Skip to main content

Posts

Showing posts with the label com

Testing COM components

Here's some code you can use to try to load your Type through COM. You can use the GetPEKind method to get the platform that the assembly was compiled for. (Recently ran into a problem where I couldn't be sure the assembly I'd registered was registered correctly, my query was particular to win64, there are some changes in the registry entries for 64bit windows when running 32 bit applications.) using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Reflection; namespace ComTest { class MyGetTypeFromCLSIDSample { public static void Main() { try { Guid myGuid1 = new Guid("3A21CE6B-8571-4955-9780-BAE1EE3215C0");//my Types GUID, regasm was ran on this assembly. // Get the type associated with the CLSID // and specify whether to throw an exception if an error occurs // while loading the type. //if this shows The typ...

Interop Assemblies

What the hell are these Interop Assemblies, Primary Interop Assemblies (PIAs)? You'll see these assemblies from time to time pulled in as references in you projects, but I never really cared why they were called Interop and what it meant, I'll explain. Interop is short for interoperability meaning how to get .NET to talk to COM. Primary Interop Assembly (PIA): A PIA is an interop assembly that is signed by the originator to mark it as the one and only assembly to use to get the Type information. It's used to avoid conflicting Types. The assembly is signed in a particular way using the tlbimp.exe and then used by the client to resolve Types. http://msdn.microsoft.com/en-us/library/aa302338.aspx What have they got to do with COM? So implementations and Types available through COM is not accessible itself through .NET itself in the usual manner i.e. you cannot new up objects etc because you do not know the Type names. To get over this the COM Types are wrapped into an Interop ...