how to create a Net assembly as replacement for existing COM component



Hi !

I'm supposed to make an assembly, which will replace existing VB 6.0
COM component. And currently I'm in the dead end - as I've tried
everything and it doesn't work.


Altough typelibs look almost the same, a test application I have,
doesn't work with .Net assembly while it works with existing COM
component.
In the former case it crashes. I don't have its source code, so I can
only speculate. But iMO it crashes when trying to instantiate
cCalibration class (doesn't react when method's name is changed, for
instance).
I think it uses early binding, that's why I assigned GUIDs found in
COM typelib to my class, interface and assembly as well as DispIDs.
I made a VBScript (with late biding), which shows, that registration
of my assembly is OK.
I think I fallowed all, what was said here (strong name etc.):
http://msdn.microsoft.com/en-us/library/ms996450.aspx#intwebsv_topic3
but still no progress. :-(


Any suggestions ?


Here is a info on existing COM, or actually COM+ component :
===================================================================================================
// Generated .IDL file (by the OLE/COM Object Viewer)
//
// typelib filename: fcdCalibration.tlb

[
uuid(D0D94D02-F8F1-4491-BE31-7A962384023B),
version(4.0),
custom(50867B00-BB69-11D0-A8FF-00A0C9110059, 9782)

]
library fcdCalibration
{
// TLib : // TLib : COM+ Services Type Library : {2A005C00-
A5DE-11CF-9E66-00AA00A3F464}
importlib("COMSVCS.DLL");
// TLib : OLE Automation : {00020430-0000-0000-C000-000000000046}
importlib("stdole2.tlb");

// Forward declare all types defined in this typelib
interface _cCalibration;

[
odl,
uuid(E0AA626C-992B-4D29-8EDE-7970AA7EAC7E),
version(1.0),
hidden,
dual,
nonextensible,
oleautomation
]
interface _cCalibration : IDispatch {
[restricted] void Missing7();
[restricted] void Missing8();
[restricted] void Missing9();
[id(0x60030003)]
HRESULT CalibrationTestsFinished(
[in] BSTR p_sCaller,
[in] BSTR p_sChassisType,
[in] BSTR p_sChassisNumber,
[in] BSTR p_sComponentID,
[in] BSTR p_sStationID,
[in] BSTR p_sXMLCalibResults,
[in, optional, defaultvalue("engGB")] BSTR
p_sLanguage);
[id(0x60030004)]
HRESULT GetTestFile(
[in] BSTR p_sCaller,
[in] BSTR p_sChassisType,
[in] BSTR p_sChassisNumber,
[in] BSTR p_sComponentID,
[in] BSTR p_sStationID,
[in, optional, defaultvalue("engGB")] BSTR
p_sLanguage,
[out, retval] BSTR* );
};

[
uuid(3D6F167C-5B25-4EF4-A848-3BF37CF6F824),
version(1.0)
]
coclass cCalibration {
[default] interface _cCalibration;
interface ObjectControl;
};
};
===================================================================================================


This is a content of my VB.NET class
===================================================================================================
Imports System.EnterpriseServices
Imports System.Runtime.InteropServices

Namespace fcdCalibration


<Guid("E0AA626C-992B-4D29-8EDE-7970AA7EAC7E")> _
<InterfaceType(ComInterfaceType.InterfaceIsDual)> _
Public Interface _cCalibration
<DispId(1610809347)> _
Sub CalibrationTestsFinished(ByVal p_sCaller As String, _
ByVal p_sChassisType As String, _
ByVal p_sChassisNumber As String,
_
ByVal p_sComponentID As String, _
ByVal p_sStationID As String, _
ByVal p_sXMLCalibResults As
String, _
Optional ByVal p_sLanguage As
String = "engGB")

<DispId(1610809348)> _
Function GetTestFile(ByVal p_sCaller As String, _
ByVal p_sChassisType As String, _
ByVal p_sChassisNumber As String, _
ByVal p_sComponentID As String, _
ByVal p_sStationID As String, _
Optional ByVal p_sLanguage As String =
"engGB") As String
End Interface


<Guid("3D6F167C-5B25-4EF4-A848-3BF37CF6F824")> _
<ProgId("fcdCalibration.cCalibration")> _
<ClassInterface(ClassInterfaceType.None)> _
Public Class cCalibration
Inherits ServicedComponent
Implements _cCalibration

Public Sub New()
MyBase.New()
End Sub

Sub CalibrationTestsFinished(ByVal p_sCaller As String, _
ByVal p_sChassisType As String, _
ByVal p_sChassisNumber As String,
_
ByVal p_sComponentID As String, _
ByVal p_sStationID As String, _
ByVal p_sXMLCalibResults As
String, _
Optional ByVal p_sLanguage As
String = "engGB") Implements _cCalibration.CalibrationTestsFinished
End Sub

