How to instantiate a ServicedComponent in a unit test process?

[ClassInterface(ClassInterfaceType.None)]
[Guid("12C969B3-330D-4230-ACDA-F9BED3286B1E")]
[ProgId("Lib.Class")]
public class MyService : ServicedComponent, IMyService
{
      ...
}

Unit Test:

MyService target = new MyService ();

This code creates a TransparentProxy object, how the component should work in production.

How can I create an instance of the in-process and local class, such as that I can nest its dependencies?

+3
source share
1 answer

I don't like this, but you can use conditional compilation, Debug / Release, or I use DebugComPlus / Debug / Release (where only Debug is not a ServicedComponent). Note that you must implement IDisposable in Debug mode, because you will have to call Dispose on ServicedComponent for the real code, and the Dispose method will not be if it is not ServicedComponent.

COM +, , , COM + , , COM+. , , , - . COM + .

+1

Source: https://habr.com/ru/post/1723272/


All Articles