Exception of type 'System.IO.IOException' - wpf

I have the following error message:
An unhandled exception of type 'System.IO.IOException' occurred in PresentationFramework.dll
Additional information: Cannot locate resource 'Sections/MainWindow.xaml'.
I created folder and then moved my MainWindow.xaml into the folder named Sections. I got the error and then found the question that is already on here about making sure that I change my starupURI to Sections/mainwindow.xaml
However I'm still getting the error message and I don't know why.
Edit: So i ran the code again, not making any changes and now I'm getting this
A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll
Additional information: 'Provide value on 'System.Windows.Baml2006.TypeConverterMarkupExtension' threw an exception.' Line number '5' and line position '54'.
The code that I have at that position:
<Window x:Class="CTaC_Information_System.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
WindowStartupLocation="CenterScreen"
Title="CTaC Information System" Height="828" Width="1486.5" Icon="AISLogov2.ico" Loaded="Window_Loaded" FontFamily="Georgia">
The red line is under the >. I went to the end of my code and added the </Window> because for some reason I was still getting the error message.
All help is greatly appreciated.

I think the second error is being caused by your icon. Try removing that bit of code and re-compiling to check if that isolates the problem. You could try changing the icon image to a .png rather than .ico.

For me this happen, when i moved classes MainWindows.xaml and App.xaml from root folder to /UI folder.
When i moved them back - all become normal again, error gone.

Related

How to use ReactiveUI with WinForms

