title: How to call methods from COM object (cannot cast System.__ComObject to my COM class)
body: <p>I can create COM object locally</p>
  
  <pre><code>var infsrv = new InfoServ.TInfoServerClass(); //COM object
  infsrv.RunBsScript(bssScriptName, strOfParam); //calling method
  </code></pre>
  
  <p>But I needed to create COM object on server, so code is:</p>
  
  <pre><code>var myGuid = new Guid("00C4261D-0B2B-4230-A2CA-A9F4F2A46452");
  var myType = Type.GetTypeFromCLSID(myGuid, servername);
  InfoServ.TInfoServerClass infsrv = (InfoServ.TInfoServerClass)Activator.CreateInstance(myType);
  infsrv.RunBsScript(bssScriptName, strOfParam);
  </code></pre>
  
  <p>but now it says:</p>
  
  <blockquote>
    <p>Unable to cast COM object of type 'System.__ComObject' to class type
    'InfoServ.TInfoServerClass'. COM components that enter the CLR and do
    not support IProvideClassInfo or that do not have any interop assembly
    registered will be wrapped in the __ComObject type. Instances of this
    type cannot be cast to any other class; however they can be cast to
    interfaces as long as the underlying COM component supports
    QueryInterface calls for the IID of the interface.</p>
  </blockquote>
  
  <p>what should I do?</p>