Im a little confused as to how one would go about deploying a program which uses multiple DLL's. If ive understood correctly, the user needs to perform some form or setup prior to being able to run the executable using several DLL's?? Ive had a look online and in c# 4.0 in a nutshell, specifically regarding "packing a single-file executable but am still confused.
Quote
It states that this is possible by including the compiled assembly DLL's in the main exectuable project as embedded resources, and then writting an assemblyresolve event handler to load their binary images on demand.
using System;
using System.IO;
using System.Reflection;
using System.Collections.Generic;
public class Loader
{
static Dictionary <string, Assembly> libs
= new Dictionary <string, Assembly>();
static void Main()
{
AppDomain.CurrentDomain.AssemblyResolve += FindAssem;
Program.Go();
}
static Assembly FindAssem (object sender, ResolveEventArgs args)
{
string shortName = new AssemblyName (args.Name).Name;
if (libs.ContainsKey (shortName)) return libs [shortName];
using (Stream s = Assembly.GetExecutingAssembly().
GetManifestResourceStream ("Libs." + shortName + ".dll"))
{
byte[] data = new BinaryReader (s).ReadBytes ((int) s.Length);
Assembly a = Assembly.Load (data);
libs [shortName] = a;
return a;
}
}
}
public class Program
{
public static void Go()
{
// Run main program...
}
}
The following link then states the following:
Quote
A single project
If all parts of your program are written by yourself in the same language, you can obviously just add all source files to a single project. The result will be a single DLL or EXE containing all dependencies.
csc /target:winexe /out:Program.exe
MainProgram.cs ClassLibrary1.cs ClassLibrary2.cs
However, if your program is written in multiple languages or if you are using binary third party libraries, you are out of luck.
Are they both talking about the same thing or am i missing something??
Thanks for your time.

New Topic/Question
Reply



MultiQuote





|