Skip to content

Commit

Permalink
Release 0.9.3.1
Browse files Browse the repository at this point in the history
Simplified app domain setup implementation. Just gets the path of the
executing assembly and sets the new app domain's base path to that.
  • Loading branch information
tuespetre committed Apr 16, 2014
1 parent eade4cb commit c3b9382
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 61 deletions.
63 changes: 4 additions & 59 deletions Pechkin/Factory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@ public static class Factory
/// </summary>
private static AppDomain operatingDomain = null;

/// <summary>
/// In case we are running in .NET debug, the actual location of the
/// Pechkin assembly (not in the .NET temp folders)
/// </summary>
private static String realAssemblyLocation = null;

/// <summary>
/// A thread used to invoke all calls to the wkhtmltopdf library
/// so that multi-threaded applications can use Pechkin
Expand Down Expand Up @@ -232,11 +226,9 @@ public static IPechkin Create(GlobalConfig config)
Factory.SetupAppDomain();
}

String location = Factory.realAssemblyLocation ?? Assembly.GetExecutingAssembly().Location;

ObjectHandle handle = Activator.CreateInstanceFrom(
Factory.operatingDomain,
location,
Assembly.GetExecutingAssembly().Location,
typeof(SimplePechkin).FullName,
false,
BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance,
Expand Down Expand Up @@ -283,57 +275,10 @@ private static void SetupAppDomain()
Factory.synchronizer = new SynchronizedDispatcherThread();
}

String binPath = String.Empty;

if (!String.IsNullOrEmpty(AppDomain.CurrentDomain.RelativeSearchPath))
{
String[] paths = AppDomain.CurrentDomain.RelativeSearchPath.Split(';');

for (var i = 0; i < paths.Length; i++)
{
paths[i].Remove(0, AppDomain.CurrentDomain.BaseDirectory.Length);
}

binPath = String.Join(";", paths);
}

Factory.operatingDomain = AppDomain.CreateDomain("pechkin_internal_domain", null,
new AppDomainSetup
{
ApplicationBase = AppDomain.CurrentDomain.BaseDirectory,
// Sometimes, like in a web app, your bin folder is not the same
// as the base dir.
PrivateBinPath = binPath
});

if (binPath != String.Empty)
{
Factory.operatingDomain.SetData("assemblyLocation", Assembly.GetExecutingAssembly().Location);

Factory.operatingDomain.DoCallBack(() =>
{
String location = AppDomain.CurrentDomain.GetData("assemblyLocation").ToString();
String filename = System.IO.Path.GetFileName(location);
List<String> paths = new List<String>(AppDomain.CurrentDomain.RelativeSearchPath.Split(';'));

foreach (String path in paths.ToArray())
{
paths.Remove(path);
paths.AddRange(System.IO.Directory.GetFiles(path, filename));
}

Assembly.LoadFrom(paths[0]);
var dirName = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
var setup = new AppDomainSetup() { ApplicationBase = dirName };
Factory.operatingDomain = AppDomain.CreateDomain("pechkin_internal_domain", null, setup);

AppDomain.CurrentDomain.SetData("assemblyLocation", paths[0]);
});

Factory.realAssemblyLocation = Factory.operatingDomain.GetData("assemblyLocation").ToString();
}
else
{
Factory.operatingDomain.Load(Assembly.GetExecutingAssembly().FullName);
}

Func<object> del = () =>
{
Factory.operatingDomain.SetData("useX11Graphics", Factory.useX11Graphics);
Expand Down
4 changes: 2 additions & 2 deletions Pechkin/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.9.3.0")]
[assembly: AssemblyFileVersion("0.9.3.0")]
[assembly: AssemblyVersion("0.9.3.1")]
[assembly: AssemblyFileVersion("0.9.3.1")]

0 comments on commit c3b9382

Please sign in to comment.