3

I have some libraries that was written in .NET Core

Can I use these libraries in Windows Form Application ?

Can I reference them to my Win Forms or WPF ?

In general Can I use .NET Framework beside .NET Core ?

because I want to migrate to .NET Core but I need GUI for my Projects too and currently .NET Core does not support it

@JonSkeet ask me Do you test it ? Yes I test a very simple dotNETCore with my WinForm GUI

in dotNET Core

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();
    }
}

I use reflection because Reflection namespace changed in it

so I call Get() method in my GUI with button click. but show me an error

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.

I added that library into my winform project and booooooom !!! Now my Winform project does not work !!!

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

seems something is wrong but I hope that I can use .NET Framework and dotNET Core together because we dont have any GUI solution yet !

I hope MICROSOFT work on .NET Core version of WPF.

HamedFathi
  • 3,667
  • 5
  • 32
  • 72
  • 1
    Yes, I'd expect it to be fine - have you tried it? Generally speaking, full .NET apps can consume .NET Core libraries, but not vice versa. – Jon Skeet May 17 '16 at 16:49
  • @JonSkeet please see my post again I edited it ! – HamedFathi May 17 '16 at 17:07
  • 2
    "Now my Winform project does not work" doesn't give us much in the way of information... we also don't know how you're building any of this. Is *all* the code using dotnet CLI / dnx? (You can build full .NET projects that way, for example.) – Jon Skeet May 17 '16 at 17:09
  • @JonSkeet first I added a project with template of .NET Core rc2 that is installed with DotNetCore.1.0.0.RC2-VS2015Tools.Preview1 in my VS2015 then I added a win form project into current solution.after these steps I refrenced my dotNETCore library in my winform and call my method. when I ran application show me above error so I referenced it and then my winform project does not works any way. – HamedFathi May 17 '16 at 17:13
  • You still haven't shown how it's not working though. We don't even know whether it doesn't compile, or whether you're getting an exception... – Jon Skeet May 17 '16 at 17:16
  • @JonSkeet you right, see my post again please – HamedFathi May 17 '16 at 17:22
  • 1
    So you've got compilation errors - those should be shown *as text* in the question. There's no need for all these screenshots, which are *much* harder to read than plain text. – Jon Skeet May 17 '16 at 17:24
  • 3
    .NETCore projects target a completely different version of the CLR. You cannot mix CLR versions in one project, there can only be one. – Hans Passant May 17 '16 at 17:34
  • You can use some packages that target .NET platform standard but not all, and in most cases you need to be using .NET Framework 4.6.0 and above. – Lex Li May 18 '16 at 03:55
  • In the last Microsoft Build event they announce news about .NET Core 3. _"The highlight of .NET Core 3 is support for Windows desktop applications, specifically Windows Forms, Windows Presentation Framework (WPF), and UWP XAML."_ You can see more about it [here](https://blogs.msdn.microsoft.com/dotnet/2018/05/07/net-core-3-and-support-for-windows-desktop-applications/) – Rui Fernandes Aug 13 '18 at 08:48

1 Answers1

1

Microsoft have started producing a Winforms addon for Net Core https://github.com/dotnet/winforms ..

The notable problems are that Net Core Winforms doesnt have designer support (yet) so you might have to hold off on the full move to Net Core for now!

Robert Perry
  • 1,906
  • 1
  • 14
  • 14
  • Can you point me to the references that state its not supported? or to back up your claims that its "a good way into a complete disaster"? – Robert Perry Feb 06 '19 at 15:50
  • 1
    Hans with his mere 788,541 reputation? What would he know! :-D - Fair point. I'll remove that part of my answer – Robert Perry Feb 06 '19 at 16:12