C++/CLI linked with win32 dll's in C# (msvs2005)
-
Hi! I'm making a GUI for an engine I'm working on. The engine is separated into two win32 dll's and the GUI is supposed to be written in C#. I've decided to make the interface between C# and the engine using C++/CLI since that seems like the cleanest and best solution. So what I have is the following: EngineA.dll - the two engine dll's in win32 code EngineB.dll - * SVCore.dll - The C++/CLI interface class. Exposes functionality from the engines SceneViewer.exe - The gui Now the problem arises when I'm trying to include a reference to SVCore into the SceneViewer project (etiher a reference to the project or to the target dll). The class compiles and I get the following warning: "Warning 8 Could not load file or assembly 'SVCore, Version=1.0.2057.40039, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified." The other problem is when I try to use a canvas control that's using SVCore. I get a similar error message saying that it failed to create the component because it failed to load SVCore or one of its dependencies. Now I've found out that this is because the designer doesn't seem to find the engine dll's. I just find that strange since I've tried to place them everywhere within the project folders. Everything seems to work fine though when I put the dll's in the system32 directory - but this is NOT an option at all (editing the path is not an option either). So does anybody have any solutions as to how I should set up my projects for this to work? Or any other way to fix the problem? Thank you in advance!
-
Hi! I'm making a GUI for an engine I'm working on. The engine is separated into two win32 dll's and the GUI is supposed to be written in C#. I've decided to make the interface between C# and the engine using C++/CLI since that seems like the cleanest and best solution. So what I have is the following: EngineA.dll - the two engine dll's in win32 code EngineB.dll - * SVCore.dll - The C++/CLI interface class. Exposes functionality from the engines SceneViewer.exe - The gui Now the problem arises when I'm trying to include a reference to SVCore into the SceneViewer project (etiher a reference to the project or to the target dll). The class compiles and I get the following warning: "Warning 8 Could not load file or assembly 'SVCore, Version=1.0.2057.40039, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified." The other problem is when I try to use a canvas control that's using SVCore. I get a similar error message saying that it failed to create the component because it failed to load SVCore or one of its dependencies. Now I've found out that this is because the designer doesn't seem to find the engine dll's. I just find that strange since I've tried to place them everywhere within the project folders. Everything seems to work fine though when I put the dll's in the system32 directory - but this is NOT an option at all (editing the path is not an option either). So does anybody have any solutions as to how I should set up my projects for this to work? Or any other way to fix the problem? Thank you in advance!
Hi _eulogy_, I ran across your post over on the Microsoft Technical Forums. Pretty interesting stuff,...that left me thoroughly mystified. Does your SceneViewer code derive from the IDesignerHost interface? Given the sophistication of your project, I can't imagine that Visual Studio can't find your DLLs (this is TOO simple an error, and you obviously know your way around the compiler). I've noticed that sometimes (and this happens to me all the time), if you create multiple intersecting errors that don't conform to the compiler's internal diagnotic logic, it will issue an error message, but that message will be misleading.
-
Hi _eulogy_, I ran across your post over on the Microsoft Technical Forums. Pretty interesting stuff,...that left me thoroughly mystified. Does your SceneViewer code derive from the IDesignerHost interface? Given the sophistication of your project, I can't imagine that Visual Studio can't find your DLLs (this is TOO simple an error, and you obviously know your way around the compiler). I've noticed that sometimes (and this happens to me all the time), if you create multiple intersecting errors that don't conform to the compiler's internal diagnotic logic, it will issue an error message, but that message will be misleading.
Thank you for the interest :) No, I'm not inheriting from IDesignerHost and I'm still puzzled by this problem. I've found that doing the following things work: 1: Put the engine dll's in windows\system32 2: Put the location of the engine dll's in the path 3: Put the engine dll's in the same folder as devenv.exe Point number three made me a bit more certain about a suspicion I had. It seems as though the ide loads up the managed dll's as normal from their right directories, because thir whereabouts are stored in the project. The unmanaged engine dll's on the other hand are only referenced by one of the managed dll's and in an "unmanaged way". The problem might be that the ide thinks that the current search directory is the same as the running exe resides in (which happens to be devenv.exe) and not the directory that the managed dll resides in or the directory pointed to by the project. This is only a hypothesis though (hope my ramblings made sense :P).
-
Thank you for the interest :) No, I'm not inheriting from IDesignerHost and I'm still puzzled by this problem. I've found that doing the following things work: 1: Put the engine dll's in windows\system32 2: Put the location of the engine dll's in the path 3: Put the engine dll's in the same folder as devenv.exe Point number three made me a bit more certain about a suspicion I had. It seems as though the ide loads up the managed dll's as normal from their right directories, because thir whereabouts are stored in the project. The unmanaged engine dll's on the other hand are only referenced by one of the managed dll's and in an "unmanaged way". The problem might be that the ide thinks that the current search directory is the same as the running exe resides in (which happens to be devenv.exe) and not the directory that the managed dll resides in or the directory pointed to by the project. This is only a hypothesis though (hope my ramblings made sense :P).
-
I read what the responses were over at MS Technical Forums. I was on the wrong track with my last question. In Visual C++ .NET you reference another .NET assembly by inserting the #using directive in your source code. You also, as you now know, must set the LIBPATH variable that the compiler uses to search for your associated .NET assemblies. This can be done very simply by opening the Property pages for your Project (from the Solution Explorer). The following MSDN information will explain this: The Using Directive[^] And, you might want to read this, it describes how to set the path of directories that Visual Studio looks in for project files and Dlls. VC++ Directories, Projects, and Options Dialog Box[^] Referencing an unmanaged Win32 DLL is different. You must use Interop. Consuming Unmanaged DLL Functions[^] A better solutuion would be to use the Type Library Importer to convert your Win32 DLLs to assemblies, which can then be used in a managed project as if they were .NET assemblies. Type Library Importer[^]