-1

I'm trying to receive google users for my app.... I installed 2 packages from nuget - Google APIs Client Library 1.9.0 and Google.Apis.Admin.Directory.directory_v1
My environment is Windows7, VS2010 with .NET4.0 framework I've got this warning:

The primary reference "Google.Apis" could not be resolved because it has an indirect dependency on the framework assembly "System.Net.Http, Version=1.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0". To resolve this problem, either remove the reference "Google.Apis" or retarget your application to a framework version which contains "System.Net.Http, Version=1.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".

I understand that it is connect somehow to strong naming - I tried to get the source and compile it, though the source code is not adjust to VS2010 ....

Is there a way to install/compile source/whatever which can help me use those packages?

Or.. maybe receive data(users data) without using those APIs

Thanks

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
ishigh
  • 31
  • 1
  • 1
  • 7
  • are you trying to build a Dll? – Linda Lawton - DaImTo Dec 16 '14 at 10:29
  • I tried to install packages, than I was thinking to compile it myself (yes to Dll's) though I'm using VS2010 and the code is for 2012 – ishigh Dec 16 '14 at 10:32
  • If your project will be compiled as a DLL then you will need them strong named. If you just making a normal application then they shouldn't need to be strong named. But I don't think that is the strong name error message check my answer below. – Linda Lawton - DaImTo Dec 16 '14 at 10:43
  • 1
    You need to include complete steps to reproduce this issue. I have tried now with 4 types of projects in Visual Studio 2010 and Visual Studio 2015, and cannot reproduce it. DalmTo also could not reproduce the issue. – Sam Harwell Dec 16 '14 at 11:27
  • What kind of steps? I installed the package and after that I got those warnings, furthermore I cannot run my application now cause of this exception: The type initializer for 'System.Net.Http.Formatting.XmlMediaTypeFormatter' threw an exception – ishigh Dec 16 '14 at 11:32
  • I don't know what else I need to add? – ishigh Dec 16 '14 at 11:32
  • @ishigh try and create a new project with just that see if you can recreate it. I have seen this error its normally the client profile error. remember you only need the directory nugget it will install the other one as a dependency. – Linda Lawton - DaImTo Dec 16 '14 at 12:03
  • Starting with no project, explain the project to create, the code to add, and the commands to run leading to that error. The information you gave hasn't led anyone to that error, which means the problem lies in something you haven't told us. – Sam Harwell Dec 16 '14 at 12:04

2 Answers2

0

Unless you are trying to build a .dll they don't need to be strong named. (As far as I know someone correct me if I am wrong)

I don't really understand when you ger getting this error:

If its when you do the NuGet install (Install-Package Google.Apis.Admin.Directory.directory_v1 )

  • Right click your project -> properties -> make sure Target framework is .Net FrameWork 4.0 not .NET Framework 4.0 client profile
  • make sure you have the newest version of NuGet also this can also cause it to fail to import the libraries.

If its when you are trying to compile the project:

  • check each of the dlls in your reference is set to copy local true or add them to GAC

enter image description here

Let me know if this doesn't work.

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
0

This message is unrelated to strong naming. In fact, as of version 1.9.0, the Google.Apis.Core package on NuGet does not use a strong name, so your project will not be able to either.

While I was not able to reproduce the issue described above, it sounds like you need to add an assembly binding redirection.

  1. In Visual Studio, use Tools → Extension Manager... to make sure the NuGet extension is updated to the latest version.
  2. Open your solution in Visual Studio.
  3. Run View → Other Windows → Package Manager Console
  4. Run the following command, where YourProjectName is the name of the project you are trying to build.

    Add-BindingRedirect -ProjectName YourProjectName

    You should see the following output from this command.

    Name                             OldVersion                NewVersion
    ----                             ----------                ----------
    System.Net.Http                  0.0.0.0-2.2.22.0          2.2.22.0
    System.Net.Http.Primitives       0.0.0.0-2.2.22.0          2.2.22.0
    System.Runtime                   0.0.0.0-2.6.9.0           2.6.9.0
    System.Threading.Tasks           0.0.0.0-2.6.9.0           2.6.9.0
    
Sam Harwell
  • 97,721
  • 20
  • 209
  • 280
  • I did and this is what I got:Name Newtonsoft.Json 0.0.0.0-6.0.0.0 6.0.0.0 System.Runtime 0.0.0.0-2.6.9.0 2.6.9.0 System.Threading.Tasks 0.0.0.0-2.6.9.0 2.6.9.0 System.Net.Http 0.0.0.0-2.2.22.0 2.2.22.0 System.Net.Http.Primitives 0.0.0.0-2.2.22.0 2.2.22.0 – ishigh Dec 16 '14 at 11:16
  • @ishigh Is the problem fixed now? – Sam Harwell Dec 16 '14 at 11:19
  • No - now I get: Warning 1 Found conflicts between different versions of the same dependent assembly. C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets 1605 5 – ishigh Dec 16 '14 at 11:22
  • And when I try to run it I get this exception:The type initializer for 'System.Net.Http.Formatting.XmlMediaTypeFormatter' threw an exception. – ishigh Dec 16 '14 at 11:23