Visual Studio Development Bookmark and Share   
 index > Visual Studio Extensibility > Loading external dll in DSL Tools
 

Loading external dll in DSL Tools

Hi,

I would like to use some external library in my DSL Tools (VS 2008)
My dll is not in the GAC, so I think I have to manage manually the dll loading; could you confirm that ? (I have some strange behavior; my dll is referenced in my dsl project, it works on debug, but not when I deploy on a third machine).

where would be the best place to manage dll loading in the DSL library ?

Thanks for any help,

Nico
Nicolas Roux  Thursday, October 15, 2009 3:52 PM
I add some more information.

My intention is to add the following code somewhere:
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);

and:

      
 Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
 {
 	if (args.Name.StartsWith("MyLibrary"))
	{
		string assemblyDirectory = this.GetType().Assembly.Location;

                return Assembly.LoadFrom(string.Format(@"{0}\{1}", assemblyDirectory, "MyLibrary.dll"));
        }

        return null;
 }


Where should I put this code in my DSL project ?
Nicolas Roux  Thursday, October 15, 2009 5:37 PM

Hi Nico,

Have you checked the external library was installed on a third machine after deployed ? What is the exception code while deploy on a third machine?

If you don’t want install the assembly in the global assembly cache (GAC), you can use another two methods:

· Use an application configuration (.config) file with the <codeBase> tags

· Use the AssemblyResolve event

For more information, please refer to:

How to load an assembly at runtime that is located in a folder that is not the bin folder of the application

Best Regards,

Nancy


Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Nancy Shao  2 hours 9 minutes ago

You can use google to search for other answers

Custom Search

More Threads

• Too many GUID for Language Service Package with Managed Babel
• Overriding doubleclick in solution explorer
• WinForm designer as custom editor
• Breaking change in VS2005 Enterprise SolutionEvents "Opened" event
• GetService DTE request in Parser.cs file of my language service
• Event raised when a custom tool is run
• ContextGuids ?
• Visual Studio 2003-TestDriven.NET
• DTE.ExecuteCommand and Action.AddFolder
• Script to Colapse Solution Explorer