Search code examples
visual-studio-2010visual-studiodependenciesnugetgocardless

GoCardless SDK "requires a later version of the .NET Framework than the one specified in the project" (ASP.NET 3.5, Visual Studio 2010)


UPDATE 201521011559: I'm wondering if this is caused by an error in the dependency specifications in the .nuspec file used to build the package...

The .nuspec file for the client SDK is on GoCardless' GitHub repo

https://github.com/gocardless/gocardless-dotnet/blob/master/GoCardlessSdk/GoCardlessSdk.nuspec

and includes this section:

<dependencies>
  <group targetFramework="net20">
    <dependency id="Newtonsoft.Json" version="4.5.11"/>
    <dependency id="RestSharp.Net2" version="1.1.11"/>
  </group>

  <!-- For reasons unknown, NuGet pack will not recognise targetFramework and tries to put all our deps into the default group.-->
  <!--
  <group targetFramework="net35">
    <dependency id="Newtonsoft.Json" version="5.0.2"/>
    <dependency id="RestSharp" version="104.1"/>
  </group>
  -->
</dependencies>

Am I right in thinking that means it's going to try and install RestSharp.Net2, regardless of the target framework version of the target project?


ORIGINAL QUESTION:

One of our projects is an ASP.NET web application - target framework set to .NET 3.5, no client profile or anything.

I've just installed the NuGet package containing the GoCardless .NET SDK (http://www.nuget.org/packages/GoCardless/)

PM> Install-Package GoCardless

It appears to work fine. Then I add a reference to GoCardless.Sdk to one of my pages, and the project refuses to compile:

The type or namespace name 'GoCardlessSdk' could not be found (are you missing a using directive or an assembly reference?)

What's really odd is that if I remove the reference, then right-click References, Add Reference, browse to the ..\packages\GoCardless\lib\net35\ folder and select GoCardlessSdk.dll, I get this error:

'GoCardlessSdk.dll', or one of its dependencies, requires a later version of the .NET Framework than the one specified in the project. You can change the .NET Framework target by clicking Properties on the Project menu and then selecting a new target in the '.NET Framework' dropdown box.

Do you still want to add a reference to 'GoCardlessSdk.dll' in the project?

enter image description here

I've checked the package using NuGet Package Explorer. It definitely exposes both a .NET 2.0 and a .NET 3.5 version; the only dependencies are Newtonsoft.Json and RestSharp, both of which run just fine on .NET 3.5.

I'm using Visual Studio 2010 Premium on Windows 7 x64. Is this a Visual Studio problem, a .NET problem or something specifically wrong with the GoCardless SDK NuGet package?


Solution

  • I've fixed this in the past by uninstalling Microsoft Blend. It gets installed along with Visual Studio 2012, and it also installs its own version of Newtonsoft.Json.dll. It does something weird with the DLL (maybe it installs the DLL in the GAC?) that causes Visual Studio to reference the Blend version of the DLL, rather than whatever other DLL it should be referencing.

    There's possibly a friendlier solution than uninstalling Microsoft Blend, but if you don't use Blend then that's the easiest option!