Hi
I am new to the concepts of using COM dlls in C# application and have an issue when I try to deploy my C# application that uses a COM dll.
Scenario:
I am trying to obtain some details of a project created in a commercial tool, by building a C# Windows Application.
For this, I have installed the tool and I am adding a reference of one of the dlls’ from the “.. /program files/ bin “ folder of the tool , into my C# Appln .
In the development environment I am able to execute the application without any issues.
The problem arises when I use the exe on other machines where the tool HAS BEEN installed.
Sample Code:
Using COMdll;
COMdll.Application appln = new COMdll.Application();
COMdll.Project prj ;
prj = appln.Somefunction(); // This line throws the COM cast exception in TEST machines
COMdll.x Reqs;
Reqs = prj.Somefunction();
I get a COM cast exception while trying to run this C# appln in any other macines. Some machines also show a Invalid cast exception in the 4th line.I am unable to reproduce these exceptions in the development environment.My understanding is that if the problem was actually that of the Invalid Cast, then this should have been raised in the development environment too.But this is not the case in the current scenario.
I am now unsure if my code actually has a problem or this issue is because of COM dll not being deployed properly in the test machines.
In case any other statements have to be used in my program to make it work on other machines,please let me know about it. I did some reading and found dllimport, PInvoke as common mentions.
P.S. The COM dll was developed in VB6
This exception appears even after I try registering the COM dll in the test machines.
The development environment and Test environments are similar.
Please help.
Thank you.
Regards,
Sandeep