Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
312 views
in Technique[技术] by (71.8m points)

c# - Editing XAML leads Visual Studio's Designer to crash

Original Question


I'm working on a WPF application with Visual Studio 2010, using Telerik.

I have been dealing with a lot of crashes everytime I use the designer : clicking on a element, changing its position, even changing its name leads to a crash, and displays the following exception :

System.ArgumentNullException
Value cannot be null.
   to System.RuntimeType.MakeGenericType(Type[] instantiation)
   to Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkUtil.GetRuntimeType(Type type)
   to Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkType.TryGetRuntimeType()
   to Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkUtil.EnsureRuntimeType(Type type)
   to Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkProvider.GetRuntimeType(Type reflectionType)
[...]

I tried the following things :

  • Uninstall and reinstall Telerik;
  • Uninstall and reinstall .NET 4.0;
  • Uninstall and reinstall Visual Studio.

None of these attempts worked.

This morning, I noticed that the designer didn't crashed at all, and I understood why : the designer crashes when I have opened or edited XAML.

After opening XAML, Visual Studio begin to freeze and the designer crashes everytime I try to click something. If I close Visual Studio and Build the solution (without opening XAML), everything works fine with the designer.

My guess is that something goes wrong when Visual Studio tries to "convert" XAML code to graphical elements in the designer, and only in that direction.


Question : Have you ever experimented this kind of thing ? Have you any idea of why modifiying XAML causes crashes and how to solve it ?

Thank you in advance.


New attemps done after reading answers

  • Debug the Visual Studio instance itself when the designer opens. The method which leads to the ArgumentNullException is GetRuntimeTime. I've been able to see the .NET code but I couldn't determine the source of the problem. See the full stack trace below :

enter image description here

Additionally, this is the exact line where the error occurs and the exception details. Note that the file is VSIsolationProviderService.cs and that I am able to see the source thanks to the .NET Reflector Object Browser.

enter image description here

  Message=Value cannot be null.
  Source=mscorlib
  StackTrace:
       to System.RuntimeType.MakeGenericType(Type[] instantiation)
  InnerException: null

Finally, the Local Variables inspector at the moment of the Exception shows the following object :

enter image description here

End of the object :

enter image description here

Answers to comments :

  • The value of this._targetFrameworkProvider at the line where the exception occurs is below. enter image description here
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I guess, your best bet is to debug Visual Studio!

  • Run Visual Studio (instance #1) and load your solution
  • Run a 2nd instance of Visual studio (#2)
  • From instance #2 go, Debug->Attach to process->Select devenv.exe (instance #1, make sure to select Managed debugging)
  • Then select Debug->Exception, press "Find.." and search for System.ArgumentNull then check "Thrown"
  • Go to instance #1, load your view in the designer, this should trigger a break point in instance #2 and it should show you a full stack trace. This information should be enough to identify the offending control/component..

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...