“无法加载App_Web _ * dll”ASP.NET编译和回收后的异常

“无法加载App_Web _ * dll”ASP.NET编译和回收后的异常,第1张

概述我最近遇到了以下结构的代码: > FooService.cs > FooService.svc > Default.aspx 文件内容: [FooService.cs] using System.ServiceModel;namespace FooService{ [ServiceContract] public class FooService { 我最近遇到了以下结构的代码:

> FooService.cs
> FooService.svc
> Default.aspx

文件内容:

[FooService.cs]

using System.ServiceModel;namespace FooService{    [ServiceContract]    public class FooService    {        static FooEngine engine = new FooEngine();        [OperationContract]        public string Foo()        {            return "bar";        }    }    public class FooEngine    {    }}

[FooService.svc]

<%@ ServiceHost Language="C#" Service="FooService.FooService" %>

[Default.aspx的]

<%@ Page Language="C#" %><% var foo = "bar"; %>

我们在windows Server 2003上使用.Net 4.0(DeBUG)和IIS6,使用’fooservice’Web和主机文件条目,通过http://fooservice/FooService.svc和default.aspx通过http://fooservice/调用Web服务。此时一切正常。

但是,按照以下步骤,

>在default.aspx中更改代码,保存文件
>加载http://fooservice/(触发ASP.NET编译)
>回收应用程序池

对http://fooservice/FooService.svc的调用失败,并引发以下异常

[fileNotFoundException: Could not load file or assembly 'App_Web_ynlv0b1k,Version=0.0.0.0,Culture=neutral,PublicKeyToken=null' or one of its dependencIEs. The system cannot find the file specifIEd.]   System.Reflection.RuntimeAssembly._nLoad(Assemblyname filename,String codeBase,EvIDence assemblySecurity,RuntimeAssembly locationHint,StackCrawlMark& stackMark,Boolean throwOnfileNotFound,Boolean forIntrospection,Boolean suppressSecurityChecks) +0   System.Reflection.RuntimeAssembly.nLoad(Assemblyname filename,Boolean suppressSecurityChecks) +39   System.Reflection.RuntimeAssembly.InternalLoadAssemblyname(Assemblyname assemblyRef,Boolean suppressSecurityChecks) +132   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString,Boolean forIntrospection) +144   System.Reflection.Assembly.Load(String assemblyString) +28   System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString,Uri[] baseAddresses) +208   System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath) +1440   System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +44   System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +615[ServiceActivationException: The service '/FooService.svc' cannot be activated due to an exception during compilation.  The exception message is: Could not load file or assembly 'App_Web_ynlv0b1k,PublicKeyToken=null' or one of its dependencIEs. The system cannot find the file specifIEd..]   System.Runtime.AsyncResult.End(IAsyncResult result) +679246   System.ServiceModel.Activation.HostedhttpRequestAsyncResult.End(IAsyncResult result) +190   System.ServiceModel.Activation.HostedhttpRequestAsyncResult.ExecuteSynchronous(httpApplication context,String routeServiceVirtualPath,Boolean flowContext,Boolean ensureWFService) +234   System.ServiceModel.Activation.httpModule.ProcessRequest(Object sender,EventArgs e) +355   System.Web.SyncEventExecutionStep.System.Web.httpApplication.IExecutionStep.Execute() +148   System.Web.httpApplication.ExecuteStep(IExecutionStep step,Boolean& completedSynchronously) +75

这里究竟发生了什么?

备注

>我明白ASP.NET正在编译和加载一个新的App_Web _ *。dll(在第2步),但为什么它试图加载旧的(已删除)App_Web _ *。dll在循环(3.)之后?
>在FooService.svc中使用完全相同的代码,而不是单独的FooService.cs没有这个问题(?)
删除对FooEngine的静态引用也使得这个问题消失了(?)

解决方法 我只是有同样的问题,
该应用程序是一个Web应用程序,完全预编译。
这固定它为我,但我不知道为什么:
<compilation deBUG="false" batch="false">

我从这里得到这个解决方案:http://web.archive.org/web/20140116171941/http://www.creative-jar.com/insights/labs/programming/could-not-load-file-or-assembly-app_web_/

总结

以上是内存溢出为你收集整理的“无法加载App_Web _ * dll”ASP.NET编译和回收后的异常全部内容,希望文章能够帮你解决“无法加载App_Web _ * dll”ASP.NET编译和回收后的异常所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1114359.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-29
下一篇2022-05-29

发表评论

登录后才能评论

评论列表(0条)

    保存