2011-06-19 73 views
1

我碰到這種異常在項目中期,當我按F5開始調試。我正在使用Visual Studio 2011,該項目是MCV3,EF4,我正在項目中使用Crystal報告。引發異常

這裏是異常的痕跡:

Server Error in '/' Application.

Exception of type 'System.OutOfMemoryException' was thrown.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.]
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, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +39
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks) +132
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +144 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) +618 System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +209 System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +130
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +178
System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +94 System.Web.Compilation.BuildManager.CallPreStartInitMethods() +332 System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +591

[HttpException (0x80004005): Exception of type 'System.OutOfMemoryException' was thrown.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +8946484
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +97
System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +258

這是如何出現的任何想法。

+0

的異常由內部CLR代碼,加載彙編代碼拋出。這就是所有可以從堆棧跟蹤中猜出來的。你需要一個非託管調試器才能看到更多。 –

回答

1

你(可能)有一個遞歸調用的地方在你的代碼,即

A級 構造函數(){ CallAMethod(); } CallAMethod() { 甲一個新= A(); } }

編輯:聖保利正確地指出,遞歸通常會導致StackOverflowException但是,(糾正我,如果錯了)我看到的的約80,000調用遞歸其中,如果對象是大,限制了系統上限在內存中(從其他閱讀中我看到它是CLR堆大小不是線性地址空間,雖然我認爲這也可以發揮作用),會導致資源消耗。

+0

我有這個問題,當我試圖發佈項目到測試環境,意味着在它工作正常。你可以從那裏你看樣遞歸調用除外告訴我.. – tkt986

+0

堆棧跟蹤可能不溢出的情況下有用的(無限遞歸可引起各種誤報。)檢查你的代碼。這幾乎總是導致作爲的結果,無論是你的還是一個庫使用的是創建遞歸 –

+2

無限遞歸將導致StackOverflowException –