Visual Studio crashes when encountering XAML errors during initialization

I have been having serious problems lately with Visual Studio 2010. This was a crash in an unusual way when I came across certain types of XAML errors during the InitializeComponent() of a control / window.

The program is interrupted and the visual studio moves up as if it is catching an exception (because it is), and then it stops in the middle, showing the broken highlight in my XAML file without any details regarding what is wrong. Example:

alt text

There are no popups or Anywhere details about what's wrong, just a column pointing to my call to InitializeComponent() .

Now, as a rule, I just did a trial version and corrected the error to solve this problem, and find out where I got corrupted, but the real problem is not in my code. At the moment, Visual Studio is completely useless. It informs my application in the "Run" mode. The Stop / Break / Restart buttons on the toolbar or in the menu do nothing (but gray).

Closing the application does not stop this behavior, closing the visual studio, forcing it to get stuck in a massive loop where it yells at me, complaining that every open file is not in the debugging project, and then repeats this process when I convinced every open file .

I need to force close devenv.exe , and after that it happens 3-4 times in a row a lot of time wasted (since my projects are usually quite large and the studio can be quite slow @ loading).

To the point

  • Has anyone else experienced this?
  • How to stop the studio from blocking.
  • Can I get information from this monster on LEAST in a different way, so that I can correct my XAML error earlier than after 3-4 compilation of trial and error, leading to the same failure?

Any help would be appreciated.

Visual Studio 2010 Version: 10.0.30319.1RTM

Change and update

FWIW, basically the errors causing this are XamlParseExceptions (I figured it out after I discovered what was wrong with my XAML).

I think I need to be clearer, although I am not looking for a solution to my code problem, as these are usually typos / small things, I am looking for a solution for VStudio that all gets distorted as a result.

The specific error in the above image that 100% surely caused this was a XamlParseException caused by forgetting the Value attribute in the data trigger.

I fixed this part, but it still doesn’t tell me why my studio turns into a piece of a castrated program when a completely normal exception occurs in XAML parsing.

Code that will cause this problem (at least for me)

This is a basic WPF boilerplate application with the following Window.xaml code. The problem is the lack of Value="True" in the <DataTrigger ...> in the template. It throws XamlParseException and Visual Studio errors as described above during debugging.

 <Window x:Class="XamlParseExplosion.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <Window.Resources> <DataTemplate x:Key="BankListItemTemplate"> <Border x:Name="ItemBorder" Width="250" Margin="1" BorderBrush="Blue" BorderThickness="5,0,0,0"> <Grid> <Label Content="{Binding Name}" /> </Grid> </Border> <DataTemplate.Triggers> <DataTrigger Binding="{Binding IsDirty}"> <Setter TargetName="ItemBorder" Property="BorderBrush" Value="Red" /> </DataTrigger> </DataTemplate.Triggers> </DataTemplate> </Window.Resources> <Grid> <ListView ItemTemplate="{StaticResource BankListItemTemplate}" /> </Grid> </Window> 

Final notes

The following solutions did not help me :

  • Restart Visual Studio
  • Rebooting
  • Reinstall Visual Studio
  • Disabling add-ons like ReSharper and Reflector

Update (path later) w / Answer

I want to add to this (as a pseudo-answer) because I later found out about it later that I want to convey to people who find this question on google.

The real problem: A XamlParseException was thrown in Debug -> Exception to break when this happens, because it happens during a WPF connection. vstudio cannot catch it correctly (usually it falls into several more levels and is processed where vstudio can handle this).

Just turn it off and life will be good again.

I did not want to put this as an answer, because the answer provided by mazelo was also right, when vstudio was launched as an Administrator, it seems to be able to correctly catch the exception and debug from there, so I did not want to take away its response status, because its solution really works.

+4
source share
8 answers

I had a similar problem. After several hours, I had the idea of ​​running a visual studio as an administrator. The problem is fixed, but still do not know why.

+1
source

I had a similar problem and the above answers did not help me. I will post my decision here if this happens to others. I had a window with suspicious xaml, which, when I tried to open the window tab in VS, caused it to crash every time. It's amazing when you want to get there to remove bad code! A simple solution: open the xaml file in notepad, delete the bad code and then rebuild it in VS. Simple but worked for me.

+2
source

This is probably a failure while initializing the built-in UserControl. See how the DependencyProperties properties of this control are handled.

+1
source

What you need to try:

  • Turn off the "troubleshooting assistant" in the debugging options.
  • Disable the "Visual Studio Hosting Process" in the project debugging properties.

Does the behavior differ if you enable "break on CLR exceptions" in the "Exceptions" dialog box (Ctrl + Shift + E) and disable "Include only my code ..."?

0
source

Something similar happened to me in an aspx file, in a MOSS project. There was a single line that each time caused a VS crash. I realized that the only solution was to delete the line and add it only when the file was not opened in VS.

You checked the file format, I mean, is this the Unicode / Ansi / etc file right? Check it out at binary level.

Try opening a new WPF project by skipping XAML (without code) and see if it all crashes. Try-catch around Initialize won't help?

Edit: I tried XAML, you sent a message, no errors. Same version of VS.

0
source

Try disabling visual effects in the settings of Visual Studio. I know that it sounds crazy and sounds disconnected, but when I did it on my rather old graphics card, it all crashed a lot less.

As for accidents that occur, I suggest sending a report to Microsoft Connect if the above does not work.

0
source

Change the graphics card drivers. Either update them or return the drivers provided by Microsoft.

On my work computer, I returned to the integrated Intel video adapter, and Visual Studio and Windows Explorer no longer crash.

Cm.

0
source

It also happened to me. I can reproduce the problem every time with a simple scenario:

 <UserControls:OperationLoader DepProperty1="{Binding VMProperty1}" DepProperty2="{Binding VMProperty2, Converter={StaticResource boolToInverse}}}"/> 

If I delete part of the converter, everything works fine. Probably the problem is the implementation of the converter, which looks like this:

 public sealed class BooleanToInverseConverter : BooleanConverter<bool> { public BooleanToInverseConverter() : base(false, true) { } } 
0
source

Source: https://habr.com/ru/post/1334246/


All Articles