Cannot find "app.xaml", IOException until app.xaml is modified

I basically have the same problem as this (unanswered) question: IOException was unhandled - could not find the app.xaml resource

When I open my project in Visual Studio 2010 and start debugging, I get: "IOException was unhandled: could not find app.xaml resource". Solution recovery does NOT work, I need to somehow modify the app.xaml file (for example, add an empty line) in order to successfully complete my project.

Additional Information:

  • My solution consists of two projects: My main (WPF) and a test project.
  • I read about problems if the solution was converted from Visual Studio 2005. This is not my business. My project was originally created using Visual Studio 2010. Perhaps (I don’t exactly remind you) it was once aimed at .Net Framework 3.5 or .Net Framework 4.0 Client Profile, but currently it is configured to work with .Net Framework 4.0
  • Both projects have different names, if that matters. The first is called MyApplicationName (assembly name and default namespace) and the second name is MyApplicationName.Test (assembly name and default namespace).
  • Most of the classes in my main project are internal (including View classes), but my App class is public.
  • The main project exposes its internal components to a test project (using [assembly: InternalsVisibleTo("MyOtherProject")] )
  • I am using MVVM (with MVVM Light) but I am not using ViewModel 'resolver' / container / bootstrapper / MEF or related things. I just map my ViewModels to their respective views using DataTemplates and create my ViewModels manually (if that matters).
  • My App.xaml includes the other three xaml resource files. Here I add my App.xaml:

     <Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="Resources/StyleDictionary.xaml" /> <ResourceDictionary Source="Resources/CommonResources.xaml" /> <ResourceDictionary Source="Resources/ViewModelMappings.xaml" /> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Application.Resources> 

  • I override the OnStartup method from my App class to manually handle the startup logic, if that matters. I also wrote a static constructor to initialize the DispatcherHelper from MVVM Light:

      public partial class App : Application { static App() { GalaSoft.MvvmLight.Threading.DispatcherHelper.Initialize(); } ... } 

Any help would be appreciated. If you need more information, let me know.

+4
source share
2 answers

I don't know if this is the final solution, but it seems to work so far:

  • Open csproj file with Notepad
  • Search App.xaml and App.xaml.cs. Make sure that every link to this file has the same case. These files were called App.xaml and App.xaml.cs, so I left such links.

I used to have something like this:

 <Compile Include="app.xaml.cs"> <DependentUpon>App.xaml</DependentUpon> <SubType>Code</SubType> </Compile> 

So, I changed it, and now this:

 <Compile Include="app.xaml.cs"> <DependentUpon>App.xaml</DependentUpon> <SubType>Code</SubType> </Compile> 

Another thing I did was to find BootstrapperPackage and remove old versions of the .Net Framework, although I don't think it is a good idea if your project uses libraries that depend on older versions of .Net. I am not sure if this was causing the problem either.

0
source

Such things can happen when the project’s target structure changes. You can recreate projects as new applications that target .NET from the beginning and add all your code files as existing elements.

Another thing that comes to mind is the shell of the app.xaml file name. It may be case sensitive in some contexts and not case sensitive in others, so what were you trying to change this? On my system, the default is App.xaml. Since the error message is app.xaml, it may be worth trying a sensitive search of the project files using a text editor and changing all occurrences of the name in App.xaml.

0
source

All Articles