ProEns08
ProEns08

Reputation: 1914

Added reference not detected in visual studio

When trying to install the netmq vis nuget, I get the following error:

Could not install package 'AsyncIO 0.1.18'. You are trying to install this package
 into a project that targets '.NETPortable,Version=v4.5,Profile=Profile111',
 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.

The problem is that netmq depends on AsyncIO. when installing it, nuget find that the assembly is not compatible with .Net 4.5.

so nuget fail in installing AsyncIO, and then failed in installing netmq.

So I downloaded the AsyncIO Source from Github and build it locally with .Net 4.5.

After that and added the dll of AsyncIO built locally as a reference for my project.

Theoretically, NetMQ should be successfully installed with nuget. because I added the needed reference to AsyncIO.

But when trying to reinstall NetMQ, I get the same error:

Could not install package 'AsyncIO 0.1.18'. You are trying to install this package
 into a project that targets '.NETPortable,Version=v4.5,Profile=Profile111',
 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.

and nuget did not detect that I added 'AsyncIO 0.1.18' in my project.

How to let nuget detect that I added this reference in my project?

Upvotes: 2

Views: 896

Answers (2)

Zverev Evgeniy
Zverev Evgeniy

Reputation: 3719

Have a look here:

.NET Portable profiles

Profile111 is a combination of:

  • .NET Framework 4.5
  • Windows 8.0
  • Windows Phone 8.1

or in other words: portable-net45+netcore45+wpa81

So your project into which you are trying to append the NuGet targets Windows Phone 8.1 and other 2 platforms, I mention this one as the most restrictive.

Now let's have a look at the named NuGet package's source:

 <ProjectGuid>{3830B7A3-0225-4FDA-B155-E085E183650C}</ProjectGuid> 
 <OutputType>Library</OutputType> 
 <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> 
 <TargetFrameworkProfile> 
 </TargetFrameworkProfile> 

What do we have here? We can see that the project is not a PCL. It is targeting full .NET 4.0 framework which is not available on Windows Phone 8.1. And your library does target Windows Phone 8.1. See the problem?

You say that if you compile the AsyncIO targeting .NET 4.5 than you can successfully append it into your project as a reference? That's not altogether true. I mean you can append a reference to it but you cannot use it. You will see that when you try to call something from that reference.

In order to use AsyncIO from you PCL will have to build AsyncIO as a PCL targeting the same or more restrictive set of platforms. Try creating a PCL project targeting Profile111 and try compiling the AsyncIO code with it (just link the original AsyncIO source files (*.cs) into this new AsyncIO_PCL project). If you are lucky enough and the code of AsyncIO is really compatible you will be able to use that library.

Here are your steps:

  1. Create a new project (named AsyncIO_PCL) of type PCL class library.
  2. Pick the Profile111 platform set i.e.
    • .NET Framework 4.5
    • Windows 8.0
    • Windows Phone 8.1
  3. Link all the .cs files from the original AsyncIO project save one (AssemblyInfo.cs) into the new AsyncIO_PCL project.
  4. Set the output assembly name to the same as in original AsyncIO project.
  5. Try building the project.

Your ability to build the AsyncIO as a PCL with the required set of supported platforms depends on AsyncIO code i.e. which API is used inside and if that API is supported by all the three platforms you are targeting.

Upvotes: 2

Player
Player

Reputation: 1

Try clicking right-button on the project -> Properties. In the "Application" menu check the "Target Framework". It should be set to .NET Framework 4.5

Upvotes: -1

Related Questions