我如何对弱命名的 COM 可见进行单元测试 类

How can I unit-test weakly named COM visible classes

我在 C# 中有一个 COM visible class(标记为 [ComVisible(true)] 并在 RegAsm 中注册),我想对其进行单元测试。
我的程序集是一个名为 unsigned/weakly 的 dll(它必须保留这个)。我要测试的 class 有一个 COM 不可见的 private 成员。 我的问题是,当我想在测试中实例化此 class 时,它失败并显示以下消息:

Test method %MyTestMethod% threw exception System.EnterpriesServices.RegistreationException: The assembly %MyAssembly% does not have a strong name.

那么如何在 unsigned/weakly 命名的 dll 上使用单元测试框架?

using System.EnterpriseServices;
using System.Runtime.InteropServices;

[ComVisible( true )]
public class MyComClass: ServicedComponent, IMyClass
{
    //SomeAttribute

    private MyNonComClass nonCom;

    public MyComClass( MyNonComClass _nonCom )
    {
        this.nonCom = _nonCom;
    }
}

正如 Hans Passant 在我从继承中删除 ServicedComponent class 时所建议的那样,单元测试是 运行 所设想的。