I have decided to learn ReactiveUI after seeing what can be done with it, but my enthusiasm has been broken at the first attempt to run a simple project. I have recreated the example from this article, using reactiveui-winforms.Net40 version 6.5.0 from NuGet. Everything compiles ok, but i get an exception during runtime at the following line
var OKCmdObs = this.WhenAny(vm => vm.EnteredText,
s => !string.IsNullOrWhiteSpace(s.Value));
System.InvalidOperationException occurred
HResult=-2146233079
Message=The current thread has no Dispatcher associated with it.
Source=System.Reactive.Windows.Threading
StackTrace:
at System.Reactive.Concurrency.DispatcherScheduler.get_Current()
at ReactiveUI.PlatformRegistrations.<>c.<Register>b__0_7() in C:\workspace\git-perso\ReactiveUI\ReactiveUI\Platform\Registrations.cs:line 75
InnerException:
Does anyone have any idea of what's happening ?
The mentioned article does not have the compiled project available for download, and i didn't find any complete "Hello-World" project for reactiveui-winforms.
My test project can be downloaded here.
In Visual Studio, if i Continue(F5), another exception occures :
System.NullReferenceException occurred
HResult=-2147467261
Message=Object reference not set to an instance of an object.
Source=ReactiveUI
StackTrace:
at ReactiveUI.IROObservableForProperty.<>c__DisplayClass1_0.<GetNotificationForProperty>b__6(IReactivePropertyChangedEventArgs`1 x) in C:\workspace\git-perso\ReactiveUI\ReactiveUI\IROObservableForProperty.cs:line 44
InnerException:
If i continue to hit F5 i get :
System.Exception was unhandled by user code
HResult=-2146233088
Message=An OnError occurred on an object (usually ObservableAsPropertyHelper) that would break a binding or command. To prevent this, Subscribe to the ThrownExceptions property of your objects
Source=ReactiveUI
This exception is caused because RxUI always tries to initialize for WPF, even though (because you're also using the winforms package) it'll override this setting with a Winforms-based scheduler right after.
It should be harmless though, as it's catched and ignored. You're probably hitting it within VS ?

exception while changing cursor

A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll
Additional information: 'The invocation of the constructor on type 'filehelpertest.MainWindow' that matches the specified binding constraints threw an exception.' Line number '3' and line position '9'.
Hi all,
i'v wanted to change my grid's cursor to a custom one using this code:
//using resources is already in the references assembly
Cursor gameCursor = new Cursor(Application.GetResourceStream(new Uri("pack://application:,,,/Pictures/Cursor.cur")).Stream);
MenuGrid.Cursor = gameCursor;
but for some reason this exception jumps when im running the program.
the .cur file has been added to the project and marked as a resource.
any ideas?

WPF Class-loading Error? Crashes on addition of custom class

Popup
An unhandled exception of type 'System.IO.IOException' occurred in
PresentationFramework.dll
Additional information: Cannot locate resource 'mainwindow.xaml'.
Output Log
'markless.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'
...
'markless.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework\v4.0_4.0.0.0__31bf3856ad364e35\PresentationFramework.dll'
The thread 'vshost.NotifyLoad' (0x6b0) has exited with code 0 (0x0).
The thread 'vshost.LoadReference' (0x1fa8) has exited with code 0 (0x0).
'markless.vshost.exe' (Managed (v4.0.30319)): Loaded 'T:\#_\Programming\GitHub\markless\src\win2\markless\bin\Debug\markless.exe', Symbols loaded.
Step into: Stepping over method without symbols 'markless.App.App'
'markless.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll'
A first chance exception of type 'System.IO.IOException' occurred in PresentationFramework.dll
An unhandled exception of type 'System.IO.IOException' occurred in PresentationFramework.dll
Additional information: Cannot locate resource 'mainwindow.xaml'.
The program '[6268] markless.vshost.exe: Program Trace' has exited with code 0 (0x0).
The program '[6268] markless.vshost.exe: Managed (v4.0.30319)' has exited with code 0 (0x0).
This happens every time I try to add a C# class to my project. It's WPF, and when I start a new project, it'll run fine with just the window. The minute I try to add actual functionality to the application, it blows up on me like this. (Oh, it builds, it builds fair enough - this is a runtime error.) Even if I then remove the class, the application will still not run correctly. Wat do?
Any help is appreciated.
There are many ways of going forward, but only one way of standing still. - FDR
EDIT:
If you want to check out the repo, it's right here.
Additional information: Cannot locate resource 'mainwindow.xaml'.
Your App.xaml:
<Application x:Class="markless.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
The problem is not the adding of any classes but the removal/renaming of the MainWindow which is still referenced here.

Adding datatemplate to listbox and panorama items form program in windows phone 7

I am adding panorama items to panorama controls dynamically, they are adding successfully without any issues
but when i try to add the listbox to panorama item its giving error. I am not able to see the exception also, application automatically closing and I am seeing emulator home screen after that.
Following is my code which I've written to create panorama item and list box
lstAnniversaries = new ListBox()
lstAnniversaries.Width = 420;
lstAnniversaries.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
lstAnniversaries.Foreground = new SolidColorBrush(FacebookQueries.GetColorFromHexString("#000000"));
lstAnniversaries.Background = new SolidColorBrush(FacebookQueries.GetColorFromHexString("#ffffff"));
lstAnniversaries.Tap += new EventHandler<System.Windows.Input.GestureEventArgs>(lstUpcoming_Tap);
lstAnniversaries.ItemTemplate = (DataTemplate)XamlReader.Load(#"<DataTemplate xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"">
<Grid Height=""100"" Margin=""0,0,0,0"">
<Grid.ColumnDefinitions>
<ColumnDefinition Width=""90"" />
<ColumnDefinition Width=""210"" />
<ColumnDefinition Width=""*"" />
</Grid.ColumnDefinitions>
<Image Source=""{Binding ImageSource}"" Height=""90"" Width=""90"" Margin=""0,0,11,0"" />
<StackPanel Grid.Column=""1"" Margin=""0,10,0,0"">
<TextBlock Text=""{Binding NameSource}"" Style=""{StaticResource ProfileNameStyleForTextBlock}"" />
<StackPanel Orientation=""Horizontal"" Margin=""0,-2,0,0"">
<TextBlock Text=""{Binding EventName}"" Foreground=""#000000"" Style=""{StaticResource EventNameStyleForTextBlock}"" />
<TextBlock Text=""{Binding EventDate}"" Foreground=""{Binding EventColor}"" Style=""{StaticResource EventDateStyleForTextBlock}"" />
</StackPanel>
</StackPanel>
<Button VerticalAlignment=""Center"" Height=""Auto"" Name=""btnAnniversary"" Width=""75"" Margin=""5,0,0,0"" HorizontalAlignment=""Left"" Visibility=""{Binding EllipseStatus}"" Tag=""{Binding BindsDirectlyToSource=True}"" Click=""btnAnniversary_Click"" Canvas.ZIndex=""1"" Grid.Column=""2"">
<Image Source=""/GiftGiv;component/Assets/bubble.png"" />
</Button>
</Grid>
</DataTemplate>");
pan_anniversaries = new PanoramaItem();
pan_anniversaries.HeaderTemplate = (DataTemplate)XamlReader.Load(#"<DataTemplate xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""><TextBlock Text=""anniversaries"" FontSize=""54"" Foreground=""Black"" Margin=""-10,0,0,0""></TextBlock></DataTemplate>");
Grid grd = new Grid();
grd.Children.Add(lstAnniversaries);
pan_anniversaries.Content = grd;
PanoramaControl.Items.Add(pan_anniversaries);
EDIT:
Output windows Text
A first chance exception of type 'System.InvalidOperationException' occurred in System.Core.dll
A first chance exception of type 'System.InvalidOperationException' occurred in System.Core.dll
Step into: Stepping over method without symbols 'System.Reflection.RuntimeMethodInfo.InternalInvoke'
Step into: Stepping over method without symbols 'System.Reflection.MethodBase.Invoke'
Step into: Stepping over method without symbols 'System.Delegate.DynamicInvokeOne'
Step into: Stepping over method without symbols 'System.MulticastDelegate.DynamicInvokeImpl'
Step into: Stepping over method without symbols 'System.Delegate.DynamicInvoke'
Step into: Stepping over method without symbols 'System.Windows.Threading.DispatcherOperation.Invoke'
Step into: Stepping over method without symbols 'System.Windows.Threading.Dispatcher.Dispatch'
Step into: Stepping over method without symbols 'System.Windows.Threading.Dispatcher.OnInvoke'
Step into: Stepping over method without symbols 'System.Windows.Hosting.CallbackCookie.Invoke'
Step into: Stepping over method without symbols 'System.Windows.Hosting.DelegateWrapper.InternalInvoke'
Step into: Stepping over method without symbols 'System.Windows.RuntimeHost.ManagedHost.InvokeDelegate'
A first chance exception of type 'System.Exception' occurred in System.Windows.dll
A first chance exception of type 'MS.Internal.WrappedException' occurred in System.Windows.dll
A first chance exception of type 'MS.Internal.WrappedException' occurred in System.Windows.dll
A first chance exception of type 'MS.Internal.WrappedException' occurred in System.Windows.dll
A first chance exception of type 'MS.Internal.WrappedException' occurred in System.Windows.dll
A first chance exception of type 'MS.Internal.WrappedException' occurred in System.Windows.dll
A first chance exception of type 'System.Exception' occurred in System.Windows.dll
A first chance exception of type 'MS.Internal.WrappedException' occurred in System.Windows.dll
A first chance exception of type 'MS.Internal.WrappedException' occurred in System.Windows.dll
A first chance exception of type 'MS.Internal.WrappedException' occurred in System.Windows.dll
A first chance exception of type 'MS.Internal.WrappedException' occurred in System.Windows.dll
A first chance exception of type 'MS.Internal.WrappedException' occurred in System.Windows.dll
The thread '<No Name>' (0xf640c32) has exited with code 0 (0x0).
The thread '<No Name>' (0xf450ca6) has exited with code 0 (0x0).
The thread '<No Name>' (0xf050d2e) has exited with code 0 (0x0).
The thread '<No Name>' (0xf820cda) has exited with code 0 (0x0).
The thread '<No Name>' (0xecb0e52) has exited with code 0 (0x0).
Instead of creating DataTemplates in code file, add DataTemplate code in resources section of Page or APP.
Use following way will resolve the problem as #igrali mentioned in the comments
lstAnniversaries.ItemTemplate = this.Resources["AnniversariesTemplate"] as DataTemplate;
lstAnniversaries.Style = this.Resources["EventsListStyle"] as Style;

How to make non-Localizable SplashScreen in WPF

I'm just adding internationalization to my next WPF application, and have followed the instructions here.
I then noticed that there would be a fair amount of duplication in the satellite DLL, so marked the images that won't be localized in the .csproj as
<Localizable>False</Localizable>
Unfortunately, one of my resources is used in a SplashScreen thus:
SplashScreen ss = new SplashScreen("Images/splash.png");
ss.Show(false);
And this throws an exception when the Show call is executed. Here's the exception output
A first chance exception of type 'System.IO.IOException' occurred in WindowsBase.dll
A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll
Step into: Stepping over method without symbols 'System.RuntimeType.CreateInstanceImpl'
A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll
Step into: Stepping over method without symbols 'MS.Internal.Xaml.Runtime.ClrObjectRuntime.CreateInstance'
A first chance exception of type 'System.Xaml.XamlObjectWriterException' occurred in System.Xaml.dll
Step into: Stepping over method without symbols 'System.Windows.Markup.WpfXamlLoader.Load'
A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll
Additional information: 'The invocation of the constructor on type 'MainWindow' that matches the specified binding constraints threw an exception.' Line number '4' and line position '9'.
When I remove the False line it works again.
Is there any way to load the resource I want, which is stored in test.unlocalizable.g.resources?

Resources