C
C#17mo ago
Mohammed85

WPF 7.net app craching after it is done building

The error i am getting:
c#
System.Windows.Markup.XamlParseException: ''The invocation of the constructor on type 'mythos.MainWindow' that matches the specified binding constraints threw an exception.' Line number '7' and line position '9'.'
c#
System.Windows.Markup.XamlParseException: ''The invocation of the constructor on type 'mythos.MainWindow' that matches the specified binding constraints threw an exception.' Line number '7' and line position '9'.'
there are no errors/warnings it builds successfully the file which has the namespace mythos and the file name MainWindow.xaml from line 1 to line 17
<Window x:Class="mythos.MainWindow"
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"
xmlns:local="clr-namespace:mythos"
xmlns:viewModel="clr-namespace:mythos.MVVM.ViewModel"
mc:Ignorable="d"
Height="900" Width="1015"
WindowStyle="None"
ResizeMode="CanResizeWithGrip"
Background="Transparent"
AllowsTransparency="True" IsManipulationEnabled="True">

<Window.DataContext>
<viewModel:MainViewModel/>
</Window.DataContext>
<Window x:Class="mythos.MainWindow"
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"
xmlns:local="clr-namespace:mythos"
xmlns:viewModel="clr-namespace:mythos.MVVM.ViewModel"
mc:Ignorable="d"
Height="900" Width="1015"
WindowStyle="None"
ResizeMode="CanResizeWithGrip"
Background="Transparent"
AllowsTransparency="True" IsManipulationEnabled="True">

