Answered by:
Unhandled Exception has occurred

Question
-
I keep getting these type of exceptions in the XAML designer.
Unhandled Exception has occurred
Click here to reload the designer
Microsoft.Expression.DesignHost.Isolation.Remoting.RemoteException
The value cannot be a null reference (Nothing in Visual Basic) when the target type is a value type.
at Microsoft.Expression.Markup.DocumentModel.DocumentPrimitiveNode..ctor(IDocumentContext context, ITypeId typeId, IDocumentNodeValue value) at Microsoft.Expression.Markup.DocumentModel.DocumentPrimitiveNode.DocumentPrimitiveNodeDeserializer.Deserialize(IStateDeserializationContext context) at Microsoft.Expression.DesignSurface.Documents.StreamDocumentStateDeserializationContext.Read(IStateDeserializer deserializer) at Microsoft.Expression.DesignSurface.Documents.StreamDocumentStateDeserializationContext.ReadTypeAndState() at Microsoft.Expression.DesignSurface.Documents.SceneMarkupDocument.PropertyDictionaryChangeUndoUnit.PropertyDictionaryChangeUndoUnitDeserializer.Deserialize(IStateDeserializationContext context) at Microsoft.Expression.DesignSurface.Documents.StreamDocumentStateDeserializationContext.Read(IStateDeserializer deserializer) at Microsoft.Expression.DesignSurface.Documents.StreamDocumentStateDeserializationContext.ReadTypeAndState() at Microsoft.Expression.DesignSurface.DesignerUndoService.ReadUndo(IStateDeserializationContext context, UndoTarget target) at Microsoft.Expression.DesignSurface.Documents.SceneMarkupDocument.RestoreAdditionalDocumentNodes(IStateDeserializationContext context) at Microsoft.Expression.DesignSurface.ViewModel.SceneViewModel.ReadState(Stream input) at Microsoft.Expression.DesignSurface.ViewModel.SceneViewModel.ReadContext() at Microsoft.Expression.DesignSurface.ViewModel.SceneViewModel.LoadContext() at Microsoft.Expression.DesignSurface.View.XamlSceneView.<.ctor>b__0() at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler) at System.Windows.Threading.DispatcherOperation.InvokeImpl() at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Windows.Threading.DispatcherOperation.Invoke() at System.Windows.Threading.Dispatcher.ProcessQueue() at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler) at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs) at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam) at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg) at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame) at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame) at System.Windows.Threading.Dispatcher.Run() at System.Windows.Application.RunDispatcher(Object ignore) at System.Windows.Application.RunInternal(Window window) at System.Windows.Application.Run(Window window) at System.Windows.Application.Run() at Microsoft.Expression.DesignHost.Isolation.IsolationProcess.RunApplication() at Microsoft.Expression.DesignHost.Isolation.IsolationProcess.DesignProcessViewProvider.<>c__DisplayClass7.<applicationView_Activated>b__6() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()
The XAML is:
<common:LayoutAwarePage x:Name="pageRoot" x:Class="metro.TreePage" DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}" IsTabStop="false" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:metro" xmlns:common="using:metro.Common" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"> <Page.Resources> <!-- TODO: Delete this line if the key AppName is declared in App.xaml --> <x:String x:Key="AppName">My Application</x:String> </Page.Resources> <!-- This grid acts as a root panel for the page that defines two rows: * Row 0 contains the back button and page title * Row 1 contains the rest of the page layout --> <Grid Style="{StaticResource LayoutRootStyle}"> <Grid.RowDefinitions> <RowDefinition Height="340"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <!-- Back button and page title --> <Grid Style="{StaticResource LayoutRootStyle}"> <Grid.RowDefinitions> <RowDefinition Height="*"></RowDefinition> <RowDefinition Height="*"></RowDefinition> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <Button x:Name="backButton" Click="GoBack" IsEnabled="{Binding Frame.CanGoBack, ElementName=pageRoot}" Style="{StaticResource BackButtonStyle}"/> <TextBlock x:Name="pageTitle" Grid.Column="1" Text="{StaticResource AppName}" Style="{StaticResource PageHeaderTextStyle}"/> <!--<Button Content="Button" Grid.Row="1"> </Button>--> <!--<ListView x:Name="zzx" Grid.Row="1" Grid.Column="1" > <x:String>Hello</x:String> <x:String>World</x:String> </ListView>--> <SemanticZoom IsZoomedInViewActive="False" Grid.Row="1" Grid.Column="1" > <SemanticZoom.ZoomedOutView> <ListView x:Name="ZoomOutList"> <x:String>Chuid</x:String> <ListView > <Button Content="World"> </Button> <Button Content="Africa"></Button> <Button Content="Asia"></Button> </ListView> </ListView> </SemanticZoom.ZoomedOutView> <SemanticZoom.ZoomedInView> <GridView x:Name="ZoomInList"> <x:String>Hello</x:String> <x:String>World</x:String> </GridView> </SemanticZoom.ZoomedInView> </SemanticZoom> </Grid> <VisualStateManager.VisualStateGroups> <!-- Visual states reflect the application's view state --> <VisualStateGroup x:Name="ApplicationViewStates"> <VisualState x:Name="FullScreenLandscape"/> <VisualState x:Name="Filled"/> <!-- The entire page respects the narrower 100-pixel margin convention for portrait --> <VisualState x:Name="FullScreenPortrait"> <Storyboard> <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style"> <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PortraitBackButtonStyle}"/> </ObjectAnimationUsingKeyFrames> </Storyboard> </VisualState> <!-- The back button and title have different styles when snapped --> <VisualState x:Name="Snapped"> <Storyboard> <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style"> <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedBackButtonStyle}"/> </ObjectAnimationUsingKeyFrames> <ObjectAnimationUsingKeyFrames Storyboard.TargetName="pageTitle" Storyboard.TargetProperty="Style"> <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedPageHeaderTextStyle}"/> </ObjectAnimationUsingKeyFrames> </Storyboard> </VisualState> </VisualStateGroup> </VisualStateManager.VisualStateGroups> </Grid> </common:LayoutAwarePage>
The program will run correctly. And if I exit VS, and reload the project, then the designer does not get the exception. However, clicking on "reload the designer" still produces the same error. I figured that if I report it, perhaps the next version can recover more gracefully from the problem; perhaps reporting what "Value" is getting or has a null reference.
-- XAML designer in C++ VS Metro environment gives exception on previous contents of XAML file, not the contents visible to the user.
-- XAML designer not catching syntax errors in XAML cleanly- unhandled exception.
- Edited by Andrew7Webb Thursday, June 28, 2012 6:42 PM Added keywords
Thursday, June 28, 2012 4:06 PM
Answers
-
I reproed exception on design surface on 11.0.50522.1 RCREL only after I delete
<Target Name="PrimaryWinMDOutputGroup" Returns="@(PrimaryWinMDFullPath)">
<ItemGroup>
<PrimaryWinMDFullPath Include="$(OutDir)NoWinMDFile.winmd"/>
</ItemGroup>
</Target>So, I believe that's the reason. And the code above is the work around.
Besides, I can't repro the exception on later version even without the above code change.
- Proposed as answer by JackyGao Friday, June 29, 2012 5:11 PM
- Marked as answer by Jesse Jiang Monday, July 2, 2012 2:25 AM
Friday, June 29, 2012 12:54 AM
All replies
-
Hi Andrew
I can run the app successfully and it works perfect. Exit VS, launch vs and open the same project again also load design surface correctly. I believe it is fixed now. What version you are using?
- Edited by JackyGao Thursday, June 28, 2012 5:27 PM
Thursday, June 28, 2012 5:26 PM -
The same thing happens to me- reloading the project makes the problem go away.
Here are the versions:
OS Name Microsoft Windows 8 Release Preview
Version 6.2.8400 Build 8400Microsoft Visual Studio Professional 2012 RC
Version 11.0.50522.1 RCREL
Microsoft .NET Framework
Version 4.5.50501Installed Version: Professional
Microsoft Visual C++ 2012 RC 04167-004-0009005-02372
Microsoft Visual C++ 2012 RCI'll try to recreate the problem.
Thursday, June 28, 2012 5:45 PM -
Changed to the non existent grid row 2:
<SemanticZoom IsZoomedInViewActive="False" Grid.Row="2" Grid.Column="1" >
and I get this error:
Microsoft.Expression.DesignHost.Isolation.Remoting.RemoteException
Index was out of range. Must be non-negative and less than the size of the collection.Parameter name: index
Changed it back to 1, saved the .xaml, and I still get the above error.
Recompile (Using C++), and it runs ok.
Reload the designer, and it still gets the exception.
Thursday, June 28, 2012 5:53 PM -
By said Reload, I assume you mean close xaml file, then reopen it? or close solution and VS, re-launch VS, and open the project again? Or, kill xDesProc.exe, and then click "Click here to reload the designer". All this way it works well for me. I think it is fixed in a later version since mine is newer than yours. So you may expect that it will be fixed in next release.
- Edited by JackyGao Thursday, June 28, 2012 6:14 PM
Thursday, June 28, 2012 6:13 PM -
By Reload, I mean clicking on "Click here to reload the designer".
Did you try this using the C++ environment or something else?
I don't expect anything was fixed until I can reproduce the problem on an old version, but can't on a new version using the exact same method.
By said Reload, I assume you mean close xaml file, then reopen it? or close solution and VS, re-launch VS, and open the project again? Or, kill xDesProc.exe, and then click "Click here to reload the designer".
Thursday, June 28, 2012 6:26 PM -
Fixing the problem in the XAML, then closing the file, then reopening the .xaml file DOES remove the exception.
Clicking on "Click here to reload the designer". but not closing the .xaml file, DOES NOT remove the exception.
So what you see in the XAML page is not what the XAML designer is getting.
Thursday, June 28, 2012 6:39 PM -
I tried C++ too, works well.
I even can't get the design surface exception. The only way I can get the design surface exception is to kill xDesProc (So that I am able to click "Click here to reload designer")
I am preparing a same Release Preview machine as you. Will get back to you later.
Thursday, June 28, 2012 6:44 PM -
I can not repro the exception on release preview either.
What I did is create a C++ Group metro application. Copy paste your code into GroupedItemsPage.xaml (replace the default code). Made some necessary change, like change the "metro", "ThreePage" etc. Build
And thing different? Could you gave a a detail step you were doing?
Thursday, June 28, 2012 9:08 PM -
The projects are on my skydrive public folder:
"metro" is the project that contains the .xaml in question, and "politan: is a library.
https://skydrive.live.com/redir.aspx?cid=eb4f9903e74eeca8&page=view&resid=EB4F9903E74EECA8!119&parid=EB4F9903E74EECA8!114&sc=Documents&authkey=!&Bpub=SDX.SkyDrive&Bsrc=ShareI have ben trying to get a simpler reproduction of the error without success.
The Metro project depends on a politan static library
I had to modify the politan library project file by inserting:
<Target Name="PrimaryWinMDOutputGroup" Returns="@(PrimaryWinMDFullPath)">
<ItemGroup>
<PrimaryWinMDFullPath Include="$(OutDir)NoWinMDFile.winmd"/>
</ItemGroup>
</Target>per:
- Edited by Andrew7Webb Thursday, June 28, 2012 11:28 PM new info:
- Proposed as answer by JackyGao Friday, June 29, 2012 5:11 PM
Thursday, June 28, 2012 10:28 PM -
I reproed exception on design surface on 11.0.50522.1 RCREL only after I delete
<Target Name="PrimaryWinMDOutputGroup" Returns="@(PrimaryWinMDFullPath)">
<ItemGroup>
<PrimaryWinMDFullPath Include="$(OutDir)NoWinMDFile.winmd"/>
</ItemGroup>
</Target>So, I believe that's the reason. And the code above is the work around.
Besides, I can't repro the exception on later version even without the above code change.
- Proposed as answer by JackyGao Friday, June 29, 2012 5:11 PM
- Marked as answer by Jesse Jiang Monday, July 2, 2012 2:25 AM
Friday, June 29, 2012 12:54 AM -
I'll just remind myself to recheck this on the new VS release then. Thanks for looking in to it.Friday, June 29, 2012 1:15 AM