1

Good day.

I have created a .NetCore2 webapp and would like some guidance on how you get windows.forms working on it. (VS2017)

This is the error I get basically:

Dot Net Core and Azure Storage: Could not load file or assembly System, Version=4.0.0.0

Could not load file or assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.

The project builds but the moment I call the api it fails to detect the dll. (In code it detects the dll fine)

I have added the dll to the project, also followed the instructions of adding it to your project.json. (in my case: package.json)

 "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "net46",
        "net40"
      ]
    }
  },

Also added the required references to my csproj folder.

<PropertyGroup>
  <TargetFrameworks>net452;netstandard1.3</TargetFrameworks>
</PropertyGroup>

How to use System.Windows.Forms in .NET Core class library

"frameworks": {
  "netstandard1.6": {
    "dependencies": {
      "NETStandard.Library": "1.6.0"
    }
  },
  "net40": {
    "frameworkAssemblies": {
      "System.Windows.Forms": {}
    }
  }
}

I am still getting the same error.

I know it is not advised to use .Net framework in a .NetCore app. Am I going to have to port the framework app so it works in a Core enviroment?

The reason i want to just use .NetFramework is that the app already works fine, I just have to get the screens shown to the user.

I also read somewhere that Windows.Forms is not supported with .NetCore in some versions of the framework.

If so, any links to help with this?

I am quite a noob with .NETCore so some of my questions might not make sense or are ignorant.

Thanks

Dave
  • 57
  • 7
  • Why would your web application use Windows Forms to begin with? – Matti Virkkunen Apr 29 '18 at 07:47
  • What functionality from a thick client presentation technology (Windows Forms) could be useful in a web application? – Tanveer Badar Apr 29 '18 at 07:49
  • That old question looks like it's using the old tooling, before .NET Core moved to msbuild. But fundamentally, you're not going to be able to treat a Windows Forms app as a web app, and you won't be able to run Windows Forms apps portably. – Jon Skeet Apr 29 '18 at 07:54
  • Yeah I figured as much :/ The problem is that I then need to port a 3rd party app (That uses windows.forms) into the web app. I do have access to the source COM objects but not the inside of the forms. – Dave Apr 29 '18 at 07:56
  • @Dave In that case "porting" is going be more like rewriting the UI and not reusing any of it. If the "COM objects" contain the logic you might be able to use those, assuming .NET Core supports COM interop to begin with. Even if it doesn't it should still be possible though, because you can call into native code. – Matti Virkkunen Apr 29 '18 at 08:10
  • Rewriting yes, unfortunately. this is not good for deadlines. COM objects are supported. As i am already using a wrapper from the functionality of the 3rd party app. Now to get the visual aspects working is where i am stuck. – Dave Apr 29 '18 at 08:11
  • @MattiVirkkunen Any getting started tutorial for other way round, build .net core shared library for WinForms, Mono project and use on Web .NET core, to support reuse? How to references them that without any much C like language. – Edward Chan JW May 21 '18 at 02:42
  • @Dave If you let the deadline dictate the complexity of the project you're doing it the wrong way round. – Matti Virkkunen May 21 '18 at 09:58

0 Answers0