How to define the path to an assembly DLL in the applicationConfig.xml

I'm working with some software where I can extend the functionality by adding libraries to it.
In order to add the new stuff, I create a library and point to it in an ApplicationConfig.xml that resides in the directory of the executable.

The new DLL can be put either in the GAC (which I have to avoid) or in the directory of the executable, then it works fine. I would like to put my custom assemblies in a separate directory so I need to add the path somehow.

This is the definition I currently have that works with the MyTest.DLL in the GAC or in the directory of the EXE.
<Assembly name="MyTest, Version=, Culture=neutral, PublicKeyToken=null">
      <Module class="My.Namespace.Class.MyTest">

The assembly is: MyTest.dll
The class included in this one is: My.Namespace.Class.MyTest

CAVEAT: I'm not sure if this is .NET standard or something custom for this particular application.
If it's not standard, I have to try to get the info from the vendor but I suspect a response might take a while so I try here first.
Who is Participating?
Gautham JanardhanConnect With a Mentor Commented:
AppDomain.CurrentDomain.AssemblyResolve +=
                new ResolveEventHandler(CurrentDomain_AssemblyResolve);

static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
            string AssemblyFullName = args.Name;
            //load from the folder u want as

            Assembly assembly = Assembly.LoadFile(assemblyPath);
            return assembly;
Gautham JanardhanCommented:
u can hook assembly resolve event of appdomain to do this
Sharp2bAuthor Commented:
I'm not sure where I could add this code.
My code is not loaded unless the main application can find it as defined in the ApplicationConfig.xml
7 new features that'll make your work life better

It’s our mission to create a product that solves the huge challenges you face at work every day. In case you missed it, here are 7 delightful things we've added recently to monday to make it even more awesome.

Gautham JanardhanCommented:
if winfors then in programs.cs
if WPF app then app.xaml.cs
Sharp2bAuthor Commented:
Thanks, I probably need to clarify the situation.
I'm extending the functionality of an application that is outside of my control. On startup, this application reads the ApplicationConfig.xml to find out what assemblies to load. One of them being my custom code. None of my code is executed unless it's loaded as specified in the xml file.

The problem is to get my code loaded from a specific location that is not the directory of the exe (where ApplicationConfig.xml is also located) or the GAC. So, I need a way to specify the path to the DLL in the xml file. Maybe this is not standard .NET stuff but something that is defined by the vendor of this application. Then I might have to ccontact their developers to find out if this is possible.

Sorry if I was not clear before
Gautham JanardhanCommented:
if u dont have acesst to the startup then this soln cant be used..
ApplicationConfig.xml is this deefined by the vendor ?  then u will have to contact them for more info..
Sharp2bAuthor Commented:
I will do so.
Thanks a lot for your help anyway, and I will accept your solution above as I had no idea about this possibility and I think it can come in handy in other projects later on.
Sharp2bAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.