找不到'的App.xaml“,IOException异常,直到修改的App.xaml [英] Cannot locate 'app.xaml', IOException until modifying app.xaml

查看:311
本文介绍了找不到'的App.xaml“,IOException异常,直到修改的App.xaml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上我有同样的问题,因为这(解答)问题:的 IOException异常是未处理的 - 无法找到资源的App.xaml

Basically I'm having the same issue as this (unanswered) question: IOException was unhandled - Cannot locate resource app.xaml

当我在Visual Studio 2010中打开我的项目,并开始调试,我得到IOException异常是未处理:找不到资源的App.xaml。重建解决方案不工作,我必须以某种方式修改我的App.xaml文件(添加一个空行,例如)为了成功运行我的项目。

When I open my project in Visual Studio 2010 and start debugging, I get "IOException was unhandled: Cannot locate resource app.xaml". Rebuilding the solution DOES NOT work, I have to somehow modify my app.xaml file (adding an empty line, for example) in order to run my project successfully.

其他详细信息:


  • 我的解决方案包括两个项目:我的主要(WPF)应用程序和测试项目

  • 我看了一下问题如果解决方案从Visual Studio 2005中这是不会我的情况下进行转换。我的项目最初是用Visual Studio 2010中创建也许(我不提醒精确地)它在某个时候.NET Framework 3.5或.Net框架4.0客户端配置文件为对象,但当前配置了框架4.0
  • 这两个项目具有不同的名称,如果该事项。首先是所谓的MyApplicationName(集名称和默认命名空间)和第二MyApplicationName.Test(集名称和默认命名空间太)

  • 中的大多数类我的主要项目有内部(包括视图类),但我的App类是公共

  • 主要项目公开其内部组件测试项目(使用 [汇编:InternalsVisibleTo(MyOtherProject)]

  • 我使用MVVM(与MVVM光),但我不使用视图模型解析/集装箱/引导程序/ MEF或相关的东西。我只是用我的DataTemplates映射的ViewModels各自的意见和手动创建我的ViewModels(如果该事项)。

  • 我的App.xaml包括其他三个XAML资源文件。我在这里有我的App.xaml:

  • My solution consists of two projects: My main (WPF) application and a test project.
  • I have read about issues if the solution was converted from Visual Studio 2005. This is not my case. My project was originally created with Visual Studio 2010. Maybe (I don't remind exactly) it was sometime targetted at .Net Framework 3.5 or .Net Framework 4.0 Client Profile, but it currently 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 MyApplicationName.Test (assembly name and default namespace too)
  • Most classes in my main project are internal (including the View classes), but my App class is public
  • The main project exposes its internal components to the test project (using [assembly: InternalsVisibleTo("MyOtherProject")])
  • I'm using MVVM (with MVVM Light), but I'm not using a 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 other three xaml resource files. I include my App.xaml here:

<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>



我重写从我的App类OnStartup方法来手动处理的启动逻辑,如果该事项。我也写了一个静态构造函数没有初始化从MVVM点燃DispatcherHelper:

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

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


任何帮助将不胜感激。如果您需要更多的详细信息,请告诉我。

Any help will be appreciated. If you need more details, please tell me.

推荐答案

我不知道这是否是一个明确的解决办法,但似乎到目前为止,是工作的:

I don't know if this is a definitive solution, but it seems to be working so far:


  1. 用记事本打开您的csproj文件

  2. 搜索App.xaml中和App.xaml.cs.确保该文件中的每个引用具有相同的情况。这些文件被称为的App.xaml和App.xaml.cs,所以我离开喜欢的引用。

以前我有这样的事情这样的:

Previously I had something like this:

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



所以,我修改了它,现在它是:

So I modified it and now it is:

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



我做的另一件事就是找BootstrapperPackage,并从那里取出.NET Framework的旧版本,虽然我不认为这是一个好主意,如果你的项目使用依赖于旧版本的.NET库。我不知道这是太导致的问题。

Another thing I did was look for BootstrapperPackage and remove the old versions of .Net Framework from there, though I don't think that's a good idea if your project uses libraries that depend on old versions of .Net. I'm not sure that was causing the problem too.

这篇关于找不到'的App.xaml“,IOException异常,直到修改的App.xaml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