Author: sandervanderburg
Date: Tue Sep 13 12:17:28 2011
New Revision: 29236
URL: https://ssl.nixos.org/websvn/nix/?rev=29236&sc=1
Log:
Oops: forgot to include the wrapper class
Added:
nixpkgs/trunk/pkgs/build-support/dotnetenv/Wrapper.cs.in (contents, props
changed)
Added: nixpkgs/trunk/pkgs/build-support/dotnetenv/Wrapper.cs.in
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ nixpkgs/trunk/pkgs/build-support/dotnetenv/Wrapper.cs.in Tue Sep 13
12:17:28 2011 (r29236)
@@ -0,0 +1,64 @@
+using System;
+using System.Reflection;
+using System.IO;
+
+namespace @NAMESPACE@
+{
+ class @MAINCLASSNAME@Wrapper
+ {
+ private String[] AssemblySearchPaths = { @ASSEMBLYSEARCHPATHS@ };
+
+ public @MAINCLASSNAME@Wrapper()
+ {
+ AppDomain currentDomain = AppDomain.CurrentDomain;
+ currentDomain.AssemblyResolve += new
ResolveEventHandler(MyResolveEventHandler);
+ }
+
+ static void Main(string[] args)
+ {
+ // Initialise the wrapper so that the missing library assemblies
are loaded
+ new @MAINCLASSNAME@Wrapper();
+
+ // Call the original main method
+ @[email protected](args);
+ }
+
+ private Assembly MyResolveEventHandler(object sender, ResolveEventArgs
args)
+ {
+ //This handler is called only when the common language runtime
tries to bind to the assembly and fails.
+
+ //Retrieve the list of referenced assemblies in an array of
AssemblyName.
+ Assembly MyAssembly, executingAssemblies;
+ string assemblyPath = "";
+
+ executingAssemblies = Assembly.GetExecutingAssembly();
+ AssemblyName[] referencedAssemblies =
executingAssemblies.GetReferencedAssemblies();
+
+ //Loop through the array of referenced assembly names.
+ foreach (AssemblyName assemblyName in referencedAssemblies)
+ {
+ //Check for the assembly names that have raised the
"AssemblyResolve" event.
+ if (assemblyName.FullName.Substring(0,
assemblyName.FullName.IndexOf(",")) == args.Name.Substring(0,
args.Name.IndexOf(",")))
+ {
+ //Retrieve the name of the assembly from where it has to
be loaded.
+ String dllName = args.Name.Substring(0,
args.Name.IndexOf(",")) + ".dll";
+
+ //Search for the right path of the library assembly
+ foreach (String currentAssemblyPath in AssemblySearchPaths)
+ {
+ assemblyPath = currentAssemblyPath + "/" + dllName;
+ if (File.Exists(assemblyPath))
+ break;
+ }
+ }
+ }
+
+ //Load the assembly from the specified path.
+ MyAssembly = Assembly.LoadFrom(assemblyPath);
+
+ //Return the loaded assembly.
+ return MyAssembly;
+ }
+
+ }
+}
_______________________________________________
nix-commits mailing list
[email protected]
http://mail.cs.uu.nl/mailman/listinfo/nix-commits