I'm trying to expose my C# class functionality through COM to my Delphi application. Quite a few articles on the internet address this subject, but so far I'm not having any luck.
I have a C# Library project for the .NET 3.5 framework (Visual Studio 2010 Express Edition).
[Guid("48D921E8-FE9E-45da-9FCC-BFE4FD076EBE")]
public class MyPublicClass
{
public MyPublicClass()
{
//Default constructor needed for COM
}
public int Add(int a, int B)/>
{
return a + b;
}
}
When I compile this to a library (DLL) it seems to work fine, I can use it in any other .NET project.
This article describes an implementation for the library. From a different article I used the Guid attribute (Generated with GuidGen.exe).
After compilation I exported the library with TlbExp.exe (Type Library Exporter) with the following parameters
TlbExp.exe MyLib.dll /tlb:MyLib.tlb /verbose
The TlbExp.exe program returns with success and puts a new .tlb file into the folder.
According to the two mentioned articles it should be ready to be used in a different language (my case Delphi 7).
When I import the Type Library and generate a wrapper class around it, this is the result that Delphi gives me:
unit LibGripDPV_TLB
interface
uses Windows, ActiveX, Classes, Graphics, StdVCL, Variants;
// *********************************************************************//
// GUIDS declared in the TypeLibrary. Following prefixes are used:
// Type Libraries : LIBID_xxxx
// CoClasses : CLASS_xxxx
// DISPInterfaces : DIID_xxxx
// Non-DISP interfaces: IID_xxxx
// *********************************************************************//
const
// TypeLibrary Major and minor versions
LibGripDPVMajorVersion = 1;
LibGripDPVMinorVersion = 0;
LIBID_LibGripDPV: TGUID = '{7C77462B-D182-4826-AA12-E40F45042BE1}';
implementation
uses ComObj;
end.
As you can see there is no implementation generated and it seems my class is not recognized or maybe not even transported properly into Type Library.
Now then, the question... What am I doing wrong? I'm probably forgetting something, but I can't figure out what.
Is there any way of checking what is inside my Type Library (.tlb)? Is it possible that Visual Studio Express doesn't provide the needed functionality?
Almost forgot, I also used the procedure described here but also no result.
Hope somebody can help me out with this...
Rico

New Topic/Question
Reply



MultiQuote




|