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. C / C++ / MFC
  4. Calling C# dll from C++ 6.0 and GPF

Calling C# dll from C++ 6.0 and GPF

Scheduled Pinned Locked Moved C / C++ / MFC
csharpc++comdesigndebugging
2 Posts 1 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.
  • A Offline
    A Offline
    Al_Pennyworth
    wrote on last edited by
    #1

    This is a little difficult to explain. I created a dll in .NET using C# and I need to call this dll from a Visual C++ 6.0 application. I read numerous materials on setting the C# dll up with COM Interop and I think I have it working. Now for the difficult part: when I call the function to launch the UI in the C# dll, it comes up, then I do my thing and close it down. I then go through the functionality again and the dll is called w/ no problems, the form comes up, etc. When I close it down, I will get a GPF. In trying to trace the problem, it returns from my dll, then returns from my function in the 6.0 c++ application, and returns from another function. I cannot discover where the GPF is occurring. Here is a basic outline of my 6.0 c++ function: void functionname { // Initialize COM. HRESULT hr = CoInitialize(NULL); // Create the interface pointer. IManageInterfacePtr pIInterface(__uuidof(ManagerInterface)); // Call the Add method. pIInterface->LaunchRSSDLL(string, string, string); pIInterface->Dispose(); <--this is from trying something with the C# dll pIInterface->Release(); // Uninitialize COM. CoUninitialize(); } I have put try/catch inside this function, around the call to this function, inside my C# DLL COM interface, and I still cannot find where the gpf is occurring. This is my first C# dll so be please be patient if I so kind of idiotic in describing this. Any ideas on what I may be missing? Any ideas on what I can look at?

    A 1 Reply Last reply
    0
    • A Al_Pennyworth

      This is a little difficult to explain. I created a dll in .NET using C# and I need to call this dll from a Visual C++ 6.0 application. I read numerous materials on setting the C# dll up with COM Interop and I think I have it working. Now for the difficult part: when I call the function to launch the UI in the C# dll, it comes up, then I do my thing and close it down. I then go through the functionality again and the dll is called w/ no problems, the form comes up, etc. When I close it down, I will get a GPF. In trying to trace the problem, it returns from my dll, then returns from my function in the 6.0 c++ application, and returns from another function. I cannot discover where the GPF is occurring. Here is a basic outline of my 6.0 c++ function: void functionname { // Initialize COM. HRESULT hr = CoInitialize(NULL); // Create the interface pointer. IManageInterfacePtr pIInterface(__uuidof(ManagerInterface)); // Call the Add method. pIInterface->LaunchRSSDLL(string, string, string); pIInterface->Dispose(); <--this is from trying something with the C# dll pIInterface->Release(); // Uninitialize COM. CoUninitialize(); } I have put try/catch inside this function, around the call to this function, inside my C# DLL COM interface, and I still cannot find where the gpf is occurring. This is my first C# dll so be please be patient if I so kind of idiotic in describing this. Any ideas on what I may be missing? Any ideas on what I can look at?

      A Offline
      A Offline
      Al_Pennyworth
      wrote on last edited by
      #2

      I found my own answer in this article: http://www.dotnet247.com/247reference/msgs/35/178790.aspx I removed the line of code System.Windows.Forms.Application.EnableVisualStyles() and all is well.

      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