vs2010 clr20r3错误_VS2010旗舰版双击选中或者光标选中代码时频繁崩溃问题
本来用的好好的,不知道怎么就挂了,每次调试xslt都会出错,然后只能关闭重启,然后又出错。。。
火了,重装,还没有解决问题,冲动啊,浪费两个小时
网上查了一下
?
http://www.ikosingapore.com/Forums/da-DK/vssetup/thread/d3608a82-62b7-43d8-9864-e86232c17d01
?
应该是一些配置有问题
1. Open Visual Studio Command Prompt (2010) under Start menu -> All Programs -> Microsoft Visual Studio 2010 -> Visual Studio Tools (run it with Administrator privilege: right-click the program -> Run as administrator);
2. Try some devenv switches in command prompt:
a. Run devenv /Resetsettings to eliminate the cause of corrupted settings.
b. Run devenv /ResetSkipPkgs in Command Prompt.
c. Run devenv /Safemode to see if you can apply it correctly. This can eliminate the possibility that third party Add-ins or packages are causing problems.
3. Reboot the machine in Safe Mode. This can isolate some third party application/driver's interference.
4. Switch and try a new user account. This can rule out the possibility of corrupted user profile.
VS2010 配置文件路径:C:\Users\Administrator\AppData\Roaming\Microsoft\VisualStudio\10.0
VS2010旗舰版双击选中或者光标选中代码时频繁崩溃问题
VS2010每次双击代码想选中某个单词的时候,或者用鼠标想选中某一样的时候,VS2010就会崩溃掉。
事件查看发现报错如下:
EventType clr20r3, P1 devenv.exe, P2 10.0.30319.1, P3 4ba1fab3, P4 microsoft.visualstudio.platform.vseditor, P5 10.0.0.0, P6 4ba1d76c, P7 1a03, P8 0, P9 system.dllnotfoundexception, P10 NIL.
最后看到事件中无法加载 DLL“UIAutomationCore.dll”: 找到原因是系统的UI补丁没有打造成的。
WindowsXP的下载地址:Windows XP 更新程序 (KB971513)
Windows2003的下载地址:Windows Server 2003 更新程序 (KB971513)
?
打上补丁之后,问题瞬间解决。
在自己的一个Windows Phone开发项目中,遇到一个问题,就某XAML文件切换到Designer下,会立即崩,其它文件则没这问题。而且编译程序,也没有出错,能正常运行,很古怪,重装了VS2010+SP1+Windows Phone SDK均无效。
Problem signature: ? Problem Event Name: CLR20r3 ? Problem Signature 01: devenv.exe ? Problem Signature 02: 10.0.40219.1 ? Problem Signature 03: 4d5f2a73 ? Problem Signature 04: 省略 ? Problem Signature 05: 1.0.0.0 ? Problem Signature 06: 4f535202 ? Problem Signature 07: 5f ? Problem Signature 08: 57 ? Problem Signature 09: System.Exception ? OS Version: 6.1.7601.2.1.0.256.1 ? Locale ID: 2052 Additional information about the problem: ? LCID: 1033
后来经过不断查找资料,发现国外也有人遇到这问题,但是似乎没什么好的解决方法,折腾了半天,在看到这页面后,终于尝试着解决了,下面描述下问题所在。
首先项目使用MVVM开发模式,一个View绑定一个ViewModel,我在ViewModel类的构造函数中有一个函数,该函数会通过我在底层写的一个通讯类的方法访问服务器,获取资源和信息。通讯类采用HttpWebRequest类访问,以下是简单的代码片段:
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
webRequest.Method = request.Method;
webRequest.BeginGetResponse(EndRequest, webRequest);
private void EndRequest(IAsyncResult ar)
{
HttpWebRequest request = (HttpWebRequest)ar.AsyncState;
HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(ar); // 运行到这里会出错
......
}
出错后,用VS Debug了下,发现以下错误代码:
at System.Windows.Threading.Dispatcher.FastInvoke(DispatcherPriority priority, Delegate d, Object[] args)
at System.Net.Browser.AsyncHelper.CheckUseLowLatencyNetworking()
at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
我学WP7开发并不久,这段代码也不怎么看得懂,但是注意到:
System.Windows.Threading.Dispatcher.FastInvoke
BeginOnUI
就怀疑是不是在XAML的Designer下,IDE自动关联View和ViewModel类,并且会导致ViewModel的构造函数运行一遍,从而运行到我的通讯类那里,但由于是异步访问,在调用EndGetResponse时,并不是在UI线程,从而导致Designer出现跨线程访问、崩溃。看那代码,似乎EndGetResponse里的处理会用到UI线程上,不知道是不是就是我上面的猜测?希望高人能讲得更详细些。出于这个猜测,我就改进了下代码,如下:
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
HttpWebRequest request = (HttpWebRequest)ar.AsyncState;
HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(ar);
});
这样写,VS就不再崩溃了。但是总感觉这样写并不好,如果我返回的数据还要进行加工处理,直接在UI线程上处理,会不会影响效率呢?能不能不改动这里,等处理完数据后,再调用去处理?
后来搜了半天,在这里发现有人和我有同样的问题:
http://www.ikosingapore.com/VisualStudio/feedback/details/667062/visual-studio-2010-crashes-randomly-and-frequently-when-editing-a-xaml-silverlight-file
默认的解决方案有2个:
1.使用WebClient代替HttpWebRequest和HttpWebResponse
2.在ViewModelBase里添加一个只有访问器(getter)的属性,属性名为?IsDesignTime
,返回一个 DesignerProperties.IsInDesignTool 属性(需using System.ComponentModel 命名空间)。
但是由于我使用的是MVVM Light,而且项目也写到一定程度了,不好修改基类,所以尝试只在出现问题的ViewModel类添加该属性,但是均未解决。又想了想,在ViewModel构造函数中这样写,终于解决了问题:
if(!DesignerProperties.IsInDesignTool)
{
// 这地方写会调用到HttpWebRequest的函数调用
}
--------------------------
等等,有人会说,我这样写了,切换到Designer下,仍然会崩溃。别急,先把原来的项目解决方案清空,重新编译项目,再切换到Designer下,就不会崩溃了。
关于DesignerProperties.IsInDesignTool属性,MSDN解释为:获取一个值,该值指示元素是否在设计器的上下文中运行。