Quantcast
Channel: Visual COBOL - Forum - Recent Threads
Viewing all articles
Browse latest Browse all 4356

RE: How to Change Existing Program to Make it COM

$
0
0

So if I understand correctly, you previously had 4 COBOL modules that were used as COM clients and 3 that were linked together into a native dll that was then called by your C++ application using LoadLibrary, etc. is that correct?

So what you are looking for is a way to repackage those 3 programs into a .dll that can be consumed by C#. You are posting this question to the Visual COBOL forum so I am assuming that you are talking about deploying this as a Visual COBOL application and not Net Express is that correct?

There are a couple different ways that you can go here.

If you do not have the requirement that these have a COM interface then you could load and call the native .dll directly from C# using the .NET P/Invoke technology. This involves creating a wrapper class to define the .dll name and entry points and then calling this from C#. This is documented from Microsoft and can be found here.

If you do have the requirement to have a COM interface for this then the easiest method in Visual COBOL is to create a managed .NET COBOL Class Library project and check the Register for COM Interop checkbox. In this class you would define your entry points that would be called by C# and when you build the project it will automatically create a COM Interop assembly that will be registered on your system using the Class name. You could call your native COBOL .dlls from this COM wrapper. There is an example of this here.

The third option in Visual COBOL is to recompile your existing native modules in a managed code Class Library and then they can be called directly from C# without any COM layer.

If you are still using Net Express then the wizard I am referring to is the Class Wizard and not the service interface one. This can be accessed from New-->File-->Class and then select COM Component. This will generate the required files for a COM interface and then you can call your native modules from within this.

Thanks.


Viewing all articles
Browse latest Browse all 4356

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>