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

我最近遇到了以下结构的代码: @H_403_2@> FooService.cs
> FooService.svc
> Default.aspx@H_502_5@ @H_403_2@文件内容:@H_502_5@ @H_403_2@[FooService.cs]@H_502_5@
using System.ServiceModel;

namespace FooService
{
    [ServiceContract]
    public class FooService
    {
        static FooEngine engine = new FooEngine();

        [OperationContract]
        public string Foo()
        {
            return "bar";
        }
    }

    public class FooEngine
    {

    }
}
@H_403_2@[FooService.svc]@H_502_5@
<%@ ServiceHost Language="C#" Service="FooService.FooService" %>
@H_403_2@[Default.aspx的]@H_502_5@
<%@ Page Language="C#" %>
<% var foo = "bar"; %>
@H_403_2@我们在Windows Server 2003上使用.Net 4.0(Debug)和IIS6,使用’fooservice’Web和主机文件条目,通过http://fooservice/FooService.svc和default.aspx通过http://fooservice/调用Web服务。此时一切正常。@H_502_5@ @H_403_2@但是,按照以下步骤,@H_502_5@ @H_403_2@>在default.aspx中更改代码,保存文件
>加载http://fooservice/(触发ASP.NET编译)
>回收应用程序池@H_502_5@ @H_403_2@对http://fooservice/FooService.svc调用失败,并引发以下异常@H_502_5@
[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
@H_403_2@这里究竟发生了什么?@H_502_5@ @H_403_2@备注@H_502_5@ @H_403_2@>我明白ASP.NET正在编译和加载一个新的App_Web _ *。dll(在第2步),但为什么它试图加载旧的(已删除)App_Web _ *。dll在循环(3.)之后?
>在FooService.svc中使用完全相同的代码,而不是单独的FooService.cs没有这个问题(?)
删除对FooEngine的静态引用也使得这个问题消失了(?)@H_502_5@
@H_404_41@解决方法
我只是有同样的问题,
该应用程序是一个Web应用程序,完全预编译。
这固定它为我,但我不知道为什么:
<compilation debug="false" batch="false">
@H_403_2@我从这里得到这个解决方案:http://web.archive.org/web/20140116171941/http://www.creative-jar.com/insights/labs/programming/could-not-load-file-or-assembly-app_web_/@H_502_5@

相关文章

操作步骤 1、进入elasticsearch的plugin,进入ik。进入config。 2、在config下面建立以.dic为后缀的字典...
lengend data数据中若存在&#39;&#39;,则表示换行,用&#39;&#39;切割。
代码实现 option = { backgroundColor: &amp;#39;#080b30&amp;#39;, tooltip: { trigger: &...
问题原因 原因在于直接在js中取的变量并复制给var变量。 于是就变成这样。 解决办法 var data = &#...
前言 最近做了一个调查问卷导出的功能,需求是将维护的题目,答案,导出成word,参考了几种方案之后,选...
对于很多人来说,用字符编码都是熟能生巧,而不清楚为什么是那样的字符编码,所以我在这列了一个表,翻...