[英]No references were found in the windows sdk (Windows 1903)
我想使用本文從 WPF 應用程序創建到 Windows 10 操作中心的簡單 Toast 通知。
但是我在第 2 步遇到了問題:
右鍵單擊項目 => 添加 => 引用... => Windows => 核心
我檢查的內容:
這是我的 csproj 文件:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{A5A389ED-4BBB-4EF4-A8A4-45DD3D0AF9AE}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>WpfApp3</RootNamespace>
<AssemblyName>WpfApp3</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetPlatformVersion>10.0.10240.0</TargetPlatformVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<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' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<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.Data" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<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="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</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>
</EmbeddedResource>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
更新到Windows 1903后出現這個錯誤,因為Visual Studio無法訪問C:\\Windows\\System32\\WinMetadata
在更新到 2019 年 5 月版的 Windows 10 時,目錄C:\\WINDOWS\\SysWOW64\\WinMetadata
被刪除,這是 Visual Studio 2017 和 2019 正在尋找所有文件的地方。
有2種方法可以解決這個問題:
1.單擊參考管理器中的瀏覽並從C:\\WINDOWS\\System32\\WinMetadata
選擇您的參考。
2.將WinMetadata文件夾從C:\\WINDOWS\\System32\\WinMetadata
到C:\\WINDOWS\\SysWOW64\\WinMetadata
。 然后重新打開參考管理器。
對我來說,我點擊了瀏覽並使用了這個路徑%windir%\\Sysnative\\WinMetadata並且它對我有用。 視窗 10 1903 \\ VS 17
我已經重現了你的問題。 節點<TargetPlatformVersion>
應位於現有節點<TargetFrameworkVersion>
節點之下。
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetPlatformVersion>10.0.10240.0</TargetPlatformVersion>
但是在您的項目文件中,此節點有單獨的PropertyGroup
。
Visual Studio 無法訪問 C:\\Windows\\System32\\WinMetadata 目錄以在 Windows 1903 上加載 Windows SDK。
所以從 Windows 1903 降級到 1803 解決了這個問題。
我已在Visual Studio 開發人員社區頁面上報告了此問題。
視窗 1903:
將 WinMetadata 文件夾從(隱藏文件夾)C:\\WINDOWS\\sysnative\\WinMetadata 復制到 C:\\WINDOWS\\SysWOW64\\WinMetadata。
重新打開參考管理器。
文件夾 %windir%\\Sysnative\\WinMetadata 在我的 Windows 1903 (OS Build 18362.900) 上似乎不存在。
我的解決方法是在 %windir%\\System32\\WinMetadata 中制作所需文件的本地副本(例如在您的解決方案中的 lib 文件夾下)並從那里引用它們。
就我而言,這就是我獲取 Windows.Data.winmd 和 Windows.UI.winmd 文件的方式(在 NuGet 上找不到它們)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.