Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

How To Call a COM DLL from a Net DLL


1 reply to this topic

sanjoygr

sanjoygr
  • Full Members
  • 76 posts

Posted 03 May 2006 - 08:40

Dear All

I have an .Net application where I am using MSXML4.0 along with another COM called MyValidator.dll.

1. For this I have included XML4.0 in the merge modules for distribution while preparing setup using InstallShield 11 basic MSI.

2. For the other COM dll I have made a Component (COM server) and a key of MyValidator.dll and made sure that it gets registered by checking Self register and Always Overwrite checkbox.

My queries

1.Is it required to put MSXML4.dll in the bin folder of the application? I find the apllication fails to access the MSXML4.dll if not in bin folder as it generally gets installed and registered in c:\winnt\system32 folder.

2. To call a class xyz available in the COM dll from a .Net dll is it required to put full name eg MyValidator.MyClassName() even though the the dll MyValidator.dll is getting registered.

Thanks
Sanjoy





russellperry

russellperry
  • Full Members
  • 31 posts

Posted 08 May 2006 - 23:19

QUOTE
1.Is it required to put MSXML4.dll in the bin folder of the application? I find the apllication fails to access the MSXML4.dll if not in bin folder as it generally gets installed and registered in c:\winnt\system32 folder.


The registration of a COM dll should succeed from any directory. You load up a COM object by CLSID or ProgID. If it's been registered correctly and not moved or corrupted, the directory shouldn't matter. If you have the OLE viewer utility from Visual Studio, or some other COM viewer, check to make sure the dll is registered under the CLSID/ProgID you expect, and that it is the version you expect.

QUOTE
2. To call a class xyz available in the COM dll from a .Net dll is it required to put full name eg MyValidator.MyClassName() even though the the dll MyValidator.dll is getting registered.


This last question is outside the scope of this forum, but I'll try to give a brief answer.

The string you're using, "MyValidator.MyClassName()" looks like a ProgID, exept the parentheses at the end are incorrect formatting. The ProgID information you need should be in the documentation for the COM dll you're using.

You can also look at the COM information that InstallShield extracts from the .dll in the component view. If there are ProgIDs for your class, they'll show up in the Installation Designer under: Components -> [Your Component] -> Advanced Settings -> COM Registration -> ProgIDs. If no COM information shows up, you can right-click on the file under Components -> [Your Component] -> Files -> [Your COM dll] and select "Refresh (or Extract) COM Data For Key File."

The format for a ProgID is ProjectName.ClassName, so yes, it will look like 'MyValidator.MyClassName' only without any parentheses at the end. If you have parenthese on your Class name in your code, that could be the problem.

This is going to be the case in any language, .NET, C++, VB, whatever. It sounds to me like you need to hit your dll's docs and look for code samples demonstrating the correct method to load up the class you want.

MSDN may be a good place to start.

Edited by russellperry, 08 May 2006 - 23:25.