Visual COBOL native program calls .NET managed via COM Interop fails when run under COBOL Server

0 Likes
over 8 years ago

Problem:

Customer has an application developed in Visual COBOL 2.1 for Visual Studio 2010. This application has a native program which calls a .NET managed .dll using COM Interop. The project for the .NET managed .dll has the option Register for COM Interop checked so that the .dll will automatically be registered for use as a COM server when the project is built.

When the customer deploys this application to a computer on which COBOL Server 2.1 is installed the call from native program to managed fails. Why?

Resolution:

As this program is created as a COM Server it needs to be registered on the production computer.

When you use Visual Studio in development the IDE will automatically register the .dll with COM when you check the COM Interop property but this is only on the development computer.

In production you need to run the regasm.exe utility which is part of the .NET Framework. You need to run the correct version for the .NET Framework your application is targeting.

regasm also assumes that your .dll has been installed into the GAC so that it assumes that this is where the .dll will be located. If you do not install it into the GAC then you need to use the /codebase switch when running regasm so that it will store the absolute location of the .dll in the registry.

You should create a strong name key for the .assembly in order to do this or regasm will give you a warning message.

Take a look at the following article as it may give you some pointers:

http://blogs.msdn.com/b/jigarme/archive/2008/04/28/how-to-register-net-assembly-for-com-interop.aspx

Comment List
Anonymous
Related Discussions
Recommended