這個問題是this question的續篇C#程序如何使用任何版本的COM DLL?
我們正在創建一個用C++編寫的dll,提供對某些硬件的訪問。這個DLL實現並使用COM接口訪問。我們也有一個C#程序,它通過COM對象使用這個DLL。
我們遇到了版本問題。事實上,在運行C#程序時,它絕對要使用編譯時使用的確切COM/C++ dll版本。即如果C#程序是使用COM/C++ dll 1.2.3.4編譯的,那麼程序將拒絕使用COM/C++ dll 1.2.3.5運行。
Unhandled Exception: System.TypeInitializationException: The type initializer for 'MyDllVerify.App' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'MyCorp.MyDll.Interop, Version=1.2.3.4, Culture
=neutral, PublicKeyToken=ced78d295d1e0f2b' or one of its dependencies. The system cannot find the file specified.
File name: 'MyCorp.MyDll.Interop, Version=1.2.3.4, Culture=neutral, PublicKey Token=ced78d295d1e0f2b' at MyDllVerify.App..cctor()
我想指示C#程序使用任何COM/C++ DLL版本1.2.anything。
我在哪裏可以在C#項目中配置?