Unit test can not load COM class


I have a .net 4 application that references a COM dll. It works fine using an app.manifest with GUIDs.

However, when I try to execute a unit test, the executable is QTAgent32.exe and I don't know how to allow it to load the COM class: System.Runtime.InteropServices.COMException: Retrieving the COM class factory for component with CLSID {81273702-956F-4CBD-9B16-43790558EE29} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).

Can I use a manifest for QTAgent32?

asked on Stack Overflow Aug 2, 2011 by rgargente • edited Aug 3, 2011 by rgargente

2 Answers


I would recommend just making the ServicedComponent (the COM+ class) a this wrapper for the class actually performing the logic, and then perform the unit test on this class.

If your class is dependent on an external runtime environment, it is not generally possible to unit test it. A unit test should not depend on any external environment, be it IIS, file system, database, COM+, etc. Imho.


For a Unit Test - that uses external resources ie Database - to deploy successfully, you will have to define the TestCategory of Integration as below


answered on Stack Overflow Nov 12, 2019 by manibest

User contributions licensed under CC BY-SA 3.0