Tech Off Post

Single Post Permalink

View Thread: WPF + WindowsFormsHost + .Net Forms + ( COM interfaces + Forms Invoke ) = E_NOINTERFACE Exception
  • User profile image

    Dexter said:
    pompomJuice said:
    On Windows CE it probably works because the "CE" COM does not implement synchronization, all COM objects are free threaded (the client code has the reponsability to synchronize access to a COM object).

    Now I'm not sure why that object doesn't have a proxy registered. One possibility is that it is actually a free threaded COM object and it doesn't have a proxy because that's not needed (I assume it's only used as an inproc server). However, if the object is created on the main UI thread it will be subject to apartment threading rules.

    You'll have to figure out what threading model the COM object supports (see its registration key in HKCR\CLSID\{guid}\InProcServer32). If it's indeed free threaded you could try to create the object on a different thread than the main UI thread.

    Thanks Dexter.

    Firstly, on a by note, anyone that uses Chrome with channel9, DONT it "aw snaps" when you copy and paste to it. I think I have lost about 5 posts like this, 3 of them the main post. I almost threw my laptop out of the window. I am back on exploder for now Wink How many times do I have to realize that you only use Microsoft with Microsoft? Anything else is folly. ( I come from Linux, forced to convert to Microsoft recently because of all the hype Microsoft creates around their stuff. MS is bullying Linux IMO and must stop it because my boss is  influenced by snazzy Microsoft posters, not actually working operating systems; In the end I sit with the mess)

    Ok so I hear you on the CE. Makes sense. I have done more reading on Marshalling and COM and came across this interesting article which you dont need to read, but maybe for someone else that knows as little as me.

    I like that article. This makes me feel better because I was debugging till early morning hours as he states discovering multithreading issues. I felt like a chop.

    Ok so Dobbs showed me that Marshalling is just crazy and I opted to go with your initial advice to inspect those "else" code blocks more carefully. You said maybe I can take out those COM calls. Indeed!!! You were right. I removed the invokes completely and just tediously invoked every little UI change inside of that "else" code block. SUCCESS!!! Thanks.

    Ok but now further down the line I just hit another Exception. Sigh, COM object that has been separated from its underlying RCW cannot be used.

    I have not yet investigated it, first I go to the gym to pump out some frustrations then I come back for round two. So far all I have figured out is that RCW stands for Runtime Callable Wrapper. Quick random spamming of STAThread and MTAThread has show me that this error actually responds to those modes. the MTAThread give that same interface cast exception above, but STAThread now gives the RCW disappearing error.

    Any quick tips will be greatly appreciated. So far you have helped a lot.