Skip to content

Commit

Permalink
Try loading jsreport.Client dependent assemblies without specific ver…
Browse files Browse the repository at this point in the history
…sion

Fix #1
  • Loading branch information
pofider committed Nov 12, 2014
1 parent 705b04f commit b36d7dc
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
6 changes: 2 additions & 4 deletions JsReportVSTools/Impl/EmbeddedServerManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,8 @@ public RemoteTask<int> StopAsync()
/// </summary>
public override object CreateReportingService()
{
Type reportingServiceType = AppDomain.CurrentDomain.Load("jsreport.Client").GetType("jsreport.Client.ReportingService");

return Activator.CreateInstance(reportingServiceType, ServerUri);
}
return Activator.CreateInstance(LoadReportingServiceType(), ServerUri);
}

private string GetMainModuleFilePath(int processId)
{
Expand Down
4 changes: 1 addition & 3 deletions JsReportVSTools/Impl/RemoteServerManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ public RemoteTask<int> EnsureStartedAsync()

public override object CreateReportingService()
{
Type reportingServiceType = AppDomain.CurrentDomain.Load("jsreport.Client").GetType("jsreport.Client.ReportingService");

return Activator.CreateInstance(reportingServiceType, _remoteServerUri, _username, _password);
return Activator.CreateInstance(LoadReportingServiceType(), _remoteServerUri, _username, _password);
}

public string ServerUri { get { return _remoteServerUri; } }
Expand Down
24 changes: 24 additions & 0 deletions JsReportVSTools/Impl/ReportingServerManagerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Linq;
using System.Security.Permissions;
using Newtonsoft.Json;
using System.Reflection;

namespace JsReportVSTools.Impl
{
Expand Down Expand Up @@ -101,6 +102,29 @@ public override object InitializeLifetimeService()
{
return null;
}

protected Type LoadReportingServiceType()
{
AppDomain.CurrentDomain.AssemblyResolve -= CurrentDomain_AssemblyResolve;
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;

return AppDomain.CurrentDomain.Load("jsreport.Client").GetType("jsreport.Client.ReportingService");
}

private readonly IList<string> _triedWithoutVersion = new List<string>();

System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
string assemblyName = new AssemblyName(args.Name).Name;

if (_triedWithoutVersion.Contains(assemblyName))
{
return null;
}

_triedWithoutVersion.Add(assemblyName);
return Assembly.Load(assemblyName);
}
}

[Serializable]
Expand Down
2 changes: 1 addition & 1 deletion JsReportVSTools/source.extension.vsixmanifest
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="60546472-b12d-4ad6-b5ea-74401d44d9fc" Version="0.2.6" Language="en-US" Publisher="Jan Blaha" />
<Identity Id="60546472-b12d-4ad6-b5ea-74401d44d9fc" Version="0.2.7" Language="en-US" Publisher="Jan Blaha" />
<DisplayName>jsreport visual studio tools beta</DisplayName>
<Description xml:space="preserve">Extension allowing to use jsreport open source reporting platform inside visual studio. It allows to create any pdf report you can think of without lame designers just using html and javascript.</Description>
<MoreInfo>http://jsreport.net/</MoreInfo>
Expand Down

0 comments on commit b36d7dc

Please sign in to comment.