is this an error becos of incompatible datatypes between COM+ and .Net

  • Thread starter Thread starter Buddhike de Silva
  • Start date Start date
B

Buddhike de Silva

Hi,

I created a small serviced component using VB.net.
It has an interface and a class as dfefined as follows.

CEvent.vb
---------
Imports System.EnterpriseServices

Public Class CEvent
Inherits ServicedComponent
Implements IEvent

Public Sub LogMsg(ByVal c As String, _
ByVal a As Long, _
Optional ByVal b As Int64 = 0) _
Implements IEvent.LogMsg
End Sub
End Class

IEvent.vb
----------
Imports System.Runtime.InteropServices

<InterfaceType(ComInterfaceType.InterfaceIsIUnknown)> _
Public Interface IEvent
Sub LogMsg(ByVal c As String, _
ByVal a As Long, _
Optional ByVal b As Int64 = 0)
End Interface

This compiles and builds fine. But when I try to register
this in my Windows 2000 professional machine the
regsvcs.exe program ends up with following error.


TlbExp error: Type library exporter encountered an error
while processing 'Event
Class.IEvent.LogMsg(b), EventClass'. Error: Bad variable
type.

What I noticed was when I removed the optional keyword
from the definition this works fine. Also this comes when
the optional value type is Long or something bigger than
it.

Please let me know if you know any answer.


..
 
What I noticed was when I removed the optional keyword
from the definition this works fine. Also this comes when
the optional value type is Long or something bigger than
it.

I believe Automation didn't have support for 64 bit integers in
Windows 2000 (it was introduced in WinXP). So if I were you, I'd avoid
using Long if possible.



Mattias
 
-----Original Message-----


I believe Automation didn't have support for 64 bit integers in
Windows 2000 (it was introduced in WinXP). So if I were you, I'd avoid
using Long if possible.



Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
.

Hello Mattias
Yes I agree your point. But my arugument is why MIDL
compiler or tlbexp tool detects it only when the
parameters is default?
 
Yes I agree your point. But my arugument is why MIDL
compiler or tlbexp tool detects it only when the
parameters is default?

I don't know, but I suspect that both of them eventually just call
down to the oleaut typelib generation APIs, and that perhaps it had an
issue with default int64 parameters on platforms previous to WinXP.



Mattias
 
Back
Top