我们经常使用WCF服务(由Silverlight使用)获得错误,这些服务不会让我们继续下去:
The service '/ourservice.svc' cannot be activated due to an exception during compilation. The exception message is: Object reference not set to an instance of an object.. ---> System.NullReferenceException: Object reference not set to an instance of an object. at System.Web.Compilation.DiskBuildResultCache.CacheBuildResult(String cacheKey, BuildResult result, Int64 hashCode, DateTime utcStart) at System.Web.Compilation.BuildManager.CacheBuildResultInternal(String cacheKey, BuildResult result, Int64 hashCode, DateTime utcStart) at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
每当我通过浏览器或使用silverlight客户端使用它时,服务编译/运行正常。系统的Silverlight端报告了同样无用的错误:
System.ServiceModel.CommunicationException:
[HttpWebRequest_WebException_RemoteServer]Arguments: NotFound
我设法找到的唯一线索可能正在改变instancing behaviour,但我不确定为什么我们需要这样做,而且我不知道默认是什么。
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)
答案 0 :(得分:9)
服务中是否有任何内容修改\ bin目录的内容?在ASP.NET下托管时,ASP.NET运行时将监视\ bin目录中的任何更改,当看到更改时,它将尝试重新初始化应用程序,以便它可以获取可能已发生的任何更改。
作为服务正常操作的一部分,您不应该在\ bin目录中写任何内容。通常,这是将日志文件配置为写入\ bin目录而不是自己的特定目录的问题。如果由于某种原因无法在应用程序目录的根目录之外的某个位置写入日志文件,只需将它们写入\ logs子目录并配置ASP.NET以阻止对该目录的所有访问,如下所示:
<location path="logs">
<system.web>
<authorization>
<deny users="*" />
</authorization>
</system.web>
</location>
答案 1 :(得分:1)
此处报告了类似的问题:Service activation problem似乎与日志文件有关。
答案 2 :(得分:1)
看起来像System.Web中的错误。这里报告了同样的问题:http://connect.microsoft.com/VisualStudio/feedback/details/550511/nullreferenceexception-during-service-compilation。
陪审团仍未解决,但如果您在http://connect.microsoft.com上发布详细信息,我认为您有更好的机会解决此问题。
答案 3 :(得分:1)
在测试WCF服务期间,当其中一位开发人员开始部署新版本的服务时,我们收到了类似的错误。