c# - .NET Core 库旁边的 Windows 窗体 GUI 可能吗?

标签 c# .net

<分区>

我有一些用 .NET Core 编写的库

我可以在 Windows 窗体应用程序中使用这些库吗?

我可以将它们引用到我的 Win Forms 或 WPF 中吗?

一般情况下,我可以在 .NET Core 旁边使用 .NET Framework 吗?

因为我想迁移到 .NET Core,但我的项目也需要 GUI,而目前 .NET Core 不支持它

@JonSkeet 问我你测试了吗? 是的,我用我的 WinForm GUI 测试了一个非常简单的 dotNETCore

在 dotNET 核心中

public class Person
{
    [EmailAddress]
    public string Name { get; set; }
}

public static class TestCore
{
    public static string Get()
    {
        var type = typeof(Person).GetProperty("Name");
        var attr = type.Attributes;
        return attr.ToString();
    }
}

我使用反射是因为其中的反射命名空间发生了变化

所以我通过单击按钮在我的 GUI 中调用 Get() 方法。但是告诉我一个错误

Additional information: Could not load file or assembly 'System.Runtime, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

我将该库添加到我的 winform 项目中,然后 booooooom !!! 现在我的 Winform 项目不工作了!!!

enter image description here

Warning RCS1060 Consider declaring each type in separate file.  dotNETCore..NETStandard,Version=v1.5    \visual studio 2015\Projects\dotNETCore\src\dotNETCore\Person.cs

Error   CS0433  The type 'EditorBrowsableAttribute' exists in both 'System.Runtime, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'  WindowsFormsApplication1    \visual studio 2015\Projects\dotNETCore\WindowsFormsApplication1\Properties\Resources.Designer.cs

似乎出了点问题,但我希望我可以同时使用 .NET Framework 和 dotNET Core,因为我们还没有任何 GUI 解决方案!

我希望 MICROSOFT 致力于 .NET Core 版本的 WPF。

最佳答案

Microsoft 已开始为 Net Core 制作 Winforms 插件 https://github.com/dotnet/winforms ..

值得注意的问题是 Net Core Winforms 还没有设计器支持(目前),因此您可能不得不暂时推迟完全迁移到 Net Core!

关于c# - .NET Core 库旁边的 Windows 窗体 GUI 可能吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37282066/

相关文章:

c# - 为什么 Process.Start ("cmd.exe", process);不行?

c# - App.Config 更改值

c# - ProtectedMemory - 如何保证字节数组的大小是16的倍数?

c# - 类不包含采用 0 个参数的构造函数

c# - 从另一个 WCF 服务中调用 WCF 服务时发生 WCF 内存泄漏

c# - MSTest期间的终结器中的NullReferenceException

c# - 接口(interface)接口(interface) <T> : T

c# - 从 ProcessThreadCollection 按名称获取正在运行的线程

c# - 尝试使用来自第三方 WSDL 的故障元素在 VS2013 中创建服务引用时出错

c# - 从 TTF 字体流创建 GlyphTypeface 对象