当我创建一个用户并为他们分配一个角色时,我正在编写一个测试,然后检查以确保正确地分配了该角色。我能够创建用户,分配角色,将用户加载到HttpContext.Current中,并持久化用户。但是,当我检查角色是否已正确分配时,我得到以下错误。
An exception of type 'System.TypeLoadException' occurred in System.Web.dll but was not handled in user code
Additional information: Could not load type 'MyProject.Repositories.RQRole' from assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.我找遍了,没有MyProject.exe,但有一个MyProject调试数据库。MyProject.dll就在那里,引用它的其他测试可以很好地完成它。
这是抛出错误的那一行。
Assert.IsTrue(System.Web.Security.Roles.IsUserInRole("user"));发布于 2014-09-06 03:37:30
http://forums.asp.net/t/1270044.aspx?Unit+Testing+the+Role+and+Membership+Providers
我指定了dll的具体名称,它工作得很好。
https://stackoverflow.com/questions/25691625
复制相似问题