加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

C# – Visual Studio中的System.OutOfMemoryException

发布时间:2020-12-15 23:22:48 所属栏目:百科 来源:网络整理
导读:我有一个问题,当我在Visual Studio中右键单击我的主窗体并转到“查看设计器”时出现错误.它说:’抛出了’System.OutOfMemoryException’类型的异常. 堆栈跟踪: at System.Reflection.AssemblyName.nGetFileInformation(String s)at System.Reflection.Asse
我有一个问题,当我在Visual Studio中右键单击我的主窗体并转到“查看设计器”时出现错误.它说:’抛出了’System.OutOfMemoryException’类型的异常.

堆栈跟踪:

at System.Reflection.AssemblyName.nGetFileInformation(String s)
at System.Reflection.AssemblyName.GetAssemblyName(String assemblyFile)
at Microsoft.VisualStudio.Design.VSTypeResolutionService.AssemblyEntry.get_AssemblyName()
at Microsoft.VisualStudio.Design.VSTypeResolutionService.AssemblyEntry.get_FullName()
at Microsoft.VisualStudio.Design.VSTypeResolutionService.AssemblyEntry.get_AssemblySpec()
at Microsoft.VisualStudio.Design.VSTypeResolutionService.SearchProjectEntries(String fullName,Boolean correctThread)
at Microsoft.VisualStudio.Design.VSTypeResolutionService.System.ComponentModel.Design.IDesignTimeAssemblyLoader.GetTargetAssemblyPath(AssemblyName runtimeOrTargetAssemblyName,String suggestedAssemblyPath,FrameworkName targetFramework)
at Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkUniverse.ResolveAssembly(AssemblyName assemblyName,Assembly runtimeAssembly)
at Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkUniverse.GetTypeFromTargetLocation(Type type,Boolean validateBase)
at Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkUniverse.GetType(Type type)
at Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkUtil.GetCustomAttributes(Type type,Type filter,Boolean inherit,CustomAttributesCache cache)
at Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkType.GetCustomAttributes(Type filter,Boolean inherit)
at Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkAttributeCollection.GetAttributes(Type type,Type filter)
at Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkAttributeCollection.GetAttributes(MemberInfo member,Type filter)
at Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkAttributeCollection.get_Attributes()
at System.ComponentModel.AttributeCollection.get_Count()
at Microsoft.VisualStudio.Design.VSDesignSurface.EnsureExtensions(IComponent component)
at Microsoft.VisualStudio.Design.VSDesignSurface.CreateInstance(Type type)
at System.ComponentModel.Design.DesignerHost.System.ComponentModel.Design.IDesignerHost.CreateComponent(Type componentType,String name)
at System.ComponentModel.Design.Serialization.DesignerSerializationManager.CreateInstance(Type type,ICollection arguments,String name,Boolean addToContainer)
at System.ComponentModel.Design.Serialization.DesignerSerializationManager.System.ComponentModel.Design.Serialization.IDesignerSerializationManager.CreateInstance(Type type,Boolean addToContainer)
at System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.Deserialize(IDesignerSerializationManager manager,CodeTypeDeclaration declaration)
at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager manager)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager)
at System.ComponentModel.Design.Serialization.BasicDesignerLoader.BeginLoad(IDesignerLoaderHost host)

设计师:
http://pastebin.com/hdRB5DAj

今天早上我收到了这个错误,但我还是没有解决.如果有人能帮助我,我会非常感激!

我只使用了我所有RAM的55%,所以不可能.

解决方法

这可能是由多种因素导致的,并且旧版Visual Studio的问题变得更糟(2005年我的经历特别糟糕).

当您查看表单的设计者时会发生这种情况,这可能是由于在表单的构造函数或事件处理程序中创建了对象.当VS将表单加载到设计器中时,它实际上将编译并创建表单类的实例.您在表单中创建的任何对象也可能在此时创建.所有这些都发生在Visual Studio的内存分配中,因此如果要分配大量内存,这可能会妨碍Visual Studio的内存处理.

我建议您对表单的DesignMode属性执行检查,并仅在该属性为false时加载/创建数据类(如Views)的实例.您还应该准备在整个表单中的事件处理程序中执行此操作,因为这些可以由Visual Studio设计器触发.

或者,如果你感觉很勇敢,你可以自己调试Visual Studio!在VS中打开您的项目,然后打开另一个VS实例.在第二个实例中使用Debug – >附加到Process选项并附加到第一个VS实例.现在打开表单的设计器,看看是否可以识别错误发生的位置.您可能必须在Debug – >下打开’break on thrown exceptions’设置.第二个VS实例中的例外,以确保您的调试会话看到所有异常.

祝好运.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读