diff --git a/access-add-in/source/modules/NetComDomain.cls b/access-add-in/source/modules/NetComDomain.cls index 0f10d91..0a32213 100644 --- a/access-add-in/source/modules/NetComDomain.cls +++ b/access-add-in/source/modules/NetComDomain.cls @@ -22,7 +22,6 @@ Attribute VB_Exposed = False ' ' com/NetComDomain.cls ' _codelib/license.bas -' stdole20{00020430-0000-0000-C000-000000000046} ' _examples/com/NetComDomain_Example_ShowWinForm_Minimal.bas ' Creates objects from a .NET COM library without registration (hosts the .NET 4 CLR, no references needed) ' @@ -228,15 +227,16 @@ Private Sub ReleaseComPointer(ByRef Pointer As LongPtr) End If End Sub -' Wraps an IUnknown pointer into an Object variable (QueryInterface for IDispatch). -' The caller still owns its own reference. +' Wraps an IUnknown pointer into an Object variable. The caller still owns its own reference. +' Unknown must be declared As Object: As stdole.IUnknown makes the Set below call +' QueryInterface(IDispatch), which the default AppDomain rejects (error 13, type mismatch). Private Function ObjectFromPointer(ByVal Pointer As LongPtr) As Object - Dim Unknown As stdole.IUnknown + Dim Unknown As Object Dim NullPointer As LongPtr CopyMemory Unknown, Pointer, PointerSize ' no AddRef - Set ObjectFromPointer = Unknown ' QueryInterface(IDispatch) incl. AddRef + Set ObjectFromPointer = Unknown ' AddRef CopyMemory Unknown, NullPointer, PointerSize ' no Release when Unknown goes out of scope End Function