Hello.
I've used ILMerge in the past when I needed to include the DLL's my assemblies depended on and only have to distribute a single exe file.
Jeffrey Richter recently posted some c# code that allows you to embed the DLL's and load them from a byte array as embedded resources.
I wonder if anyone here has done this in VB.net yet?( Without a bunch of off topic discussion about "if this is legal to do")
I've tried to understand how you would do this in VB.net, but I'm kinda at a loss..
Here is the original link
http://blogs.msdn.com/b/microsoft_pr...d-edition.aspx
Here's the code sample he gives(in c#), I'm just not sure how to handle the event in VB.net since among many things the sub main is semi hidden and my lack of the appdomain knowledge
A rough conversion to vb.netCode:AppDomain.CurrentDomain.AssemblyResolve += (sender, args) => { String resourceName = "AssemblyLoadingAndReflection." + new AssemblyName(args.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); } };
Anyone ever done this before? Perhaps a working code sample?Code:AppDomain.CurrentDomain.AssemblyResolve += Function(sender, args) Dim resourceName As [String] = "AssemblyLoadingAndReflection." + New AssemblyName(args.Name).Name & ".dll" Using stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName) Dim assemblyData As [Byte]() = New [Byte](stream.Length - 1) {} stream.Read(assemblyData, 0, assemblyData.Length) Return Assembly.Load(assemblyData) End Using End Function
Thanks in advance!




Reply With Quote