我们使用的Web应用程序的一部分使用内部Web控件程序集。此程序集包含多个Web用户控件,其中一些控件由同一程序集中的其他Web控件使用。
程序集构建为具有Web部署项目的网站。
主Web应用程序的页面通过服务动态编译为单个程序集,并放入相应的bin文件夹中。在我们的开发服务器中,旧的程序集并不总是被整理和删除,这意味着文件夹中充满了旧的程序集。
当使用内部Web控件程序集(如上所述)的页面运行时,asp.net实例会在加载所有旧程序集时抛出内存不足,以尝试确定哪个程序集包含对该引用的引用用户控件由同一程序集内的其他用户控件使用。
我们一直在顶级用户控件中使用以下内容来注册其他控件
<%@ Register Src="~/....ascx" TagPrefix="UC" TagName="...." %>
当然,当应用程序运行时,它不会提供有关它可以找到它的程序集的信息。
之前有没有人遇到过这个问题? 这不是一个真正的问题,因为我们的实时服务器使用清理工具来删除旧的程序集,但仍有可能因此导致内存不足(例如工具停止工作!),所以它会很好解决这个问题。
由于
这是堆栈跟踪
[OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.]
System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +0
System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +43
System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +127
System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +142
System.Reflection.Assembly.Load(String assemblyString) +28
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +46
[ConfigurationErrorsException: Exception of type 'System.OutOfMemoryException' was thrown.]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +613
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +203
System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +105
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +178
System.Web.Compilation.BuildProvidersCompiler..ctor(VirtualPath configPath, Boolean supportLocalization, String outputAssemblyName) +54
System.Web.Compilation.CodeDirectoryCompiler.GetCodeDirectoryAssembly(VirtualPath virtualDir, CodeDirectoryType dirType, String assemblyName, StringSet excludedSubdirectories, Boolean isDirectoryAllowed) +8812786
System.Web.Compilation.BuildManager.CompileCodeDirectory(VirtualPath virtualDir, CodeDirectoryType dirType, String assemblyName, StringSet excludedSubdirectories) +128
System.Web.Compilation.BuildManager.CompileCodeDirectories() +265
System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +320
[HttpException (0x80004005): Exception of type 'System.OutOfMemoryException' was thrown.]
System.Web.Compilation.BuildManager.ReportTopLevelCompilationException() +58
System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +512
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters) +729
[HttpException (0x80004005): Exception of type 'System.OutOfMemoryException' was thrown.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +8894095
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +85
System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +259
答案 0 :(得分:0)
对于这些情况,我在web.config中注册了控件。
<pages>
<controls>
<add tagPrefix="yourPrefix" namespace="Your.Lib.Controls" assembly="Your.Lib.Controls"/>
</controls>
</pages>