<Window.DataContext>
<viewModel:MainViewModel/>
</Window.DataContext>
17 Replies
Mohammed85
Mohammed85OP17mo ago
the file which has the namespace mythos and the file name MainWindow.xaml.cs
using mythos.Core;
using mythos.DataClasses;
using mythos.MVVM.Model;
using mythos.MVVM.View;
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Xml;
using mythos.Core;
using mythos.DataClasses;
using mythos.MVVM.Model;
using mythos.MVVM.View;
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Xml;
namespace mythos
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{

public MainWindow()
{
InitializeComponent();
ImportUserAccountData();
test();
/*?
Add the startup classes/funcations here idot. I know you will forget that and put them some were else.
I am clear here only with the only exption being View funcations they stay inside there view files*/

}

void test()
{
JsonData jsonData = new JsonData();
jsonData.ImportJson();
}

public void ImportUserAccountData()
{

string TEMPName = "EpicDensetsu1234567";
int fontSize = 15; // The number of charcters after which all the letter will be removed and ... added insted
if (TEMPName.Length > 15) { TEMPName = (TEMPName.Remove(15) + "..." ); }
List<UserAccountData> contacts = new List<UserAccountData>()
{
new UserAccountData
{
userName = TEMPName, //TODO Change all of these to accuale vars
AccountToken = "non",
imageSource = "https://cdn.discordapp.com/avatars/843270188686245888/f3c27f99128b8510f28e868e98b9c058",
fontSize = fontSize,
}
};
ProfileDisplay.ItemsSource= contacts;

}
}
}
namespace mythos
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{

public MainWindow()
{
InitializeComponent();
ImportUserAccountData();
test();
/*?
Add the startup classes/funcations here idot. I know you will forget that and put them some were else.
I am clear here only with the only exption being View funcations they stay inside there view files*/

}

void test()
{
JsonData jsonData = new JsonData();
jsonData.ImportJson();
}

public void ImportUserAccountData()
{

string TEMPName = "EpicDensetsu1234567";
int fontSize = 15; // The number of charcters after which all the letter will be removed and ... added insted
if (TEMPName.Length > 15) { TEMPName = (TEMPName.Remove(15) + "..." ); }
List<UserAccountData> contacts = new List<UserAccountData>()
{
new UserAccountData
{
userName = TEMPName, //TODO Change all of these to accuale vars
AccountToken = "non",
imageSource = "https://cdn.discordapp.com/avatars/843270188686245888/f3c27f99128b8510f28e868e98b9c058",
fontSize = fontSize,
}
};
ProfileDisplay.ItemsSource= contacts;

}
}
}
reflectronic
reflectronic17mo ago
is there an InnerException on the XamlParseException?
Mohammed85
Mohammed85OP17mo ago
no after the 17th line it is just elements till the end of the fill / i might not know what you are talking about
reflectronic
reflectronic17mo ago
no, what i'm saying is that it tells you what the actual error is
reflectronic
reflectronic17mo ago
reflectronic
reflectronic17mo ago
see the part that says "Inner Exception" that will tell you what is wrong with your code
Mohammed85
Mohammed85OP17mo ago
okay let me snd a pic the inner Exception
This exception was originally thrown at this call stack:
Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile(string, System.IO.FileMode, System.IO.FileAccess, System.IO.FileShare, System.IO.FileOptions) in SafeFileHandle.Windows.cs
Microsoft.Win32.SafeHandles.SafeFileHandle.Open(string, System.IO.FileMode, System.IO.FileAccess, System.IO.FileShare, System.IO.FileOptions, long, System.IO.UnixFileMode?) in SafeFileHandle.Windows.cs
System.IO.Strategies.OSFileStreamStrategy.OSFileStreamStrategy(string, System.IO.FileMode, System.IO.FileAccess, System.IO.FileShare, System.IO.FileOptions, long, System.IO.UnixFileMode?) in OSFileStreamStrategy.cs
System.IO.Strategies.FileStreamHelpers.ChooseStrategyCore(string, System.IO.FileMode, System.IO.FileAccess, System.IO.FileShare, System.IO.FileOptions, long, System.IO.UnixFileMode?) in FileStreamHelpers.Windows.cs
System.IO.File.Create(string) in File.cs
mythos.Core.JsonData.ImportJson() in JsonData.cs
mythos.MainWindow.test() in MainWindow.xaml.cs
mythos.MainWindow.MainWindow() in MainWindow.xaml.cs
This exception was originally thrown at this call stack:
Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile(string, System.IO.FileMode, System.IO.FileAccess, System.IO.FileShare, System.IO.FileOptions) in SafeFileHandle.Windows.cs
Microsoft.Win32.SafeHandles.SafeFileHandle.Open(string, System.IO.FileMode, System.IO.FileAccess, System.IO.FileShare, System.IO.FileOptions, long, System.IO.UnixFileMode?) in SafeFileHandle.Windows.cs
System.IO.Strategies.OSFileStreamStrategy.OSFileStreamStrategy(string, System.IO.FileMode, System.IO.FileAccess, System.IO.FileShare, System.IO.FileOptions, long, System.IO.UnixFileMode?) in OSFileStreamStrategy.cs
System.IO.Strategies.FileStreamHelpers.ChooseStrategyCore(string, System.IO.FileMode, System.IO.FileAccess, System.IO.FileShare, System.IO.FileOptions, long, System.IO.UnixFileMode?) in FileStreamHelpers.Windows.cs
System.IO.File.Create(string) in File.cs
mythos.Core.JsonData.ImportJson() in JsonData.cs
mythos.MainWindow.test() in MainWindow.xaml.cs
mythos.MainWindow.MainWindow() in MainWindow.xaml.cs
reflectronic
reflectronic17mo ago
see, so there's something wrong with your File.Create what is the message for the inner exception
Mohammed85
Mohammed85OP17mo ago
i think it is talkibg about this as it crachs aftte it displays the message box
reflectronic
reflectronic17mo ago
i know for a fact it is talking abuot it that is why it is in the stack trace the computer does not lie
Mohammed85
Mohammed85OP17mo ago
ya i know i said it was this as you said it is file.create but why does it crach
reflectronic
reflectronic17mo ago
i mean, there is a message that should tell you
reflectronic
reflectronic17mo ago
Mohammed85
Mohammed85OP17mo ago
ohh i did not make it check/create on lunch to create the mythos directory
Mohammed85
Mohammed85OP17mo ago
let me test it now
Mohammed85
Mohammed85OP17mo ago
thanks works
Mohammed85
Mohammed85OP17mo ago
@reflectronic appreciate it
Want results from more Discord servers?
Add your server