【问题标题】:DivideByZeroException in Webrequest test (WP7)Webrequest 测试中的 DivideByZeroException (WP7)
【发布时间】:2012-11-04 02:18:13
【问题描述】:

我正在使用 NUnit 来测试 WP7 应用程序(Install-Package NUnit)。我用这样的测试创建了空白的 WP Class 项目:

var req = WebRequest.CreateHttp("http://google.com");

这个测试有这样的错误:

System.TypeInitializationException : 的类型初始化器 'System.Net.WebRequest' 引发了异常。 ----> System.DivideByZeroException : 试图除以零。在 System.Net.WebRequest.CreateHttp(String requestUriString) 在 Class1.cs 中的 PhoneClassLibrary1.Class1.T():第 13 行 --DivideByZeroException at System.Net.WebRequest..cctor()

如何解决?

【问题讨论】:

    标签: windows-phone-7 nunit dividebyzeroexception


    【解决方案1】:

    我用 nunit 尝试了相同的代码,没有抛出异常。 确保您获得了最新版本的 nunit 并与 silverlight 4 兼容。 你可以看看这个帖子=> NUnit with Windows Phone 7

    您正在搜索的是 nunit-silverlight。您需要引用“NUnit.Silverlight.Framework.dll”和“NUnit.Silverlight.Compatibility.dll”(SilverLight 3 版本),并将所有引用设为“本地副本”,即使是 .NET 框架。

    可能会解决您的问题:)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-02
      • 1970-01-01
      • 2012-04-09
      • 1970-01-01
      • 1970-01-01
      • 2011-07-04
      相关资源
      最近更新 更多