• Welcome to Theos PowerBasic Museum 2017.

Oddity with registering

Started by Edwin Knoppert, January 27, 2010, 03:55:02 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Edwin Knoppert

I am trying to prepare me an interface for my .NET assemblies.
I don't have to modify or register the assembly as long i use late binding.

Today i prepared me an IDBIND interface but keeps crashing, so i modified it all and created a dual com interface assembly and registered it with regasm to get me a tlb.

This is the declaration, *all* the functions before test are additional functions inserted by .NET.


' Generated by: PowerBASIC COM Browser v.2.00.0077
' Date & Time : 27-1-2010 at 15:43
' ------------------------------------------------
' Library Name: Classes
' Library File: C:\Documents and Settings\Edwink\Local Settings\Temp\PDB1F\Classes.tlb
' Description :
' GUID : {C9231F4B-F056-379F-B1A2-2BBBE47A52D2}
' LCID : 0
' Version : 1.0

' Class Identifiers
$CLSID_Classes_Class1 = GUID$("{9988A780-EF12-372E-98A5-78635F8494D3}")

' Interface Identifiers
$IID_Classes_Int__Class1 = GUID$("{EB5FA9C9-4EEC-3B47-8D48-74FDC77DCE1A}")

' Interface Name  : Int__Class1
' Class Name      : Class1
' ClassID         : $CLSID_Classes_Class1
Interface Int__Class1 $IID_Classes_Int__Class1
    Inherit IDispatch

    Property Get ToString <0> () As String
    Method Equals <1610743809> (Byval obj As Variant) As Integer
    Method GetHashCode <1610743810> () As Long
    Method GetType <1610743811> () As IUnknown
    Method Test <1610743812> ()
    Method Test1 <1610743813> (Byval sComment As String)
End Interface



This makes it to work.., ok what's the point?
Since i don't like registering i unregister the assembly right away.
The dll remains working, it seems there is a left-over in the registry, key: {EB5FA9C9-4EEC-3B47-8D48-74FDC77DCE1A}

Now i get two oddities, i copied the exe (and assembly) to another computer and runs also fine.., but the guid is not declared in the registry!
2nd and actually the thing i was looking for, i would like to remove the guids part from the interface like:

Interface Int__Class1
    Inherit IDispatch

    Property Get ToString <0> () As String
    Method Equals <1610743809> (Byval obj As Variant) As Integer
etc...

This crashes the call i make, i can leave the guid stuff in, maybe there is some distinction in the assembly by guid, i don't know.
Am i overlooking something?




José Roca

 
Why you want to remove the guid? Each interface declaration needs one. If you remove it, PB will assign a random one to it, and as it will be no the same as the one assigned in the assembly, the creation of an instance of that interface will fail.

Edwin Knoppert

Oh i think i get it, even while it may not be required to register the dll, the queryinterface call will need the guid.
Is that what you meant?
I was thinking a bit old fashion, i even tried the iunknown/vtable/@@pointer[]stuff :)

José Roca

Yes, QueryInterface needs the guid. In COM, interfaces are identified by its guid, not by its name.

Edwin Knoppert

Thank you, i keep forgetting everything about com... duhhh!

Btw, another stupid/forget question.
It says autodual but the interface seems not to have direct calls, only a way to use latebinding and invoking it by memberid instead of membername.
I was thinking 'dual' meant vtable + late bound via dispatch interface.

José Roca

AutoDual is related with .NET. M$ has warned not to use AutoDual ClassInterfaceType because any changes in a future version to the layout of the type or any base types will break COM clients that bind to the interface. By default, if the ClassInterfaceAttribute attribute is not specified, a dispatch-only interface is used.

See: http://msdn.microsoft.com/en-us/library/ms182205%28VS.80%29.aspx

Edwin Knoppert

I read that somewhat differently, that they meant after reordering the methods it will break the old interface definition.
That's logical + they stressed much about the memberid's in this regard.
I'll have to read it again to find out what you have read.
The IDispatch simply offers easier coding.
--
Oh, i read that topic, indeed an issue, yes .NET is different since it is harder to know or predict what compiler have been used.
It is not the goal of .NET to fix on specific versions, v2 is used in higher versions as well and is intended to be backward compatible.

Maybe the .net interface declarations are a better way to do this.
And again, not so easy to do, i mean it brings some work each time (and gain little).