From 8e0e78f716258adf7c41e1a433d1d60acc23e193 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20P=C3=B6tzl?= Date: Sun, 29 Nov 2026 22:44:19 +0100 Subject: [PATCH] Fix type mismatch in NetComDomain.ObjectFromPointer --- access-add-in/source/modules/NetComDomain.cls | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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