Не удалось загрузить тип на развернутом сайте со ссылкой на старые страницы/классы

Когда я запускаю свой код в отладчике VS и настраиваю его на перехват исключений CLR при возникновении, я получаю массу этих исключений HttpException, говорящих «Не удалось загрузить тип», которые относятся к страницам/классам, которые были удалены из приложения. Это не вызывает никаких проблем со страницами (.NET каким-то образом игнорирует это исключение), но это действительно раздражает.

Трассировки стека:

System.Web.dll!System.Web.UI.TemplateParser.GetType(string typeName, bool ignoreCase, bool throwOnError) + 0x1b0 bytes  
System.Web.dll!System.Web.UI.TemplateParser.ProcessInheritsAttribute(string baseTypeName, string codeFileBaseTypeName, string src, System.Reflection.Assembly assembly) + 0x62 bytes    
System.Web.dll!System.Web.UI.TemplateParser.PostProcessMainDirectiveAttributes(System.Collections.IDictionary parseData) + 0x118 bytes  
System.Web.dll!System.Web.UI.PageParser.PostProcessMainDirectiveAttributes(System.Collections.IDictionary parseData) + 0x6b bytes   
System.Web.dll!System.Web.UI.TemplateParser.ProcessMainDirective(System.Collections.IDictionary mainDirective) + 0x18b bytes    
System.Web.dll!System.Web.UI.TemplateControlParser.ProcessMainDirective(System.Collections.IDictionary mainDirective) + 0x90 bytes  
System.Web.dll!System.Web.UI.PageParser.ProcessMainDirective(System.Collections.IDictionary mainDirective) + 0x11 bytes 
System.Web.dll!System.Web.UI.TemplateParser.ProcessDirective(string directiveName, System.Collections.IDictionary directive) + 0x13f bytes  
System.Web.dll!System.Web.UI.BaseTemplateParser.ProcessDirective(string directiveName, System.Collections.IDictionary directive) + 0x1ea bytes  
System.Web.dll!System.Web.UI.TemplateControlParser.ProcessDirective(string directiveName, System.Collections.IDictionary directive) + 0x44 bytes    
System.Web.dll!System.Web.UI.PageParser.ProcessDirective(string directiveName, System.Collections.IDictionary directive) + 0x45 bytes   
System.Web.dll!System.Web.UI.TemplateParser.ParseStringInternal(string text, System.Text.Encoding fileEncoding) + 0x378 bytes   
System.Web.dll!System.Web.UI.TemplateParser.ParseString(string text, System.Web.VirtualPath virtualPath, System.Text.Encoding fileEncoding) + 0x6f bytes    
System.Web.dll!System.Web.UI.TemplateParser.ParseFile(string physicalPath, System.Web.VirtualPath virtualPath) + 0x115 bytes    
System.Web.dll!System.Web.UI.TemplateParser.ParseInternal() + 0x57 bytes    
System.Web.dll!System.Web.UI.TemplateParser.Parse() + 0x64 bytes    
System.Web.dll!System.Web.Compilation.BaseTemplateBuildProvider.CodeCompilerType.get() + 0x6f bytes 
System.Web.dll!System.Web.Compilation.BuildProvider.GetCompilerTypeFromBuildProvider(System.Web.Compilation.BuildProvider buildProvider) + 0x42 bytes   
System.Web.dll!System.Web.Compilation.WebDirectoryBatchCompiler.CompileNonDependentBuildProviders(System.Collections.ICollection buildProviders) + 0xca bytes   
System.Web.dll!System.Web.Compilation.WebDirectoryBatchCompiler.Process() + 0x5d bytes  
System.Web.dll!System.Web.Compilation.BuildManager.BatchCompileWebDirectoryInternal(System.Web.Hosting.VirtualDirectory vdir, bool ignoreErrors) + 0x48 bytes   
System.Web.dll!System.Web.Compilation.BuildManager.BatchCompileWebDirectory(System.Web.Hosting.VirtualDirectory vdir, System.Web.VirtualPath virtualDir, bool ignoreErrors) + 0xbc bytes    
System.Web.dll!System.Web.Compilation.BuildManager.CompileWebFile(System.Web.VirtualPath virtualPath) + 0x5d bytes  
System.Web.dll!System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(System.Web.VirtualPath virtualPath, bool noBuild, bool allowCrossApp, bool allowBuildInPrecompile, bool throwIfNotFound, bool ensureIsUpToDate) + 0x141 bytes    
System.Web.dll!System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(System.Web.HttpContext context, System.Web.VirtualPath virtualPath, bool noBuild, bool allowCrossApp, bool allowBuildInPrecompile, bool throwIfNotFound, bool ensureIsUpToDate) + 0x70 bytes 
System.Web.dll!System.Web.Compilation.BuildManager.GetVPathBuildResult(System.Web.HttpContext context, System.Web.VirtualPath virtualPath, bool noBuild, bool allowCrossApp, bool allowBuildInPrecompile, bool ensureIsUpToDate) + 0x5b bytes   
System.Web.dll!System.Web.UI.BaseTemplateParser.GetReferencedType(System.Web.VirtualPath virtualPath, bool allowNoCompile) + 0x51 bytes 
System.Web.dll!System.Web.UI.PageParser.ProcessMainDirectiveAttribute(string deviceName, string name, string value, System.Collections.IDictionary parseData) + 0x67e bytes 
System.Web.dll!System.Web.UI.TemplateParser.ProcessMainDirective(System.Collections.IDictionary mainDirective) + 0xf9 bytes 
System.Web.dll!System.Web.UI.TemplateControlParser.ProcessMainDirective(System.Collections.IDictionary mainDirective) + 0x90 bytes  
System.Web.dll!System.Web.UI.PageParser.ProcessMainDirective(System.Collections.IDictionary mainDirective) + 0x11 bytes 
System.Web.dll!System.Web.UI.TemplateParser.ProcessDirective(string directiveName, System.Collections.IDictionary directive) + 0x13f bytes  
System.Web.dll!System.Web.UI.BaseTemplateParser.ProcessDirective(string directiveName, System.Collections.IDictionary directive) + 0x1ea bytes  
System.Web.dll!System.Web.UI.TemplateControlParser.ProcessDirective(string directiveName, System.Collections.IDictionary directive) + 0x44 bytes    
System.Web.dll!System.Web.UI.PageParser.ProcessDirective(string directiveName, System.Collections.IDictionary directive) + 0x45 bytes   
System.Web.dll!System.Web.UI.TemplateParser.ParseStringInternal(string text, System.Text.Encoding fileEncoding) + 0x378 bytes   
System.Web.dll!System.Web.UI.TemplateParser.ParseString(string text, System.Web.VirtualPath virtualPath, System.Text.Encoding fileEncoding) + 0x6f bytes    
System.Web.dll!System.Web.UI.TemplateParser.ParseFile(string physicalPath, System.Web.VirtualPath virtualPath) + 0x115 bytes    
System.Web.dll!System.Web.UI.TemplateParser.ParseInternal() + 0x57 bytes    
System.Web.dll!System.Web.UI.TemplateParser.Parse() + 0x64 bytes    
System.Web.dll!System.Web.Compilation.BaseTemplateBuildProvider.CodeCompilerType.get() + 0x6f bytes 
System.Web.dll!System.Web.Compilation.BuildProvider.GetCompilerTypeFromBuildProvider(System.Web.Compilation.BuildProvider buildProvider) + 0x42 bytes   
System.Web.dll!System.Web.Compilation.WebDirectoryBatchCompiler.CompileNonDependentBuildProviders(System.Collections.ICollection buildProviders) + 0xca bytes   
System.Web.dll!System.Web.Compilation.WebDirectoryBatchCompiler.Process() + 0x5d bytes  
System.Web.dll!System.Web.Compilation.BuildManager.BatchCompileWebDirectoryInternal(System.Web.Hosting.VirtualDirectory vdir, bool ignoreErrors) + 0x48 bytes   
System.Web.dll!System.Web.Compilation.BuildManager.BatchCompileWebDirectory(System.Web.Hosting.VirtualDirectory vdir, System.Web.VirtualPath virtualDir, bool ignoreErrors) + 0xbc bytes    
System.Web.dll!System.Web.Compilation.BuildManager.CompileWebFile(System.Web.VirtualPath virtualPath) + 0x5d bytes  
System.Web.dll!System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(System.Web.VirtualPath virtualPath, bool noBuild, bool allowCrossApp, bool allowBuildInPrecompile, bool throwIfNotFound, bool ensureIsUpToDate) + 0x141 bytes    
System.Web.dll!System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(System.Web.HttpContext context, System.Web.VirtualPath virtualPath, bool noBuild, bool allowCrossApp, bool allowBuildInPrecompile, bool throwIfNotFound, bool ensureIsUpToDate) + 0x70 bytes 
System.Web.dll!System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(System.Web.VirtualPath virtualPath, System.Web.HttpContext context, bool allowCrossApp, bool throwIfNotFound) + 0x7e bytes   
System.Web.dll!System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(System.Web.VirtualPath virtualPath, System.Type requiredBaseType, System.Web.HttpContext context, bool allowCrossApp) + 0x35 bytes 
System.Web.dll!System.Web.UI.PageHandlerFactory.GetHandlerHelper(System.Web.HttpContext context, string requestType, System.Web.VirtualPath virtualPath, string physicalPath) + 0x20 bytes  
System.Web.dll!System.Web.UI.PageHandlerFactory.GetHandler(System.Web.HttpContext context, string requestType, string virtualPath, string path) + 0x26 bytes    
System.Web.dll!System.Web.HttpApplication.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() + 0x14f bytes 
System.Web.dll!System.Web.HttpApplication.ExecuteStep(System.Web.HttpApplication.IExecutionStep step, ref bool completedSynchronously) + 0xb9 bytes 
System.Web.dll!System.Web.HttpApplication.PipelineStepManager.ResumeSteps(System.Exception error) + 0x39f bytes 
System.Web.dll!System.Web.HttpApplication.BeginProcessRequestNotification(System.Web.HttpContext context, System.AsyncCallback cb) + 0x5a bytes 
System.Web.dll!System.Web.HttpRuntime.ProcessRequestNotificationPrivate(System.Web.Hosting.IIS7WorkerRequest wr, System.Web.HttpContext context) + 0xbe bytes   
System.Web.dll!System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(System.IntPtr managedHttpContext, System.IntPtr nativeRequestContext, System.IntPtr moduleData, int flags) + 0x247 bytes 
System.Web.dll!System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(System.IntPtr managedHttpContext, System.IntPtr nativeRequestContext, System.IntPtr moduleData, int flags) + 0x29 bytes    
[Native to Managed Transition]  
[Managed to Native Transition]  
System.Web.dll!System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(System.IntPtr managedHttpContext, System.IntPtr nativeRequestContext, System.IntPtr moduleData, int flags) + 0x2cc bytes 
System.Web.dll!System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(System.IntPtr managedHttpContext, System.IntPtr nativeRequestContext, System.IntPtr moduleData, int flags) + 0x29 bytes    
[Appdomain Transition]  

