Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi Guys

I am currently trying to load DLL's at runtime rather than loading all the DLL's at the same time.

The issue i am having is that service that is running, has earlier or diff version of the dll i want to execute at runtime

so for example the service has datatools.dll v1, but when the process runs i want it to use the datatools.dll v2, so i have some code which calculates the dll that needs to be used. 

So what i was thinking might work is having the service create a new app domain and load the dll's required to run load into the new app domain so that it does not conflict with the app domain the service is running from.

The issue i am having is the new app domain does not want to load the dll, keep getting an error the dll does not exist, but i am reading the bytes of the file.

Please could you advise.


What I have tried:

tried using the below
<pre>class ProxyDomain : MarshalByRefObject
        {

AppDomain DLLDomain = CreateChildDomain(DLLPath);

byte[] buffer = File.ReadAllBytes(DLLPath);

Assembly assembly = DLLDomain.Load(buffer);


}
Posted
Updated 10-Jun-19 4:22am

1 solution

It sounds like you're tryitg to perform "live" updates without having to stop the service and restart.

0) One alternative is to have the service monitor the install folder for changes to referenced DLLs, and have it restart itself when it detects a change.This would eliminate the need to load DLLs manually.

1) Look into using MAF or MEF - Google Search - "c# MAF"[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900