C# 项目无法打开,visual studio 崩溃
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17364757/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
project can't be opened, visual studio crashing
提问by Kristian
Last thing I did was add a timer in a user control which updates form color. Now every time I open the project, it loads it up and then says 'Visual Studio Stopped Working'.
我做的最后一件事是在更新表单颜色的用户控件中添加一个计时器。现在每次我打开项目时,它都会加载它,然后说“Visual Studio 停止工作”。
I noticed that Visual Studio 'runs' the timer while in designer mode too, so I thought that might be causing the problem so I removed the timer from designer.cs and then renamed all the files Visual Studio was opening, but still it crashes. All the other projects work fine. This is the 4th time that it has happened to me. I'm using Visual Studio 2012 Ultimate. Any suggestions please?
我注意到 Visual Studio 在设计器模式下也“运行”了计时器,所以我认为这可能是导致问题的原因,所以我从 Designer.cs 中删除了计时器,然后重命名了 Visual Studio 正在打开的所有文件,但它仍然崩溃。所有其他项目工作正常。这是我第 4 次发生这种情况。我正在使用 Visual Studio 2012 Ultimate。请问有什么建议吗?
采纳答案by valverij
It sounds like your solution settings were corrupted when Studio crashed. You can reset them by deleting your solution's *.suofile:
听起来您的解决方案设置在 Studio 崩溃时已损坏。您可以通过删除解决方案的*.suo文件来重置它们:
- Make sure you can view hidden files
- Find your solution in Windows Explorer. It should be a
*.slnfile - There should be a hidden
*.suofile in the same folder. Delete it.
- 确保您可以查看隐藏文件
- 在 Windows 资源管理器中查找您的解决方案。应该是
*.sln文件 *.suo同一个文件夹中应该有一个隐藏文件。删除它。
That will reset all of your solution-specific settings, including the windows you had open.
这将重置所有特定于解决方案的设置,包括您打开的窗口。
In the future, you can prevent code from executing in the designer by wrapping it in an ifusing the Form.DesignModeproperty(inherited from System.ComponentModel.Component):
将来,您可以通过将代码包装在ifusingForm.DesignMode属性中(继承自System.ComponentModel.Component)来防止代码在设计器中执行:
if(!this.DesignMode)
{
/* put code to be excluded from the designer here */
}
UPDATE for VS 2017 and 2019
VS 2017 和 2019 的更新
In VS 2017 and 2019, the *.suofile has been moved into a .vsfolder within the solution directory:
在 VS 2017 和 2019 中,该*.suo文件已移动到.vs解决方案目录中的文件夹中:
~/[Solution Directory]/.vs/[Solution Name]/.suo
~/[Solution Directory]/.vs/[Solution Name]/.suo
You can just delete the entire .vsfolder to reset your local settings for that solution.
您可以删除整个.vs文件夹以重置该解决方案的本地设置。
回答by Branden Barber
Disabling Visual Studio extensions fixed it for me
禁用 Visual Studio 扩展为我修复了它
Tools -> Extensions and Updates -> Installed
工具 -> 扩展和更新 -> 已安装
In my case, Web Essentialswas causing the problem
就我而言,Web Essentials是造成问题的原因
Hope this helps!
希望这可以帮助!
回答by Ankur Goyal
Close all the instance of VS 2012. Open VS 2012 in Admin mode (only VS 2012 no solution), then using this instance of VS try to OPEN the project *.sln.
关闭VS 2012的所有实例。在Admin模式下打开VS 2012(只有VS 2012没有解决方案),然后使用这个VS实例尝试打开项目*.sln。
It should open up properly. For me only this solution works nor deleteing *.suo file neither DISABLING the Extentions and Updates.
它应该正确打开。对我来说,只有这个解决方案有效,也不删除 *.suo 文件,也不禁用扩展和更新。
Hope this helps. Enjoy. What is Stopping You :)
希望这可以帮助。享受。是什么阻止了你:)
回答by spoulson
Make sure file permissions are consistent. If the binor objfolders can't be accessed, Visual Studio may crash. Set file ownership and permissions in file properties -> security -> advanced.
确保文件权限一致。如果无法访问bin或obj文件夹,Visual Studio 可能会崩溃。在文件属性 -> 安全 -> 高级中设置文件所有权和权限。
回答by Juraj Petrik
If you have a different version of Visual Studio on your computer open that one. Click Debug -> Attach To Process. Select the other Visual Studio process. You should only be able to see one. The Process name is devenv.exe.
如果您的计算机上有不同版本的 Visual Studio,请打开该版本。单击调试 -> 附加到进程。选择另一个 Visual Studio 进程。你应该只能看到一个。进程名称是 devenv.exe。
Now replicate the problem in the broken VS. It will break on the exception in the unbroken VS.
现在在损坏的 VS 中复制问题。它将在未中断的 VS 中因异常而中断。
In my case the exception looked like this
在我的情况下,异常看起来像这样
An unhandled exception of type 'System.TypeLoadException' occurred in Microsoft.VisualStudio.Platform.VSEditor.dll
Additional information: Method 'Connect' in type 'JetBrains.UI.SrcView.ContextNotifications.ContextNotificationControl' from assembly 'JetBrains.Platform.UI, Version=104.0.0.0, Culture=neutral, PublicKeyToken=1010a0d8d6380325' does not have an implementation.
Microsoft.VisualStudio.Platform.VSEditor.dll 中发生类型为“System.TypeLoadException”的未处理异常
附加信息:来自程序集 'JetBrains.Platform.UI, Version=104.0.0.0, Culture=neutral, PublicKeyToken=1010a0d8d6380325' 的类型 'JetBrains.UI.SrcView.ContextNotifications.ContextNotificationControl' 中的方法 'Connect' 没有实现。
I fixed it by running the Resharper installer and setting the repair option.
我通过运行 Resharper 安装程序并设置修复选项来修复它。
回答by Atif Ali Bhatti
Clearing my TFS cache worked for me.
清除我的 TFS 缓存对我有用。
To do so:
这样做:
- Close all instances of Visual Studio on the client machine
- Manually delete the corresponding TFS client cache folder, and then start Visual Studio
- 关闭客户端计算机上的所有 Visual Studio 实例
- 手动删除对应的TFS客户端缓存文件夹,然后启动Visual Studio
The corresponding TFS folders to manually delete are as follows:
手动删除对应的TFS文件夹如下:
TFS 2017:
%localappdata%\Microsoft\Team Foundation\7.0\Cache\TFS 2015:
%localappdata%\Microsoft\Team Foundation\6.0\Cache\TFS 2013:
%localappdata%\Microsoft\Team Foundation\5.0\Cache\TFS 2012:
%localappdata%\Microsoft\Team Foundation\4.0\Cache\
TFS 2017:
%localappdata%\Microsoft\Team Foundation\7.0\Cache\TFS 2015:
%localappdata%\Microsoft\Team Foundation\6.0\Cache\TFS 2013:
%localappdata%\Microsoft\Team Foundation\5.0\Cache\TFS 2012:
%localappdata%\Microsoft\Team Foundation\4.0\Cache\
回答by Thomas Hagstr?m
I don't think there's a suo file any more in VS 2017.
我认为 VS 2017 中不再有 suo 文件了。
There is however a hidden .vsfolder. Try deleting it, worked for me :)
但是有一个隐藏.vs文件夹。尝试删除它,对我有用:)
回答by Panagiotis Piperopoulos
Let me introduce my case when visual studio was crashing when opening a solution but not any solution, only a solution with DevExpress components, other solutions where opening ok until i tried to add a DevExpress component on the form.
让我介绍一下我的情况,当 Visual Studio 在打开解决方案但没有任何解决方案时崩溃,只有一个带有 DevExpress 组件的解决方案,其他解决方案在我尝试在表单上添加一个 DevExpress 组件之前可以正常打开。
The EventViewer indicated the problem has to do with a DevExpress dll. I repaired the DevExpress installation and the problem is fixed. Something broke my DevExpress installation. This only happened once in 20 years i am using their components and i have no idea what caused the problem in the first place.
EventViewer 指出问题与 DevExpress dll 有关。我修复了 DevExpress 安装,问题解决了。有些东西破坏了我的 DevExpress 安装。这仅在 20 年发生一次,我正在使用他们的组件,我不知道是什么导致了这个问题。
Having sent that in most cases that i cannot open a single solution i am deleting the .vs folder or the .suo file and the problem is usually fixed. Clearing resharper cache may also help sometimes.
在大多数情况下我无法打开单个解决方案后,我正在删除 .vs 文件夹或 .suo 文件,问题通常已解决。清除 resharper 缓存有时也可能有帮助。
回答by Jesse Sierks
I installed the Newtonsoft.Json Fixer extension, which worked for me. I had attached another VS to see that the missing file for me was with Newtonsoft.Json, which wasn't referenced by my project, and when I found this extension I thought I'd give it a go.
我安装了对我有用的 Newtonsoft.Json Fixer 扩展。我附加了另一个 VS 以查看我丢失的文件是 Newtonsoft.Json,我的项目没有引用它,当我找到这个扩展时,我想我会试一试。


