locked
COM and Prism 4 RRS feed

  • Question

  • Hi,

    I'm refactoring an old application into a Prism/WPF app and the application uses some COM objects to access certain data. I've created a reference to my COM library and I've been able to write the code that accesses the COM types I need from that library. The code compiles fine and it runs fine within a unit test. But when I run my application, it fails at runtime with this error:

    Retrieving the COM class factory for component with CLSID {...} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).

    The line of code that fails looks like this:

    ExampleComType myComType = new ExampleComType();

    Since this code works from within my unit test, I have to believe the issue lies in accessing it through Prism and the Unity container. Do I have to register the COM type with my container? If so, how would I do that since ExampleComType is technically an interface - I don't know what concrete type it would map to (I'm not very experienced with COM at all)? If not, does anyone have any other ideas of what I might need to do?

    I wasn't sure if this was the best forum for asking this question, but as my problem seems to be related to Prism I didn't see a better place to ask my question. Hopefully someone can help me because I really need to get this solved to move on. Any help would be greatly appreciated.

    Thanks, Dennis

    Thursday, February 23, 2012 3:06 PM

Answers

  • Lots of things can cause this error, like a failure in properly registering the componant.

    Are your unit tests in a separate project?

    Most common is if this componant is 32 bit unmanaged code, you won't be able to run it on a 64 bit system.

    Try going to your main project properties / build tab - change platform target to x86

    Regards,
    Pete


    #PEJL

    • Marked as answer by Dennista Thursday, February 23, 2012 4:01 PM
    Thursday, February 23, 2012 3:27 PM

All replies

  • Lots of things can cause this error, like a failure in properly registering the componant.

    Are your unit tests in a separate project?

    Most common is if this componant is 32 bit unmanaged code, you won't be able to run it on a 64 bit system.

    Try going to your main project properties / build tab - change platform target to x86

    Regards,
    Pete


    #PEJL

    • Marked as answer by Dennista Thursday, February 23, 2012 4:01 PM
    Thursday, February 23, 2012 3:27 PM
  • Thanks Pete. Changing to x86 did the trick. I had thought I had done this before, but apparently not. Thanks so much for your quick reply!

    Dennis

    Thursday, February 23, 2012 4:01 PM