2

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?

Dylan Beattie
  • 53,688
  • 35
  • 128
  • 197

3 Answers3

1

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!

kebab
  • 211
  • 3
  • 4
  • Wow... it looks like [Blend](https://connect.microsoft.com/VisualStudio/feedback/details/816725/visual-studio-referencing-dll-in-c-program-files-x86-microsoft-visual-studio-12-0-blend-directory-incorrectly) [breaks](http://stackoverflow.com/questions/21653130/) [a LOT](http://stackoverflow.com/questions/21739960/) of things. More info at [this blog post from Rick Strahl](http://weblog.west-wind.com/posts/2015/Jan/15/Blend-Path-interfering-with-C-Project-Builds) as well. – Dylan Beattie Apr 22 '15 at 12:24
0

What I would suggest you is re-arrange your whole solution:

First of all remove: - GoCardless Client Libraries 1.1.15 (Or 1.1.16) again if you have installed it now:

Than try to compile your solution again and if everything runs normal you should get the error that you can not find a file from the reference .dll right?

Than you need to make sure that for:

.NETFramework 3.5

Newtonsoft.Json (≥ 5.0.2) || RestSharp (≥ 104.1) and for

Or for .NETFramework 2.0

Newtonsoft.Json (≥ 4.5.11) || RestSharp.Net2 (≥ 1.1.11)

are matching exaclty the version they are here. (Newest update from GoCardless)

If you have checked that with the nuget controller:

Updating a Package(click to visit page)

From the Tools menu, select Library Package Manager and then click Package Manager Console. To check if there are newer versions available for any installed packages, enter Get-Package -updates at the prompt.

Get-Package command

To update a package, enter Update-Package with the package ID. For example, enter the command Update-Package jQuery. For more options that you can use with the Update-Package command, enter get-help Update-Package or see (../Reference/Package-manager-Console-Commands).

If those updates / maybe downgrades are done you can want to change the .Net Framework of you Application by doing following:

  1. In Solution Explorer, open the shortcut menu for the project that you want to change, and then choose Properties.

  2. In the left column of the properties window, choose the Application tab. Visual Studio App Properties Application tab

(After you create a Windows Store app in Visual Studio 2013, you can't change the targeted version of either Windows or the .NET Framework.)

  1. In the Target Framework list, choose the version that you want.

  2. In the verification dialog box that appears, choose the Yes button.

The project unloads. When it reloads, it targets the .NET Framework version that you just chose.

Than if you have changed it to the .Net FrameWork 3.5 (Id suggest you take that regarding your imports) you can re-import the GoCardless.dll and tell me what happens. In my opinion it should be able to add the reference and start working with it.

Community
  • 1
  • 1
Luca
  • 1,766
  • 3
  • 27
  • 38
0

That package is no longer supported and has been unlisted by it's owner.

I've create a new one here:

https://github.com/getAddress/goCardless

(or PM> Install-Package getAddress.goCardless)

Lee Smith
  • 6,339
  • 6
  • 27
  • 34
  • Yep, they withdrew it because they got fed up of me hassling them about not accepting my pull requests. Our own fork of it is at https://github.com/SpotlightUK/gocardless-dotnet and includes a bunch of fixes for bugs in their API, but they appear to have completely dumped .NET as a supported platform. At least they open sourced it first, I guess... :) – Dylan Beattie Oct 13 '16 at 13:46