简体   繁体   中英

Dynamic load and call of C# DotNet DLL from another C# DotNet DLL

I don't know if what I want to do is even possible. I have two C# DotNet DLLs: Parent.DLL and Child.DLL. Both are built with Visual Studio 2010 using .NET Framework 4.

Parent.DLL makes use of routines in Child.DLL. However, at runtime, Parent.DLL and Child.DLL will be in different directories.

Is there a way for Parent.DLL to dynamically load and use Child.DLL at runtime?

I came across this example for use in a console app that is dynamically loading a DotNet DLL and I'm trying to adapt it for use by a DotNet DLL. However, the reference it requires is not recognized when added to the project:

using System.Runtime.Loader;

Is what I am trying to do even possible? Do I need a later version of DotNet?

The phrase you are looking for is reflection. Reflection in the .NET framework allows for dynamically loading in DLL's into the calling assembly assuming they are written in the .NET framework and the methods you are trying to call are public. MSDN has good documentation on it as was already mentioned previously here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM