Tech Off Post

Single Post Permalink

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

    pompomJuice said:
    Dexter said:

    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.



    I should have been more explicit about proxy/marshaling. Marshaling is something you don't need to be concerned about in .NET  because the runtime will do that automatically. What the Dr. Dobb's article says only applies to the unmanaged world.

    Of course, that brings the question why this doesn't work if it's done automatically. That's because this marshaling requires that the component (or more exactly the interface) has a registered proxy. So your component is either not registered correctly or it doesn't have a proxy at all.

    As for the RCW error: I've never seen that before. Could you post a stack trace or at least the exact line that causes that?

    PS: you still need to figure out if your COM object is apartment threaded or free threaded Smiley