Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XAML.Parse.Exception on WPF project's deployment

Tags:

wpf

I'm having a problem when I deploy my WPF project, the deployed project crashes on startup and produces a XAML.Parse.Exception with an inner exception of "Cannot have nested BeginInit calls on the same instance" at Line 4 Position 70. The App has full permissions on my computer. I am asking this question because the few questions asked about this had no real solution to the problem.

Here is the XAML code it is referencing with the first couple of lines.

<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="ASRV.MainWindow"
    Title="ASRV GUI" Height="768" Width="1024" ResizeMode="CanMinimize">
<Window.Resources>
</Window.Resources>
<Window.Background>
    <ImageBrush ImageSource="pack://siteoforigin:,,,/background.png"/>
</Window.Background>
like image 957
user2411732 Avatar asked Feb 01 '26 20:02

user2411732


1 Answers

My guess is the reason being:

<Window.Background>
    <ImageBrush ImageSource="pack://siteoforigin:,,,/background.png"/>
</Window.Background>

You might be reusing this image elsewhere in the same window or subcontrol.

BeginInit is called in databinding and this is the only databound thing I could see in your sample code. "BeginInit calls on the same instance" points to it being bound twice.

like image 77
basarat Avatar answered Feb 03 '26 11:02

basarat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!