title: Load a .NET assembly from a COM ProgID without creating a COM object
body: <p>A bit of an odd question and probably backwards from what most people want to do, but I'm trying to work around a legacy COM issue.</p>
  
  <p>I have two components, both of which are actually .NET assemblies, but for historical reasons one is loading the other as a COM object (the assembly is registered for COM Interop). It's a plug-in architecture where the plug-in is identified by its COM ProgID, so that's the only piece of information I get to load the plug-in assembly.</p>
  
  <p>One technique I've tried is:  </p>
  
  <pre><code>var objType = Type.GetTypeFromProgID("My.ProgId");
  var objLateBound = Activator.CreateInstance(objType);
  IMyInterface netAssembly;
  try
      {
      netAssembly = (IMyAssembly)objLateBound;
      }
  catch (Exception)
      {
      netAssembly = null;
      }
  </code></pre>
  
  <p>If the cast to a .NET interface succeeds, the I know I have a .NET assembly and can access it through the interface. However, the technique is a bit clumsy and I'm getting problems with the COM side of things especially on 64-bit systems. I'd rather just eliminate loading the COM object and load the plug-in directly as a .NET assembly, if possible.</p>
  
  <p>But the only piece of information I've got to go on is the plug-in's COM ProgID.</p>
  
  <p>So, how can I go from a COM ProgID to loading a .NET Assembly, <em>without creating any COM objects</em>?</p>