We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents c2a24e0 + b3a08d5 commit 6bcc6b4Copy full SHA for 6bcc6b4
Rubberduck.VBEEditor/ComManagement/TypeLibs/TypeLibsSupport.cs
@@ -561,7 +561,11 @@ public static T ReadComObjectStructure<T>(object comObj)
561
throw new ArgumentException("Expected a COM object");
562
}
563
564
- var referencesPtr = Marshal.GetIUnknownForObject(comObj);
+ var referencesPtr = Marshal.GetIUnknownForObjectInContext(comObj);
565
+ if (referencesPtr == IntPtr.Zero)
566
+ {
567
+ throw new InvalidOperationException("Cannot access the TypeLib API from this thread. TypeLib API must be accessed from the main thread.");
568
+ }
569
var retVal = StructHelper.ReadStructureSafe<T>(referencesPtr);
570
Marshal.Release(referencesPtr);
571
return retVal;
0 commit comments