2011-04-19 62 views
0

警告1父文件,「Window1.xaml」,文件」 ........ \ Window1.xaml.cs'不能在項目文件中找到。 WpfApplication1爲什麼我得到這樣的警告cs文件不能在項目文件中找到

爲什麼會這樣?

編輯:開幕wpfapplication1.csproj文件:

<?xml version="1.0" encoding="utf-8"?> 
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> 
    <PropertyGroup> 
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> 
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> 
    <ProductVersion>9.0.21022</ProductVersion> 
    <SchemaVersion>2.0</SchemaVersion> 
    <ProjectGuid>{1656975F-4108-4386-80CB-00176DF48895}</ProjectGuid> 
    <OutputType>WinExe</OutputType> 
    <AppDesignerFolder>Properties</AppDesignerFolder> 
    <RootNamespace>WpfApplication1</RootNamespace> 
    <AssemblyName>WpfApplication1</AssemblyName> 
    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> 
    <FileAlignment>512</FileAlignment> 
    <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> 
    <WarningLevel>4</WarningLevel> 
    </PropertyGroup> 
    <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> 
    <DebugSymbols>true</DebugSymbols> 
    <DebugType>full</DebugType> 
    <Optimize>false</Optimize> 
    <OutputPath>bin\Debug\</OutputPath> 
    <DefineConstants>DEBUG;TRACE</DefineConstants> 
    <ErrorReport>prompt</ErrorReport> 
    <WarningLevel>4</WarningLevel> 
    </PropertyGroup> 
    <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> 
    <DebugType>pdbonly</DebugType> 
    <Optimize>true</Optimize> 
    <OutputPath>bin\Release\</OutputPath> 
    <DefineConstants>TRACE</DefineConstants> 
    <ErrorReport>prompt</ErrorReport> 
    <WarningLevel>4</WarningLevel> 
    </PropertyGroup> 
    <ItemGroup> 
    <Reference Include="System" /> 
    <Reference Include="System.Core"> 
     <RequiredTargetFramework>3.5</RequiredTargetFramework> 
    </Reference> 
    <Reference Include="System.Windows.Forms" /> 
    <Reference Include="System.Xml.Linq"> 
     <RequiredTargetFramework>3.5</RequiredTargetFramework> 
    </Reference> 
    <Reference Include="System.Data.DataSetExtensions"> 
     <RequiredTargetFramework>3.5</RequiredTargetFramework> 
    </Reference> 
    <Reference Include="System.Data" /> 
    <Reference Include="System.Xml" /> 
    <Reference Include="WindowsBase" /> 
    <Reference Include="PresentationCore" /> 
    <Reference Include="PresentationFramework" /> 
    </ItemGroup> 
    <ItemGroup> 
    <ApplicationDefinition Include="App.xaml"> 
     <Generator>MSBuild:Compile</Generator> 
     <SubType>Designer</SubType> 
    </ApplicationDefinition> 
    <Page Include="Window1.xaml"> 
     <Generator>MSBuild:Compile</Generator> 
     <SubType>Designer</SubType> 
    </Page> 
    <Compile Include="App.xaml.cs"> 
     <DependentUpon>App.xaml</DependentUpon> 
     <SubType>Code</SubType> 
    </Compile> 
    <Compile Include="..\..\..\..\Window1.xaml.cs"> 
     <DependentUpon>Window1.xaml</DependentUpon> 
     <SubType>Code</SubType> 
     <Link>Window1.xaml.cs</Link> 
    </Compile> 
    </ItemGroup> 
    <ItemGroup> 
    <Compile Include="Properties\AssemblyInfo.cs"> 
     <SubType>Code</SubType> 
    </Compile> 
    <Compile Include="Properties\Resources.Designer.cs"> 
     <AutoGen>True</AutoGen> 
     <DesignTime>True</DesignTime> 
     <DependentUpon>Resources.resx</DependentUpon> 
    </Compile> 
    <Compile Include="Properties\Settings.Designer.cs"> 
     <AutoGen>True</AutoGen> 
     <DependentUpon>Settings.settings</DependentUpon> 
     <DesignTimeSharedInput>True</DesignTimeSharedInput> 
    </Compile> 
    <EmbeddedResource Include="Properties\Resources.resx"> 
     <Generator>ResXFileCodeGenerator</Generator> 
     <LastGenOutput>Resources.Designer.cs</LastGenOutput> 
     <SubType>Designer</SubType> 
    </EmbeddedResource> 
    <None Include="Properties\Settings.settings"> 
     <Generator>SettingsSingleFileGenerator</Generator> 
     <LastGenOutput>Settings.Designer.cs</LastGenOutput> 
    </None> 
    <AppDesigner Include="Properties\" /> 
    </ItemGroup> 
    <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 
    <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
     Other similar extension points exist, see Microsoft.Common.targets. 
    <Target Name="BeforeBuild"> 
    </Target> 
    <Target Name="AfterBuild"> 
    </Target> 
    --> 
</Project> 

您是如何在這裏分析的文件路徑?我真的不明白

回答

0

如果您在文本編輯器中檢查WpfApplication1.csproj文件,它應該有一個Window1.xaml和Window1.xaml.cs文件的條目。

你必須確保XAML和CS文件是在項目文件認爲他們是。

+0

喜dythim,請參閱編輯 – jeremychan 2011-04-19 02:59:23

+0

好吧,該的csproj文件是在特定目錄,也許像'C:\ Visual Studio的XXXX \ Projects \ WpfApplication1 \',並且所有文件都將相對於該目錄。 '..'表示'當前目錄的父目錄' - 它正在尋找與wpfapplication1.csproj相同的目錄中的文件「Window1.xaml」,它正在尋找'「Window1.xaml.cs」 '在目錄** 4 **目錄上面。那有意義嗎? – dythim 2011-04-20 17:34:24

0

嘗試改變路徑ItemGroup\Compile的文件Window1.xaml.cs

<ItemGroup> 
    .... 
    <Compile Include="Window1.xaml.cs"> <!--Changed path--> 
     <DependentUpon>Window1.xaml</DependentUpon> 
     <SubType>Code</SubType> 
     <Link>Window1.xaml.cs</Link> 
    </Compile> 
</ItemGroup> 
相關問題