Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE

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

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

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

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2013-05-30 11:15
Updated by:
 
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.