Hi, I’m liking the idea of the new Checkout API (it’s just what I need), and after following through the Quick Start guide using VS2019 and C#. I successfully tested in the sandbox and got back a response that I can use. This was a C# “Console Application” as per the example.
But, and here is my problem, I am trying to implement exactly the same code into an existing
ASP.NET Web Application (.NET Framework)
project.
I’ve added using NuGet the required ‘Square’ and ‘Microsoft.Extensions.Configuration’ and ‘Microsoft.Extensions.Configuration.JSON’ SDK’s.
I’ve made a namespace that has the same code as the Program.cs file.
I’ve made a Class1.cs file that is the same as the one I wrote in my Console application.
I also had to update my project to .NETFramework 4.7.2.
Plus I added a reference to .netstandard.dll v2.0 (as this was missing). I used the one from my Console App (this could be relevant to my issue?)
Now all is looking nearly there, but I have three errors when I build my Project. A far bit of Goggling makes me think that the Square SDK and some other dll (reference) are clashing, but I cannot work out which files and if so what versions to use.
Ideas are most welcome, please.
Issue 1:
var result = await client.CheckoutApi.CreatePaymentLinkAsync(body: body);
Gives the error = “Reference to type ‘Task<>’ claims it is defined in ‘System.Runtime’, but it could not be found”. Is there some clash with my version of System.Threading.Tasks?
Issue 2:
catch (ApiException e)
{
var errors = e.Errors;
Gives the error in relation to the keyword ‘Errors’ = “The type ‘List<>’ is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Collections, Version=4.1.2.0,” but the reference does exist…
Issue 3:
foreach (var item in httpContext.Request.Headers) {}
Gives the error in relation to the keyword ‘Headers’ = “The type ‘Dictionary<,>’ is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Collections, Version=4.1.2.0” but once again the reference does exist…
I already make use of Task awaiting, and LIST<> in this project before adding the Square SDK + Updates, and they did work.
Thanks.