GoCardless SDK "requires a later version of the .NET Framework than the one specified in the project" (ASP.NET 3.5, Visual Studio 2010) - 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?
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?

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!

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:
In Solution Explorer, open the shortcut menu for the project that you want to change, and then choose Properties.
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.)
In the Target Framework list, choose the version that you want.
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.

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)

Related

Nuget-package not adding package reference

I am trying to install MySql.Data and MySql.Data.Entity to my class lib.
Somehow there is no reference added to the project.
Things I've tried:
Update-Package -reinstall (does not help)
packages.config contains the correct entries
*.csproj also has the correct entries
Cleared NuGet-Cache
This is the output:
Package 'MySql.Data.6.10.6' already exists in folder
'C:\Users\MYUSERNAME\Documents\Repositories\XXXXXXX\packages'
Added package 'MySql.Data.6.10.6' to 'packages.config'
Successfully installed 'MySql.Data 6.10.6' to XXXXXXXX.Persistence
Executing nuget actions took 1,6 sec
Strange thing is that NuGet creates that \docs in my project which is part of MySql
Nuget-package not adding package reference
I agree with Matt`s comment. You project targets framework should be .NET 4.5.1 or below. Because the package MySql.Data only contain assembly reference to .NET framework 4.5.2 for .NET framework:
However, this package also have the content files, which are compatible with .net framework. So when you add this package to the project(target framework 4.5.1 or below), nuget will install this nuget package without any error, just add the content file (\docs) but not add any reference to the project.
To resolve this issue, you can change the target framework to 4.5.2 and above of this project or you should use the nuget package MySql.Data with the version 6.9.11, which contain assembly reference to .NET framework 4.0 and 4.5:
Note: If you change the target framework to the .net framework 4.5.2 and above, you may get the error "The package 'MySql.Data' tried to add a framework reference to 'System.ComponentModel' which was not found in the GAC.", please add a manually reference to missed library:
Package tried to add reference to System.Runtime which was not found in the GAC
Hope this helps.
I experienced this problem even though I had the correct Framework.
It was solved by Migrating the Nuget Format to Package References
For visual studio latest versions you have to right click on Dependencies > Manage NuGet Packages > click in the settings button with a flower-like shape, then in NuGet Package Manager option choose General, and change Default package management format from packages.config to PackageReference.
If that does not do the trick, then you will have to add the packages through the CLI tools, looking into the nuget gallery and pasting the comand directly with the desired version, like for example:
dotnet add package Microsoft.EntityFrameworkCore.Design --version 6.0.10

Visual Studio for Mac does not get past "Add packages"

I am trying out Xamarin Forms on Visual Studio for Mac.
When I create a new project, I see VS is trying to add packages to the solution, but every single time- it fails at the same place...
Here is the Package Console output:
https://drive.google.com/open?id=1-KfdWC2hub4YuEOHfJ_LICL86o6zkecytmMAi0emDeQ
On this new project, after the package installer fails, it always fails to build with the default assets:
Is it possible other dev environments are affecting Visual Studio?
Is there a more stable way I can use Xamarin forms on a Mac?
Thanks in advance!
One of the errors I see in your Package Console is:
Could not install package 'Xamarin.Android.Support.v4 23.3.0'. You are
trying to install this package into a project that targets
'MonoAndroid,Version=v2.3', but the package does not contain any
assembly references or content files that are compatible with that
framework.
NuGet looks at your project's target framework and version to see if the NuGet packages are compatible. As far as NuGet is aware your project is targeting MonoAndroid version 2.3. Check what you have selected as the Compile using Android version in the project properties and ensure that it's compatible with the package you want to add.
Also, a "more stable" way to use Xamarin Forms on a Mac is not available unless you want to try Xamarin Studio but that is almost the same as Visual Studio for Mac (which is based on it).

VSIX dependency based on visual studio version

I had created a visual studio extension (VSIX) which was compatible with vs2010 and vs2012. It had Nuget Package Manager as a dependency. Now I want to make it compatible with vs2013. I added the vs2013 to the supported products. But, the istallation would always fail. Apparently, Nuget team have changed the Identfier for vsix extension for vs2013. I cannot change the identifier to new one as it will affect vs2010/12.
<References>
<Reference Id="NuPackToolsVsix.Microsoft.67e54e40-0ae3-42c5-a949-fddf5739e7a5">
<Name>NuGet Package Manager</Name>
<MoreInfoUrl>http://docs.nuget.org/</MoreInfoUrl>
</Reference>
</References>
Is there a way to add depndencies to vsix based on visual studio version. So that I can add one more reference to nuget for vs2013. OR is there any workaround to this?
The new identifier for vs2013 nuget extension is NuGet.67e54e40-0ae3-42c5-a949-fddf5739e6a5
You can do either of the following:
Remove the reference to the NuGet extension. This will result in a risk of package load errors or other errors if your users do not have NuGet installed, or if they have an outdated version of NuGet that your extension does not support.
Ship separate VSIX packages of your extension for Visual Studio 2010-2012 and Visual Studio 2013.
The latter is likely the best approach. You can create both extensions from the same codebase by following the approach used in the Cloud Explorer extension (note there will be subtle differences because this extension doesn't support Visual Studio 2010, but yours does).
Create a separate project file for the VS2013 extension in the same folder as the extension that targets 2010-2012. I highly recommend you use a visual diff tool to compare Rackspace.VisualStudio.CloudExplorer.11.csproj and Rackspace.VisualStudio.CloudExplorer.12.csproj to show the subtle differences that allow these to live side-by-side.
Create subfolders Properties\vs2010 and Properties\vs2013 to hold the two separate versions of your source.extension.vsixmanifest file. Use the correct NuGet reference for each of these files.
If your project is open source on GitHub, I could help apply the changes and send a pull request.

Adding MOQ to a .NET 4.0 project is not possible

I want to add MOQ .net library to a .NET 4.0 project. I get an error message that I should convert the project to something smaller than 4.0. I need to use .NET 4.0 also because of other project dependencies.
How can I make MOQ work with a .NET 4.0 project in VS2010 ?
Make sure you have NuGet package manager installed (Tools/Extension Manager).
Right click on Solution Explorer/References, choose Manage NuGet Packages.
Type Moq in the search box.
Install and enjoy.
The latest version from Google Code (http://code.google.com/p/moq/), works in a .Net 4.0 project. I would just download the dll again.
Here is the download link: http://code.google.com/p/moq/downloads/detail?name=Moq.4.0.10827.Final.zip
The zip file at that location contains a .Net 4 folder. Use the dll : Moq.dll from the NET40 folder and everthing will work fine. Just do a normal Add Reference on the project.
I would check the version number and the Runtime veseion of the assembly you are trying to use. It should say:
Runtime Version: v4.0.20926
Version: 4.0.10827.0
For the sake of completeness, it may be worth pointing out that it is also possible to use the Visual Studio command line package manager tool:
1) Open the console in VS
View >> Other Windows >> Package Manager Console
2) Install Moq
Type Install-Package Moq at the prompt
Note: If your tests are in a separate project, make sure that you select that project in the project dropdown.
This will install the latest package available in NuGet, which should address your compatibility issue. See http://nuget.org/packages/moq.
Watch out that you're using .NET 4, rather than the .NET 4 Client Profile as your Target Framework. I had the same issue and that was the cause for me.

Why does visual studio not recognize System.Web.SessionState?

I am trying to go through the example at http://msdn.microsoft.com/en-us/library/aa719643(VS.71).aspx
Visual studio 2010 does not recognize System.Web.SessionState and various others.
I tried adding a .net reference to them but they do not exist on my system. I have .Net 4 installed.
Why would these examples use namespaces that are not recognized by visual studio?
alt text http://www.phantix-llc.com/system.web.sessionstate_missing.jpg
System.Web isn't shown because VS2010 defaults to using the .NET4 Client Profile which doesn't include it. (You can see the "Filtered for .NET Framework 4 Client Profile" text at the top of the Add Reference dialog.)
You need to change your project's properties so that it targets the full version of the framework, then you'll be able to select System.Web.
System.Web.SessionState (and the others shown unrecognized) are in System.Web.dll. Verify that reference exists.

Resources