简体   繁体   中英

C# DLL loaded for exe-application is not found when launching similar DLL by rundll32.exe

I have built a C++/CLI DLL that is a wrapper for some .NET C# DLL. As a sample application I have built a simple project for exe-application based on WindowsForms GUI. It works fine with my C++/CLI library and the mentioned .NET C# DLL. But if I build another C++ DLL, which substitutes this sample exe-application, it doesn't succeed to load the .NET C# DLL, although it is located in the current Windows path. The following exception is occurred when trying to call some function from this C# code:

An unhandled exception of type 'System.IO.FileNotFoundException' occurred in MyApp.dll Additional information: Could not load file or assembly 'xxxx, Version=yyyy, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified

What are possible problems? In general, how should C# DLLs be linked to unmanaged executables? Is it manifest's problem? Thanks in advance.

The windows path is not used when loading .NET Assemblies. The assembly must be in the same folder as the executable, or in the GAC. (That is oversimplified a little, see the link below for more detail)

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