I want to load only some classes from a given dll. The problem is the following:
I have the following of dll files.
Dll 1:
Namespace:
Dll 2:
Namespace:
As shown in the example above, it is possible and likely to happen that I have 2 or even more dlls with the same classes in it. (Note that the namespaces are the same)
Now I thought of the following:
Is there any way to do something like that?
You have two different dll file. So You can import two different dll file into you C# project. For example first dll file's name is "File1" and second dll file's name is "File2"
const string file1_Dll_Path = @"File1.dll";
const string file2_DllPath = @"File2.dll";
[DllImport(file2_DllPath, CallingConvention = CallingConvention.Cdecl)]
public static extern int YOURFUNCTIONINFILE2DLL();
[DllImport(file1_Dll_Path, CallingConvention = CallingConvention.Cdecl)]
public static extern void YOURFUNCTIONINFILE1DLL();
Note: Don't forget adding "unsafe" your C# Form. Like this
unsafe public partial class FORMNAME : Form
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.