[Gtk-sharp-list] Dependent assemblies in Executing Assembly Folder Sub-Folders?
Iggy MA
iggy.ma at gmail.com
Wed Jun 18 18:08:39 EDT 2008
For anybody who is wondering, I figured out how to do this, specify
assemblies in other folders:
private class Program
{
public static void Main()
{
AppDomain currentDomain = AppDomain.CurrentDomain;
currentDomain.AssemblyResolve += new
ResolveEventHandler(currentDomain_AssemblyResolve);
MyProgram.Initialize();
}
static Assembly currentDomain_AssemblyResolve(object sender,
ResolveEventArgs args)
{
Assembly MyAssembly = null;
string simpleName = (new AssemblyName(args.Name).Name) + ".dll";
string path =
Path.Combine(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location.ToString()),
"mono"), simpleName);
// Try to get the assembly from one path
// If it doesn't work, get it from a different path
// Rinse and Repeat as necessary
try
{
MyAssembly = Assembly.LoadFrom(path);
}
catch
{
path = path.Replace("mono", "lib");
MyAssembly = Assembly.LoadFrom(path);
}
return MyAssembly;
}
}
private class MyProgram
{
public static void Initialize()
{
Gtk.Application.Init();
new wMain();
Gtk.Application.Run();
}
}
Iggy MA wrote:
>
> I have my executable in my bin folder, and a lot of dependent
> assemblies. I want to put those assemblies in different subfolders of
> the main executing assembly directory. I have put the dependencies and
> manually edited my csprojects to reference them there, but when I run
> my program it still says it can't find the assemblies unless they are
> in the same folder as the executing assembly.
>
> How can I specify in my assemblies where to look for dependent assemblies?
> _______________________________________________
> Gtk-sharp-list maillist - Gtk-sharp-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
>
>
--
View this message in context: http://www.nabble.com/Dependent-assemblies-in-Executing-Assembly-Folder-Sub-Folders--tp17991647p17993042.html
Sent from the Mono - Gtk# mailing list archive at Nabble.com.
More information about the Gtk-sharp-list
mailing list