I decided to leave my other question to die, as I was thinking of a new idea using the Jeffrey Richter method written on this page to integrate the .dll library into my application. So I added my DLL file as an embedded resource, and also added it as a link. Then in Program.cs (I have no idea where the code he sent should go), I added the following:
... [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); string[] args = Environment.GetCommandLineArgs(); if (args.Length > 1) _in = args[1]; SingleInstanceController controller = new SingleInstanceController(); controller.Run(args); AppDomain.CurrentDomain.AssemblyResolve += (sender, argsx) => { String resourceName = "AssemblyLoadingAndReflection." + new AssemblyName(argsx.Name).Name + ".dll"; using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName)) { Byte[] assemblyData = new Byte[stream.Length]; stream.Read(assemblyData, 0, assemblyData.Length); return Assembly.Load(assemblyData); } } ;
Should I change the name of the resource to something else? Did I add it correctly (in the right place)?
Now the problem is that I still cannot find and load the assembly, and I'm not sure what I did wrong. Any help would be appreciated.
source share