简体   繁体   English

在 windows sdk (Windows 1903) 中找不到参考

[英]No references were found in the windows sdk (Windows 1903)

I want to create simple toast notification to action center in windows 10 from a WPF app using this article .我想使用本文从 WPF 应用程序创建到 Windows 10 操作中心的简单 Toast 通知。

But I got problem on Step 2:但是我在第 2 步遇到了问题:

Right click on the project => Add => Reference... => Windows => Core右键单击项目 => 添加 => 引用... => Windows => 核心

在此处输入图片说明

What I checked:我检查的内容:

  • Windows 10 SDK Installation: Windows 10 SDK 安装: 在此处输入图片说明
  • Same issue with a WPF project WPF 项目的相同问题

And this is my csproj file:这是我的 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>

This error occurs after the update to Windows 1903, because Visual studio can not access C:\\Windows\\System32\\WinMetadata更新到Windows 1903后出现这个错误,因为Visual Studio无法访问C:\\Windows\\System32\\WinMetadata

On updating to the May 2019 release of Windows 10 the directory C:\\WINDOWS\\SysWOW64\\WinMetadata is removed and this is where Visual Studio is 2017 and 2019 is looking for all of the files.在更新到 2019 年 5 月版的 Windows 10 时,目录C:\\WINDOWS\\SysWOW64\\WinMetadata被删除,这是 Visual Studio 2017 和 2019 正在寻找所有文件的地方。

There is 2 way to solve this:有2种方法可以解决这个问题:

1. Click Browse in reference manager and chose your reference from C:\\WINDOWS\\System32\\WinMetadata . 1.单击参考管理器中的浏览并从C:\\WINDOWS\\System32\\WinMetadata选择您的参考。

2. Copy WinMetadata folder from C:\\WINDOWS\\System32\\WinMetadata to C:\\WINDOWS\\SysWOW64\\WinMetadata . 2.WinMetadata文件夹从C:\\WINDOWS\\System32\\WinMetadataC:\\WINDOWS\\SysWOW64\\WinMetadata and then re-open reference manager.然后重新打开参考管理器。

Looks like the parent bug is documented at https://developercommunity.visualstudio.com/content/problem/446490/visual-studio-cant-see-winmetadatadirectory-in-cwi.html看起来父错误记录在https://developercommunity.visualstudio.com/content/problem/446490/visual-studio-cant-see-winmetadatadirectory-in-cwi.html

For me I clicked browse and used this path %windir%\\Sysnative\\WinMetadata and it worked for me.对我来说,我点击了浏览并使用了这个路径%windir%\\Sysnative\\WinMetadata并且它对我有用 Windows 10 1903 \\ VS 17视窗 10 1903 \\ VS 17

I've reproduced your issue.我已经重现了你的问题。 The node <TargetPlatformVersion> should be below the existing node <TargetFrameworkVersion> node.节点<TargetPlatformVersion>应位于现有节点<TargetFrameworkVersion>节点之下。

<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetPlatformVersion>10.0.10240.0</TargetPlatformVersion>

But there is the separate PropertyGroup with this node in your project file.但是在您的项目文件中,此节点有单独的PropertyGroup

Visual Studio can not access the C:\\Windows\\System32\\WinMetadata directory to load the windows SDK on Windows 1903. Visual Studio 无法访问 C:\\Windows\\System32\\WinMetadata 目录以在 Windows 1903 上加载 Windows SDK。

So a downgrade from windows 1903 to 1803 solved this issue.所以从 Windows 1903 降级到 1803 解决了这个问题。

I have reported this problem on the visual studio developer community page .我已在Visual Studio 开发人员社区页面上报告了此问题。

Windows 1903:视窗 1903:

Copy WinMetadata folder from (hidden folder) C:\\WINDOWS\\sysnative\\WinMetadata to C:\\WINDOWS\\SysWOW64\\WinMetadata.将 WinMetadata 文件夹从(隐藏文件夹)C:\\WINDOWS\\sysnative\\WinMetadata 复制到 C:\\WINDOWS\\SysWOW64\\WinMetadata。

Re-open reference manager.重新打开参考管理器。

​The folder %windir%\\Sysnative\\WinMetadata does not seem to exist on my Windows 1903 (OS Build 18362.900).文件夹 %windir%\\Sysnative\\WinMetadata 在我的 Windows 1903 (OS Build 18362.900) 上似乎不存在。

My workaround was to make a local copy of the required files in %windir%\\System32\\WinMetadata (eg under a lib folder in your solution) and reference them from there.我的解决方法是在 %windir%\\System32\\WinMetadata 中制作所需文件的本地副本(例如在您的解决方案中的 lib 文件夹下)并从那里引用它们。

In my case, this is how I got a hold of the Windows.Data.winmd and Windows.UI.winmd files (couldn't find them on NuGet).就我而言,这就是我获取 Windows.Data.winmd 和 Windows.UI.winmd 文件的方式(在 NuGet 上找不到它们)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM