c# - InvalidCastException, QueryInterface call failing on COM component -


First of all, I'm totally new to the COM view so that I'm bare with me.

I am currently trying to use the PCAnywhere's wet automation in a pure application (VS 2010, C #). PCA 12.5 comes with some TLB files, when I use VS I try to add as a reference, then I could not add 'a reference to both' E: \ Dev \ PCole \ Erem 32.tlb '. Please make sure the file is accessible, and it is a valid assembly or COM component. ', So what I did is generate an interop assembly using tlbimp.exe and managed to import the created DLL as no problem in the references. Fine. Even I have the code so far:

  Thread Piketi = new Thread (delegate () {CRemoteDataManagerClass Mng = new Kromotdetamanegrclas (); Rimotdetaaks class data = null; data = ( Rimotdetaaksclas) Manji. data (data == nULL) data = (Rimotdetaaksclas) MngkCreateObjectEx ( "Tempkchf"); data. connection type = "TCP / IP"; retrieving data ObjectEx ( "temp.chf", ( Brief) 2, blank); .phoneNumber = host.IP; data. Atologinname = Mejbanknmber. Starts ( "WS")? "Yuesarvksavisi": "Admnad" "data. Otoodman =" Dome "+ real. Anamsikpad-Left (4, '0'); Data.WriteProtection = false; data. WriteObject (null); AWREM32.DocumentDoc = new AWREM32.Document ();}); pcat.SetApartmentState (ApartmentState.STA); pcat.Start (); pcat.Join ();  
< p> CRemoteDataManagerClass, RemoteDataExClass, and class within AWREM32.Document assemblies.

so I get exceptions on 5th row ( data = (RemoteDataExClass) is, Mng.RetrieveObjectEx ( "temp.chf ", (Abridged 2, blank); ), which says the following:

type unable to remove the COM object 'winawsvr.CRemoteDataManagerClass' interface type' winawsvr.iremoteDataManager 'the IOD' {82A1A806-8BA9- 11CF-B95F-00A02412C812} 'Interface is not compatible (exception from HRESULT: 0x80004002 (E_NOINTERFACE)) The QueryInterface call failed on the COM component for interface with IAP.

What am I missing here? Maybe the way COM components are registered? Before I even tried to register them with regasm.exe, there were only LocalServer32 keys within CLSID. After I have run regasm.exe, it has made two, believe me: InprocHandler32 and InprocServer32 I got the same exception before and after.

I have read somewhere that I need to run the calling code within the STA apartment state within the thread set. So i did There was no change yet.

One of the things I noticed was that when I ran ildasm.exe against the Interal Assembly where the failed class is located, I can see within the IRModdanAnnet: .custom instance void [mscorlib] System .Runtime.InteropServices.GuidAttribute ::. Ctor (string) = (01 00 24 38 32 41 31 41 38 30 36 2 D 38 42 41 39 // $ 82 AA A 806-8BA 9 ... .IMMOTDataManager GUID near TLB 82A1A806-8BA 9-11 CF-B95F-00A2424C812 , which is the same GUID outlined in the exception. The first two sections of this GUID are written by I ildasm (I that the rest of the display is only out for performance issues), so also goes well.

I use is CRemoteDataManager (which interfaces instead CRemoteDataManagerClass applicable IRemoteDataManager) Have tried In such cases, the exception always mentions of the CRemoteDataManagerClass as well. In Igrasm, CremoteDataManagerClass applies both crem to OteDataManager and IRemoteDataManager. The QueryInterface may fail on one of two, or something else

I do not know. I am clearly all over here.

I have also seen why the query interface is actually failing, but I see it mixing, take Qin I have found that how to do all on .netcompactframework.

I think that

  data = (RemoteDataXClass) MNG .RetrieveObjectEx ("temp.chf", (short) 2, tap); There can be a problem (RemoteDataExClass) in  

I believe before trying to put MNG in my own type. Recover ObjectX is called. This can give you an error. The second option may be that one of the class objects does not like the new operator. I have seen in different situations, where these libraries offer new operators, who give errors, but there are other classes also with the formation of another type of ceremony. Using those people, you can get a class created.


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -