Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. C++/CLI linked with win32 dll's in C# (msvs2005)

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

Scheduled Pinned Locked Moved Managed C++/CLI
helpcsharpc++questionannouncement
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • _ Offline
    _ Offline
    _eulogy_
    wrote on last edited by
    #1

    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!

    U 1 Reply Last reply
    0
    • _ _eulogy_

      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!

      U Offline
      U Offline
      ursus zeta
      wrote on last edited by
      #2

      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.

      A 1 Reply Last reply
      0
      • U ursus zeta

        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.

        A Offline
        A Offline
        Anonymous
        wrote on last edited by
        #3

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

        _ 1 Reply Last reply
        0
        • A Anonymous

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

          _ Offline
          _ Offline
          _eulogy_
          wrote on last edited by
          #4

          Hmmm... seems like I was suddenly logged out.

          U 1 Reply Last reply
          0
          • _ _eulogy_

            Hmmm... seems like I was suddenly logged out.

            U Offline
            U Offline
            ursus zeta
            wrote on last edited by
            #5

            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[^]

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups