VS2010和ASP.NET单元测试的问题/ WebHostAdapter例外 [英] VS2010 and ASP.NET unit test problems / WebHostAdapter exception

查看:753
本文介绍了VS2010和ASP.NET单元测试的问题/ WebHostAdapter例外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我花了半天的时间试图获得一个ASP.NET单元测试来作为<一个工作描述href=\"http://www.gangleri.net/2007/12/29/UnitTestingASPNetApplicationsWithVisualStudio2008.aspx\">Alan's开发博客。我没有VS2008,但VS2010 SP1的和ReSharper的5.1,并且不管我试试我正好碰上不同类型的错误。

I've spent half a day trying to get an ASP.NET unit test to work as described in Alan's Development Blog. I don't have VS2008 but VS2010 with SP1 and Resharper 5.1, and no matter what I try I just run into different kinds of errors.

当我添加一个测试项目与测试方法如下,并指定.NET 4为目标框架,我碰上例外

When I add a test project with a test method as follows and specify .NET 4 as target framework, I run into exception

更新,以显示有关异常的更多详细信息

在运行测试TestMethod1该网站无法正确配置的测试适配器'WebHostAdpater抛出一个异常;获取ASP.NET进程信息失败请求的http://本地主机:49676 / VSEnterpriseHelper.axd'返回了一个错误:远程服务器返回错误:(500)内部服务器错误......

[TestMethod]
[HostType( "ASP.NET" )]
[UrlToTest( "http://localhost:49676/Default.aspx" )]
[AspNetDevelopmentServerHost( @"C:\...\Projects\ProjectX\ProjectX\", "/Default.aspx") ]
public void TestMethod1()
{

}

我已经完成了互联网上关于此错误信息众多的搜索,但从来没有真正找到了解决办法 - 我尝试添加一个部分,因此所有用户都将被允许进入这也是在错误消息中提到VSEnterpriseHelper.axd ,但它并没有帮助。

I've performed numerous searches on the internet regarding this error message, but never really found a solution - I tried adding a section so all users would be allowed access to "VSEnterpriseHelper.axd" which is also mentioned in the error message, but it didn't help.

尝试设置测试项目的目标框架.NET 3.5也于事无补,并返回相同的错误。

Trying to set the test project's target framework to .NET 3.5 also doesn't help and returns the same error.

虽然使用不同的设置玩弄我也正好得到大会Microsoft.VisualStudio.QualityTools.CommandLine无法加载错误消息,即使我添加了正确的版本(用正确的公钥标记)作为参考。

While playing around with different settings I also happened to get the error message that the assembly "Microsoft.VisualStudio.QualityTools.CommandLine" couldn't be loaded, even though I added the correct version (with the correct public key token) as reference.

也许事情(ReSharper的,.NET目标框架,...)相结合食堂的事情了,但我也尝试禁用ReSharper的单元测试,这样的MSTest将用于,可惜没有效果。

Maybe the combination of things (ReSharper, .NET target framework, ...) messes things up, but I also tried disabling the ReSharper unit testing so that MSTest would be used, unfortunately to no avail.

在艾伦的博客文章的描述似乎是相当简单,但它并不想为我工作。

The description in Alan's blog post seems to be quite straightforward, but it doesn't want to work for me.

更新2

我也试图逃避艾伦在VS2008页面示例项目,但错误还是一样VS2010 SP1。

I also tried to run the example projects from Alan's page in VS2008, but the error is still the same as in VS2010 SP1.

更新3

仍然没有运气,但我已经添加的文件的),以在web.config作为的 ConfigurationErrorException 的Windows事件日志指出,该文件未找到:

Still no luck, but I've added the file Microsoft.VisualStudio.Enterprise.AspNetHelper.dll (located in %PROGRAMFILES%\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies) to the web.config as a ConfigurationErrorException in the Windows Event Log indicated that this file was not found:

<dependentAssembly xmlns="urn:schemas-microsoft-com:asm.v1">
    <assemblyIdentityVersion name="Microsoft.VisualStudio.Enterprise.AspNetHelper" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <codeBase version="10.0.0.0" href="file:///C:/Program%20Files%20(x86)/Microsoft%20Visual%20Studio%2010.0/Common7/IDE/PrivateAssemblies/Microsoft.VisualStudio.Enterprise.AspNetHelper.dll" />
</dependentAssembly>

这固定的AspNetHelper.dll这个问题,但我得到了的 AspNetAdatpter 的相同的错误消息,但以同样的方式修改web.config中的错误仍然存​​在不工作。在Visual Studio中我还可以看到,(当我尝试添加一个处理程序入口如下图所示)中的 QualityTools.HostAdapters.ASPNETAdapter 的部分显示为红色,表明在工具提示无法解析符号'QualityTools '

This fixed the problem with the AspNetHelper.dll, but I get the same error message for the AspNetAdatpter, but amending the web.config in the same way doesn't work as the error persists. Within Visual Studio I can also see that (when I try to add a handler entry as shown below) the QualityTools.HostAdapters.ASPNETAdapter part is shown in red, indicating in a tooltip "Cannot resolve symbol 'QualityTools'":

<add name="HostAdapter" verb="GET" path="ASPNETAdapter" type="Microsoft.VisualStudio.QualityTools.HostAdapters.ASPNETAdapter, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

这是所有大的混乱,似乎我已经完全失去了轨道,为什么它似乎是不可能的内VS2010运行ASP.NET单元测试?有没有其他人谁拥有了同样的问题(或者,问的问题不同,有没有谁可以运行在VS2010 ASP.NET单元测试没有问题的人)?

This is all a big mess, and it seems I've completely lost track, why does it seem to be impossible to run ASP.NET unit tests within VS2010? Is there nobody else who's got the same kind of problems (or, ask the question differently, is there anybody who can run ASP.NET unit test in VS2010 without problems)?

仍在试图把事情的工作......

Still trying to get things working...

更新4

仍然没有运气,我是唯一一个?谁可以运行这样的测试?

Still no luck, am I the only one? Who can run such tests?

更新结束

任何想法,我做错了什么?预先感谢任何指针到正确的方向。

Any ideas what I'm doing wrong here? Thanks in advance for any pointers into the right direction

-G。

推荐答案

我有,而不是集成了类似的问题,我已经发现迄今在改变应用程序池经典的唯一解决方案。

I have a similar problem and the only solution I've found so far is changing the application pool to classic, instead of integrated.

这篇关于VS2010和ASP.NET单元测试的问题/ WebHostAdapter例外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