I can create COM object locally
var infsrv = new InfoServ.TInfoServerClass(); //COM object
infsrv.RunBsScript(bssScriptName, strOfParam); //calling method
But I needed to create COM object on server, so code is:
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);
but now it says:
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.
what should I do?