6

I have a library written against .NET Standard 1.3 which should be compatible with the .NET Framework 4.6.1 runtime. The library uses the new csproj and works fine when referenced by .NET Core projects.

I also have a WPF project on a traditional csproj which should be able to use this library. In Visual Studio 2017 I managed to reference the .NET Standard library and it compiles without errors.

At runtime, it tries to load assemblies which are dependencies of the .NET Standard project and it fails with assembly not found exceptions. And I can see that my output folder doesn't have any of the dependencies indeed.

Is there a way to reference my library in such a way all the required dependencies are copied to the output folder (or an equivalent solution to make the WPF project run fine)?

Note: If I reference manually one by one all the missing dependencies and use runtime assembly version binding I can make it run, but I shouldn't really do this when referencing a project.

This is the full project page: https://github.com/UnoSD/PasswordManager

.NET Standard csproj

WPF package.config

WPF csproj

It currently is a Roslyn problem: GitHub issue

7
  • Can you share your files, both the netstandard and WPF project? Also, does your WPF project have a packages.config file? If so please share that too. Commented Mar 8, 2017 at 16:13
  • @natemcmaster all in GitHub, I have added the links. Commented Mar 8, 2017 at 16:29
  • You have to have the necessary dependencies in your output folder (use Copy Local), as well as correct assembly redirection in app.config. Commented Mar 8, 2017 at 21:56
  • @LexLi That's what I'm doing, but I shouldn't have to manually add the dependencies. Commented Mar 8, 2017 at 22:21
  • @Stefanod'Antonio "shouldn't" is just your opinion. Sadly the fact is that you have to. Commented Mar 9, 2017 at 1:21

2 Answers 2

4

It is an active issue on Roslyn:

https://github.com/dotnet/roslyn/issues/17639

https://github.com/NuGet/Home/issues/4488

Sign up to request clarification or add additional context in comments.

2 Comments

There are even more if you use "FileNotFoundException" keyword to search across the .NET Core repos. So I don't think there would be a quick fix.
@LexLi I posted the main one and mine, others are mostly closed duplicates. They suggest a workaround, but it doesn't seem to work for me.
2

You have to specify compiler output for .NET 4.6.1

Put line like below into your csproj in your .NET Standard library project.

<TargetFrameworks>netstandard1.4;net461</TargetFrameworks>

(that should go instead <TargetFramework>netstandard1.4</TargetFramework>)

Build will produce binaries both for .NET 4.6.1 and .NET Core runtime compatible with NET Standard 1.4.

4 Comments

Also, I read the whole point of using .NET Standard was not to multi-target, isn't this just multi-targeting?
Indeed, targeting both I get some type collisions and it doesn't compile anymore.
Anyone figure this out yet? I want to use a .net standard library in a project that also uses net461.
And what's the issue @christopherclark? You should be able to reference .net standard from a .net461 project

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.