【问题标题】:Problems with NotFound errors and compilation failuresNotFound 错误和编译失败的问题
【发布时间】:2011-02-15 10:19:40
【问题描述】:

使用 WCF 服务(由 Silverlight 使用)时,我们经常会遇到错误,而这些错误并没有给我们太多帮助:

由于编译期间出现异常,无法激活服务“/ourservice.svc”。 异常消息是:对象引用未设置为对象的实例.. ---> System.NullReferenceException:对象引用未设置为对象的实例。 在 System.Web.Compilation.DiskBuildResultCache.CacheBuildResult(字符串 cacheKey,BuildResult 结果,Int64 hashCode,DateTime utcStart) 在 System.Web.Compilation.BuildManager.CacheBuildResultInternal(字符串 cacheKey,BuildResult 结果,Int64 hashCode,DateTime utcStart) 在 System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) 在 System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath,布尔 noBuild,布尔 allowCrossApp,布尔 allowBuildInPrecompile) 在 System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext 上下文,VirtualPath virtualPath,布尔 noBuild,布尔 allowCrossApp,布尔 allowBuildInPrecompile)

每当我通过浏览器或使用 silverlight 客户端使用该服务时,该服务都能正常编译/运行。系统的 Silverlight 端报告这个同样无用的错误:

System.ServiceModel.CommunicationException: 
[HttpWebRequest_WebException_RemoteServer]Arguments: NotFound

我设法找到的唯一线索可能是更改instancing behaviour,但我不确定我们为什么需要这样做,而且我也无法确定默认值是什么。

  • 它托管在 Windows 2008 SP1 上
  • 服务器位于负载平衡器后面
  • web.config 中服务的超时时间为 5 分钟
  • 最大对象大小为 50000000
  • 服务有AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)

任何建议都会很棒

更新

这是另一个症状 - Silverlight 客户端经常将此异常发送到我们的日志记录服务(写入事件日志 + 电子邮件)

There was an error saving the report - The error object contained errors
System.ServiceModel.CommunicationException: [HttpWebRequest_WebException_RemoteServer]
Arguments: NotFound
Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version=4.0.60129.0&File=System.Windows.dll&Key=HttpWebRequest_WebException_RemoteServer ---> System.Net.WebException: [HttpWebRequest_WebException_RemoteServer]
Arguments: NotFound
Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version=4.0.60129.0&File=System.Windows.dll&Key=HttpWebRequest_WebException_RemoteServer ---> System.Net.WebException: [HttpWebRequest_WebException_RemoteServer]
Arguments: NotFound
Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version=4.0.60129.0&File=System.Windows.dll&Key=HttpWebRequest_WebException_RemoteServer
   at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
   at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClass5.<EndGetResponse>b__4(Object sendState)
   at System.Net.Browser.AsyncHelper.<>c__DisplayClass4.<BeginOnUI>b__1(Object sendState)
   --- End of inner exception stack trace ---
   at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
   at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
   at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result)
   --- End of inner exception stack trace ---
   at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)
   at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
   at System.ServiceModel.ClientBase`1.ChannelBase`1.EndInvoke(String methodName, Object[] args, IAsyncResult result)
   at MyNamespaceSilverlight.Core.ReportServiceReference.ReportServiceClient.ReportServiceClientChannel.EndUpdateReport(IAsyncResult result)
   at MyNamespaceSilverlight.Core.ReportServiceReference.ReportServiceClient.MyNamespaceSilverlight.Core.ReportServiceReference.IReportService.EndUpdateReport(IAsyncResult result)
   at MyNamespaceSilverlight.Core.ReportServiceReference.ReportServiceClient.OnEndUpdateReport(IAsyncResult result)
   at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result)

【问题讨论】:

  • 这是完整的堆栈跟踪吗?感觉很短。

标签: wcf


【解决方案1】:

服务中是否有任何东西在修改 \bin 目录的内容?在 ASP.NET 下托管时,ASP.NET 运行时将监视 \bin 目录是否有任何更改,当看到更改时,它将尝试重新初始化应用程序,以便它获取可能发生的任何更改。

作为服务正常操作的一部分,您不应将任何内容写入 \bin 目录。通常这是日志文件被配置为写入 \bin 目录而不是它们自己的特定目录的问题。如果由于某种原因无法将日志文件写入应用程序目录根目录之外的某个位置,只需将它们写入 \logs 子目录并配置 ASP.NET 以阻止对该目录的所有访问,如下所示:

<location path="logs">
    <system.web>
        <authorization>
            <deny users="*" />
        </authorization>
    </system.web>
</location>

【讨论】:

  • 它也不必只是日志文件,它可以是 \bin 文件夹中 .dll 的任何配置文件
  • 是的,当日志记录写入 bin 目录中的 Log 文件夹时,我发现这是一个问题。
  • @JoelC 确实如此。对我来说,当我在更改 Web.config 文件后立即尝试访问我的服务时,就会出现问题。保存文件和将其复制到 bin 目录之间似乎有一点延迟。
【解决方案2】:

这里报告了一个类似的问题:Service activation problem 这似乎与日志文件有关。

【讨论】:

    【解决方案3】:

    看起来像 System.Web 中的错误。这里报告了同样的问题:http://connect.microsoft.com/VisualStudio/feedback/details/550511/nullreferenceexception-during-service-compilation

    陪审团仍未出局,但我认为如果您在http://connect.microsoft.com 上发布您的详细信息,则更有可能解决此问题。

    【讨论】:

    • 链接目前不可用
    【解决方案4】:

    我们在测试 WCF 服务期间收到了类似的错误,当时其中一位开发人员开始部署新版本的服务。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-12-02
      • 2017-10-17
      • 2016-05-24
      • 2020-02-02
      • 1970-01-01
      • 1970-01-01
      • 2015-09-13
      • 1970-01-01
      相关资源
      最近更新 更多