person just.another.programmer    schedule 27.02.2012    source источник
comment
перестройте свой проект и проверьте еще раз.   -  person Pankaj    schedule 27.02.2012
comment
Вы все еще можете быть на что-то. Попробуйте очистить папки bin и obj с помощью этого powershell. Предполагается, что перестройка должна все это очистить, но я считаю, что она не всегда получает все. blog.slaven .net.au/2006/11/22/   -  person Christopher Rathermel    schedule 27.02.2012


Ответы (3)


Я решил эту проблему во время отладки ошибки с помощью aspnet_compiler. Оказывается, в моем проекте были физические файлы .aspx в каталогах контента на моем сайте, которые были «исключены» из моего проекта. Поскольку они были исключены, они не вызывали ошибок времени компиляции.

Однако по какой-то причине менеджер сборки компиляции веб-страницы (aspx) находит их и пытается собрать! Я предполагаю, что это связано с разделением компиляции между файлами dll и aspx. aspnet_compiler не проверяет ProjectName.vbproj (или .csproj) на предмет того, какие страницы предназначены для компиляции, он просто компилирует их все. (Если бы кто-нибудь мог документировать это, было бы здорово)!

person just.another.programmer    schedule 05.08.2012
comment
Я зашел в папку obj и почистил ее вручную. После этого я смог запустить свой проект. - person Lars Ladegaard; 17.05.2017

Я столкнулся с той же проблемой. Это было с файлом ascx. Однако его код находится в dll. На одном сервере работало, на другом нет. Сравнение между DLL показало несоответствие. Мы скопировали библиотеки DLL из рабочей версии в нерабочую, и проблема была решена.

person Jeremy Ray Brown    schedule 30.08.2012

Недавно я испытал это в веб-приложении. Проблема заключалась в том, что пакет nuget попал в зависимость Microsoft.Net.Compiler и Microsoft.Code.Dom.

Они поддерживают многоуровневые версии компилятора.

Это преобразовало мое приложение в веб-приложение ASP.NET вместо веб-приложения. Мне потребовалось вечность, чтобы решить эту проблему за 2,5 дня !!!

Я удалил их из Nuget Manager, удалил файлы в каталогах obj и bin - закрыл студию - а затем пересобрал проект.

КАКАЯ ЭТО БЫЛА БОЛЬ!!

person Ken    schedule 02.03.2020