我正在为WPF和Windows 10开发一个库。但是在后者上编译时遇到了一些问题。下面是一些代码:
project.json
{
"frameworks": {
"net46": {
"frameworkAssemblies": {
"WindowsBase": "4.0.0.0"
}
},
"netcore50": {
"dependencies": {
"Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0"
}
}
}
}
Dependency.cs
using System;
using System.Collections.Generic;
#if NET46
using System.Windows; // .NET Framework 4.6
#elif NETCORE50
using Windows.UI.Xaml; // Windows 10 apps
#endif
public static class Dependency
{
public static DependencyProperty Register<T, TOwner>(string name, PropertyChangedCallback<T, TOwner> callback)
where TOwner : DependencyObject
{
// Code here....
}
}
虽然这段代码可以在传统的.NET Framework中编译成功,但我在尝试将其应用于Windows 10应用程序所使用的netcore50时遇到了问题。出现的原因似乎是像DependencyProperty或DependencyObject这样的类型没有包含在该配置中。
是否有适用于netcore50的NuGet包可供安装,其中包含这些类型,以便我可以从我的库中使用它们?
谢谢您的帮助。
编辑:我刚刚在VS中输入了DependencyProperty并按下F12。它似乎是存在于Windows.Foundation.UniversalApiContract程序集中,但在NuGet上没有这样的包。
Microsoft.Win32.Registry
这样的包。 - James Ko