3
votes

I have a WPF application developed with .NET 4.61, and I use ClickOnce to deploy the application. The publishing phase runs without error, but when I try to install, the installer downloads .NET 4.61 as expected. Once done (after a restart), it gives an error stating the assembly System.drawing.primitives.dll version 4.0.2.0 needs to be installed in the GAC.

Does not .NET 461 install assemblies in the GAC by default?

Information

  • Windows 10 64 bits

  • Visual Studio 2017

PS: The same problem is present on my development machine.

3
System.drawing.primitives.dll looks like package for .net core: nuget.org/packages/System.Drawing.Primitives. I don't think you can expect it to be installed with the .net461 install. - Vince
but I don't use .net core at all !!! or does Prism.Wpf use it ? - Houss_gc
I did look at Prism.Wpf dependencies but there is no dependencies on System.Drawing.Primitives - Houss_gc
I have exactly same issue and also found that someone reported it. You may want to follow developercommunity.visualstudio.com/content/problem/111414/… - cilerler
So far all I can see is deployment file .application throws that error and not the actual .exe - cilerler

3 Answers

2
votes

I am able to replicate this issue, but don't know enough to be able to answer your question clearly, but maybe it may help someone more knowledgeable to help answer it.

It appears to be an issue related to a WPF application referencing a .NET Standard 2.0 class library.

Here are the steps to reproduce:

  • Create a new Solution with a WPF App in Visual Studio 2017 with File > New Project> Visual c# > WPF App (.NET Framework)
  • Build and Publish. The WPF App runs fine
  • Add a new Project to the Solution with File > Add > New Project > Visual C# > .NET Standard > Class Library > .NET Standard (.NET Framework 4.6.1)
  • Add a Reference from the WPF App to the .NET Standard Class Library.
  • Build and Publish and attempt to install.

Get an Error "Unable to install or run the application. The Application requires that assembly System.Drawing.Primitives Version 4.0.2.0 be installed in the Global Assembly Cache first.

Error Dialog

I have this simple project reproduced in git.

https://github.com/colhountech/WPF_With_NetStandard

Hope this helps someone to resolve it. I've got the same issue with a simple WPF project I am trying unsuccessfully to resolve.

2
votes

I got rid of this annoyance. It took me a lot of time browsing the web and trying. The actual changes are a lot less.

What worked for me.

  • If you have them, remove all the extra includes previously mentioned from the project file.
  • Add AutoGenerateBindingRedirects like described here.
  • Switch to .NET 4.7.1 which you can find here.
1
votes

I suffer the same issue. In order to solve it, I had to include all required packages in Application Files... on the Publish tab.

Publish configuration screenshot