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. .NET COM Interop problem

.NET COM Interop problem

Scheduled Pinned Locked Moved C / C++ / MFC
comcsharphelpc++
6 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.
  • M Offline
    M Offline
    mpastchenko
    wrote on last edited by
    #1

    Hello folks, This one has been bugging me for quite a while, I sort of have a solution but it is quite time conuming. I have a DLL written in VB.NET that I would like to use in console applciation C++. Project properties in VB.NET are set for COM interop, and I can see in the registry after I run it. The problem comes up when I try to use if in C++. Here is import statement: #import "\VOT\ADLL\ADLL\bin\Debug\AndrDLL.tlb" raw_interfaces_only raw_native_types no_namespace but I cannot even expose methods correctly, C++ does not see the interface... One way to fix is rewriting Vb project to C# project. Can anyone suggest something better and faster? Thanks in advance. Sincerely, Max Pastchenko

    M 1 Reply Last reply
    0
    • M mpastchenko

      Hello folks, This one has been bugging me for quite a while, I sort of have a solution but it is quite time conuming. I have a DLL written in VB.NET that I would like to use in console applciation C++. Project properties in VB.NET are set for COM interop, and I can see in the registry after I run it. The problem comes up when I try to use if in C++. Here is import statement: #import "\VOT\ADLL\ADLL\bin\Debug\AndrDLL.tlb" raw_interfaces_only raw_native_types no_namespace but I cannot even expose methods correctly, C++ does not see the interface... One way to fix is rewriting Vb project to C# project. Can anyone suggest something better and faster? Thanks in advance. Sincerely, Max Pastchenko

      M Offline
      M Offline
      mpastchenko
      wrote on last edited by
      #2

      Has anyone, in fact, successfully used a VB.NET dll in C++. I wrote a small VB project that creates dll, which just adds two numbers. I get some exception. While the code converted to C# works fine. this is my code: ICalculatorPtr mycalculator("CompareDLL.Test"); long one = 10; long two = 20; long lBla; mycalculator->Add(one,two,&lBla); if I try to use ICalculator, i get error message cannot create abstract class... :( Sincerely, Max Pastchenko

      M 1 Reply Last reply
      0
      • M mpastchenko

        Has anyone, in fact, successfully used a VB.NET dll in C++. I wrote a small VB project that creates dll, which just adds two numbers. I get some exception. While the code converted to C# works fine. this is my code: ICalculatorPtr mycalculator("CompareDLL.Test"); long one = 10; long two = 20; long lBla; mycalculator->Add(one,two,&lBla); if I try to use ICalculator, i get error message cannot create abstract class... :( Sincerely, Max Pastchenko

        M Offline
        M Offline
        mpastchenko
        wrote on last edited by
        #3

        writing an answer, to one part pf problem. for previous post: initializing COM actually worked :-) // initialize COM HRESULT hr = CoInitialize(NULL); Sincerely, Max Pastchenko

        M 1 Reply Last reply
        0
        • M mpastchenko

          writing an answer, to one part pf problem. for previous post: initializing COM actually worked :-) // initialize COM HRESULT hr = CoInitialize(NULL); Sincerely, Max Pastchenko

          M Offline
          M Offline
          mpastchenko
          wrote on last edited by
          #4

          Is it possible that DLL project is implemented incorrectly? I still dont see my interface in the dropdown..... Sincerely, Max Pastchenko

          M 1 Reply Last reply
          0
          • M mpastchenko

            Is it possible that DLL project is implemented incorrectly? I still dont see my interface in the dropdown..... Sincerely, Max Pastchenko

            M Offline
            M Offline
            mpastchenko
            wrote on last edited by
            #5

            .hmmmmmmm There is something I am confused about now, I hope someone can clarify this for me SO i have added one method to an interface in VB.NET created DLL used it in C++ works fine. Now, I add another method to it, it does not display second method. When I delete original method from VB.NET code, in C++ it still sees it present in the dropdown but gives me compilation error. Can someone please clarify this? Sincerely, Max Pastchenko

            M 1 Reply Last reply
            0
            • M mpastchenko

              .hmmmmmmm There is something I am confused about now, I hope someone can clarify this for me SO i have added one method to an interface in VB.NET created DLL used it in C++ works fine. Now, I add another method to it, it does not display second method. When I delete original method from VB.NET code, in C++ it still sees it present in the dropdown but gives me compilation error. Can someone please clarify this? Sincerely, Max Pastchenko

              M Offline
              M Offline
              mpastchenko
              wrote on last edited by
              #6

              problem solved. Every time VB builds a project, a .tlb is created (privided COM Interop option is chosen) This tlb is linked with a C++ project that uses .DLL. So when I already have a .tlb and decide to rebuild my VB DLL project a tlb is basically recreated. The solution i found for myself is to rebuild my DLL project after closing C++ project and then opening C++ project again. Of course initializing COM is another thing that needs to be done to properly use DLL Sincerely, Max Pastchenko

              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