WPF .NET Core 1.0 Reference Library

I am currently developing a desktop application in WPF that uses the .NET Core library to simplify porting to multiple platforms. However, I cannot reference the .NET Core library from the WPF application.

I tried the following solutions:

  • Link to the project: Visual Studio complains that the project is not a .exe or .dll file, even if it exists.

  • Link to compiled .dll: It is really ugly, but it seems to work first. Intellisense is fine with it, and the WPF project compiles just fine. But as soon as I want to use any functionality from the .NET Core project, a BadImageFormatException is thrown.

  • dotnet pack project and .nupkg link: Installs a bunch of additional packages and throws a BadImageFormatException when using any function.

From what I can assemble, there are two options:

  • Do something really hacky, like creating a .NET Core Console project and passing all objects as strings between two programs.

Or:

  • Just hand over .NET Core and use EF6.

Here is my project.json:

 { "version": "1.0.0-*", "buildOptions": { "debugType": "portable", "emitEntryPoint": true }, "dependencies": { "Microsoft.EntityFrameworkCore.Sqlite": "1.0.0", "Microsoft.EntityFrameworkCore.Design": { "version": "1.0.0-preview2-final", "type": "build" } }, "frameworks": { "netcoreapp1.0": { "dependencies": { "Microsoft.NETCore.App": { "type": "platform", "version": "1.0.0" } }, "imports": "dnxcore50" }, "dnx451": {} }, "tools": { "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final" } } 

I tried both dnx451 and net451 . The WPF project also targets .net 4.5.1. I am using "Visual Studio 2015 Update 3 Update" with ".NET Core 1.0.1 VS 2015 Tooling Preview 2".

+7
c # visual-studio wpf .net-core
source share
1 answer

Your project.json invalid for the library. The library project should look like this:

 { "dependencies": { "Microsoft.EntityFrameworkCore.Sqlite": "1.0.0", "Microsoft.EntityFrameworkCore.Design": { "version": "1.0.0-preview2-final", "type": "build" } }, "frameworks": { "net451": { }, "netstandard1.3": { "dependencies": { "NETStandard.Library": "1.6.0" } } }, "tools": { "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final" } } 

When dotnet pack starts, two DLLs will be created: one for .NET 4.5.1 and one for .NET Standard 1.3 (or depending on which netstandard you want to configure). DLL.NET 4.5.1 should be compatible with your WPF project.

+4
source share

All Articles