Using #C.net 3.5
I'm aware of the ILMerge and alike techniques, but I would actually like to make use of Jeffrey Richter's suggestions.
After adding this code to the constructor there are namespace troubles.
Jeffrey Richter's code:
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);
}
};
I set the two DLL's as "Embedded Resource" and added them as a Reference, but when i build the program, the two dll are still "Un-embbeded", I then removed them as a Reference but then when i build the program there are errors saying: "the type or namespace cannot be found...are you missing a using directive or an assembly reference?" I have the two namespaces added as a using directive..., I then tried to remove the two references and the two using directives and still errors.
here is my code:
using System.Reflection;
namespace WindowsFormsApplication2
{
public partial class Ndice : Form
{
public Ndice()
{
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);
}
};
InitializeComponent();
}
}
}