Function GetTestFile(ByVal p_sCaller As String, _
ByVal p_sChassisType As String, _
ByVal p_sChassisNumber As String, _
ByVal p_sComponentID As String, _
ByVal p_sStationID As String, _
Optional ByVal p_sLanguage As String =
"engGB") As String Implements _cCalibration.GetTestFile

Dim sReturn As String

sReturn = "smt"
Return sReturn

End Function
End Class
End Namespace

===================================================================================================


and its type lib:
===================================================================================================

// Generated .IDL file (by the OLE/COM Object Viewer)
//
// typelib filename: fcdCalibration.tlb

[
uuid(D0D94D02-F8F1-4491-BE31-7A962384023B),
version(4.0),
custom(90883F05-3D28-11D2-8F17-00A0C9A6186D, fcdCalibration,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b69ef2b4b39dc23f)

]
library fcdCalibration
{
// TLib : // TLib : mscorlib.dll :
{BED7F4EA-1A96-11D2-8F08-00A0C9A6186D}
importlib("mscorlib.tlb");
// TLib : : {4FB2D46F-EFC8-4643-BCD0-6E5BFA6A174C}
importlib("System.EnterpriseServices.tlb");
// TLib : OLE Automation : {00020430-0000-0000-C000-000000000046}
importlib("stdole2.tlb");
// TLib : Common Language Runtime Execution Engine 2.0 Library :
{5477469E-83B1-11D2-8B49-00A0C9B7C9C4}
importlib("mscoree.tlb");

// Forward declare all types defined in this typelib
interface _cCalibration;

[
odl,
uuid(E0AA626C-992B-4D29-8EDE-7970AA7EAC7E),
version(1.0),
dual,
oleautomation,
custom(0F21F359-AB84-41E8-9A78-36D110E6D2F9,
fcdCalibration._cCalibration)

]
interface _cCalibration : IDispatch {
[id(0x60030003)]
HRESULT CalibrationTestsFinished(
[in] BSTR p_sCaller,
[in] BSTR p_sChassisType,
[in] BSTR p_sChassisNumber,
[in] BSTR p_sComponentID,
[in] BSTR p_sStationID,
[in] BSTR p_sXMLCalibResults,
[in, optional, defaultvalue("engGB")] BSTR
p_sLanguage);
[id(0x60030004)]
HRESULT GetTestFile(
[in] BSTR p_sCaller,
[in] BSTR p_sChassisType,
[in] BSTR p_sChassisNumber,
[in] BSTR p_sComponentID,
[in] BSTR p_sStationID,
[in, optional, defaultvalue("engGB")] BSTR
p_sLanguage,
[out, retval] BSTR* pRetVal);
};

[
uuid(3D6F167C-5B25-4EF4-A848-3BF37CF6F824),
version(1.0),
custom(0F21F359-AB84-41E8-9A78-36D110E6D2F9,
fcdCalibration.cCalibration)
]
coclass cCalibration {
interface _Object;
interface IRemoteDispatch;
interface IDisposable;
interface IManagedObject;
interface IServicedComponentInfo;
[default] interface _cCalibration;
};
};
===================================================================================================


.



Relevant Pages

  • Re: Converting a LPSTR* to BSTR* and back again.
    ... int ListItem(int itemNumber, ref string buffer, int tabbed, int ... you may consider the following code to convert BSTR ANSI (I ... // Convert an ANSI string to a BSTR ...
    (microsoft.public.vc.mfc)
  • Re: Converting a LPSTR* to BSTR* and back again.
    ... int ListItem(int itemNumber, ref string buffer, int tabbed, int ... you may consider the following code to convert BSTR ANSI (I ... // Convert an ANSI string to a BSTR ...
    (microsoft.public.vc.mfc)
  • RE: how to create a Net assembly as replacement for existing COM compo
    ... COM typelib to my class, interface and assembly as well as DispIDs. ... BSTR p_sChassisType, ... Sub CalibrationTestsFinished(ByVal p_sCaller As String, ...
    (microsoft.public.dotnet.framework.interop)
  • Re: Code Page problem in SetWindowText
    ... LPCTSTR cast would be dangerous in a Unicode build if the function takes char *. ... BSTR bstr = NULL; ... This tells you to convert the string using code page 1252, ... I think MBCS may be the only choice for it. ...
    (microsoft.public.vc.mfc)
  • How to return string?
    ... but and in my client,I can't get the string, ... how to solve it?I want to know if the retunr string type must be BSTR? ...
    (microsoft.public.vc.atl)

Loading