C++/C# InterOp and gacutil/regasm RRS feed

  • Question

  • Hello everybody,

      I am getting in the tough issue in my application. I hope I can get some advice from you. My application CatchAllMessages is mainly written in C++ and is used to catch messages from the internal network. I have many interfaces to display message data. But for some unlucky reason, we designed the new interface written in C# to catch a new message which has the different platform compared to messages caught in CatchAllMessages application. That's why I am using Interop to regsiter the C# DLL as the COM object.

      What I did was to create the DataWrapper.cpp class( in DataWrapper project ) which translates some basic data of the message, such as IPAddress and the content of the message. Then, I created the NewMessage.cs( written in C#) in the NewMessage project. My NewMessage.cs class can catch the content of the message sent by the DataWrapper.cpp and then display to the NewMessage interface.

      To open the NewMessage interface, I have to run the following DOS commands after compiling to produce CatchAllMessages.dll, DataWrapper.dll, and NewMessage.dll:

      gacutil /i DataWrapper.dll CatchAllMessages\Debug

      gacutil /i NewMessage.dll CatchAllMessages\Debug

      regasm DataWrapper.dll /tlb:CatchAllMessages\Debug\com.DataWrapper.tlb

      regasm NewMessage.dll /tlb:CatchAllMessages\Debug\com.NewMessage.tlb


      Two tools, gacutil and regasm, are provided by .NET Framework 1.1.

      After that, I execute my application CatchAllMessages from the .NET 2003 IDE. The code works fine. My problem is that I don't want the user to run those DOS commands. The user just needs to double click CatchAllMessages.exe to run the application.

      Do you know any way to run those commands programmatically? I really appreciate your help and thank you for reading the message.


    Wednesday, September 13, 2006 11:46 PM


  • You need to add a reference to the assembly "System.EnterpriseServices" in the project's Add New References... dialog box.
    Saturday, September 16, 2006 1:31 PM

All replies

  • CreateProcess from the Windows SDK?
    Thursday, September 14, 2006 12:55 AM
  • I have found the Publish class which has GacInstall and RegisterAssembly method. However, I got the namespace error. As the document says, I have to include the namespace System.EnterpriseServices.Internal.

    I included these:

    #using <mscorlib.dll>

    #using <System.dll>

    using namespace System;

    using namespace System::EnterpriseServices;

    But the compiler says "EnterpriseServices can not be found".

    Can you please tell me a solution?


    Thursday, September 14, 2006 12:57 AM
  • Thank you for your reply.

    I am using the CreateProcess to execute gacutil.exe, and it works. However, the DOS window appears for a second, then disappears. What can I do to not display the DOS window?

    Thursday, September 14, 2006 3:12 PM
  • You need to add a reference to the assembly "System.EnterpriseServices" in the project's Add New References... dialog box.
    Saturday, September 16, 2006 1:31 PM