我正在尝试使用VS2010中的MSTest测试我的自定义成员资格提供程序,但不断收到错误System.TypeLoadException: Could not load type 'TafAdris.Security.TafAdrisMembershipProvider' from assembly 'TafAdrisSecurity'.
经过大量的努力,我意识到即使我在References文件夹中指定了Copy Local,MSTest也找不到我的程序集。接下来我尝试调试单元测试,在Watch窗口中输入Environment.CurrentDirectory。我得到以下文件夹:
C:\Users\XYZ\Documents\Visual Studio 2010\Projects\CustomSecurityProviderApp\TestResults\XYZ_PCNAME 2011-10-11 18_24_55\Out
但Test项目输出文件夹是在完全不同的位置指定的。有没有人有类似的问题?你知道如何强制MSTest从特定位置加载DLL吗?
我尝试在“测试设置”中指定其他文件夹 - >单元测试但似乎被忽略了。
答案 0 :(得分:0)
[AssemblyInitialize]
public static void AssemblyInit(TestContext context)
{
System.Environment.CurrentDirectory = @"C:\Users\username\Documents\Visual Studio 2010\Projects\CustomSecurityProviderApp\CustomMembership.Test\bin\Debug";
}
这导致测试在我的自定义成员资格所在的指定目录中运行。