我想使用this article从WPF应用程序向Windows 10中的Action Center创建简单的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 ,因此会发生此错误。
答案 0 :(得分:5)
在更新到Windows 10的2019年5月版时,目录C:\WINDOWS\SysWOW64\WinMetadata
被删除,这是Visual Studio 2017和2019在其中查找所有文件的地方。
有两种解决方法:
1。。在引用管理器中单击浏览,然后从C:\WINDOWS\System32\WinMetadata
中选择您的引用。
2。。将 WinMetadata 文件夹从C:\WINDOWS\System32\WinMetadata
复制到C:\WINDOWS\SysWOW64\WinMetadata
。然后重新打开参考管理器。
答案 1 :(得分:2)
对于我来说,我单击浏览并使用此路径%windir%\ Sysnative \ WinMetadata ,它对我有用。 Windows 10 1903 \ VS 17
答案 2 :(得分:0)
我已转载您的问题。节点<TargetPlatformVersion>
应该在现有节点<TargetFrameworkVersion>
节点之下。
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetPlatformVersion>10.0.10240.0</TargetPlatformVersion>
但是在项目文件中有单独的PropertyGroup
带有此节点。
答案 3 :(得分:0)
Visual Studio无法访问C:\ Windows \ System32 \ WinMetadata目录以在Windows 1903上加载Windows SDK。
因此从Windows 1903降级到1803解决了此问题。
我已经在visual studio developer community page上报告了此问题。
答案 4 :(得分:0)
Windows 1903:
将WinMetadata文件夹从(隐藏文件夹)C:\ WINDOWS \ sysnative \ WinMetadata复制到C:\ WINDOWS \ SysWOW64 \ WinMetadata。
重新打开参考管理器。
答案 5 :(得分:0)
Windows 1903(OS Build 18362.900)上似乎不存在%windir%\ Sysnative \ WinMetadata文件夹。
我的解决方法是在%windir%\ System32 \ WinMetadata中创建所需文件的本地副本(例如,在解决方案中的lib文件夹下),然后从那里引用它们。
就我而言,这就是我持有Windows.Data.winmd和Windows.UI.winmd文件的方式(在NuGet上找不到它们)。