Move code to DLL out of Windows Store app if it uses full-framework library?

167 views Asked by At

I've created Windows Store application on .Net 4.5, that uses AngleSharp 0.8.5, HTML parser engine. My project contains many code files which i gonna use in another application, so i decided to move that code into PCL library, to separate project.

But i cannot add AngleSharp DLL from NuGet system to my PCL project, as it says:

Could not install package 'AngleSharp 0.8.5'. You are trying to install this package into a project that targets 'portable-win+net45+sl40+wp', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

I've tried to add AngleSharp DLL manually to project, but if i try to build my PCL project i get warnings like this:

Warning 2 The primary reference "AngleSharp" could not be resolved because it was built against the ".NETPortable,Version=v4.5,Profile=Profile259" framework. This is a higher version than the currently targeted framework ".NETPortable,Version=v4.0,Profile=Profile4". prototypeLibrary

And this

The primary reference "AngleSharp" could not be resolved because it has an indirect dependency on the framework assembly "System.Threading.Tasks, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the currently targeted framework. ".NETPortable,Version=v4.0,Profile=Profile4". To resolve this problem, either remove the reference "AngleSharp" or retarget your application to a framework version which contains "System.Threading.Tasks, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". prototypeLibrary

I also tried to create a normal Class Library project and move my code there, but i cannot add a reference to it from my Windows Store application.

What should i do if i need to move some code out of Windows Store executable and re-use, in my case?

1

There are 1 answers

0
Anders Gustafsson On BEST ANSWER

According to Warning 2 you have created a Profile 4 PCL library, which is considered a legacy profile that is not supported in VS 2013 and later. Profile 4 targets .NET 4.5, Silverlight 4, Windows 8 and Windows Phone 7. AngleSharp is incompatible with both SL4 and WP7, so this PCL profile is not a viable option.

For maximum compatibility with AngleSharp, I recommend that you switch to PCL profile 259, which targets:

  • .NET 4.5
  • Windows 8
  • Windows Phone 8.1
  • Windows Phone Silverlight 8
  • Xamarin Android
  • Xamarin iOS Classic and Unified APIs

If you switch to this PCL profile, you should have no problem referencing your portable class library from your Windows Store application.