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!


Answer this question

C++/CLI linked with win32 dll's in C# (msvs2005)

  • Dejvino

    Hi! thanks for the answer!
    All the projects are in one solution and the svcore is set to depend on engineA and engineB. eventvwr doesn't catch the error messages because it seems they're caught by the editor. The problem is not when the program is running (because then it finds the engine dll's), but when I'm compiling/using the visual editor. I get the error message I told about in the other post when compiling, and when trying to draw the canvas control, I'm told that msvs failed to create the control and will remove it from the toolbox.

    I have not changed any manifest related settings, and the manifest for svcore is there, but it doesn't really contain much information.

  • Eppz

    Hello,

    I'm glad you found a workaround, although hopefully we can help find a solution that doesn't require copying the dlls to system folders *grin*

    The tool FusLogVw (Fusion Log Viewer) should help in determine why the assemblies are not being found, including which locations are being probed. Suzanne Cook (worked on the CLR Loader) has a great blog on debugging loader issues.

    Please feel free to post back to the forum with more technical details, or if you find a solution to your issues!

    Thanks,
    Stephen
    http://blogs.msdn.com/stfisher

  • Scott Cameron

    Hi, 

    Are all projects in one solution Does svcore specify that it depends on engineB.Dll Could you please take a look on event log (run eventvwr on the command line) post what message is logged right after the exception Also how do you compile svcore.dll /clr or /clr:pure or /clr:safe And is manifest embedded into your DLLs If you build in IDE and did not change any manifest related settings, then the answer is yes. You can also open binary in IDE and browse resource for RT_MANIFEST with ID==2. If you export this resource, you should see XML file. Let me know if it there.

    Thanks,
    Nikola
    VC++

  • Guemundur

    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).

  • C++/CLI linked with win32 dll's in C# (msvs2005)