square / connect-csharp-sdk

C# client library for the Square Connect APIs
https://docs.connect.squareup.com/
Apache License 2.0
27 stars 25 forks source link

Getting error for system.componentmodel.annotations v 4.2.0.0 #109

Closed logicsdrive closed 4 years ago

logicsdrive commented 5 years ago

I am using VS 2017 with .net framework 4.7.2 and when i try to run the application i am getting error "Could not load file or assembly 'System.ComponentModel.Annotations, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference"

When i tried to search for package system.component.Model.Annotations on Gnut there is no version available 4.2.0.0 and then i tried to install 4.3 but it says not compatible with .net framework. Please help what to do ?

StephenJosey commented 5 years ago

Hey @logicsdrive would you be able to share your project file where the dependencies are defined? I believe our SDK depends on System.ComponentModel.Annotations but version 4.5.0.

NoAvailableAlias commented 5 years ago

What a coincidence, also running into this issue. However, instead of "The located assembly's manifest definition does not match the assembly reference", it is, "The system cannot find the file specified" Edit: this is occurring in an mvc 4.6.1 project.

gairel commented 5 years ago

@StephenJosey We are also running into this issue. We are also using the 4.6.1 .net framework. I have tried building the C# project from this repo and including the DLL in our project AND also getting the packages through nuget. Both result in the System.ComponentModel.Annotations issue.

We have also tried routing the old version to the newer version of Annotations:

`

             <assemblyIdentity name="System.ComponentModel.Annotations" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />

             <bindingRedirect oldVersion="0.0.0.0-4.2.1.0" newVersion="4.5.0.0" />

        </dependentAssembly>

`

Our packages .config is as follows:

`<?xml version="1.0" encoding="utf-8"?>

` In looking at the nuget package manager, I can se ethat 4.2.0.0 isn't even available from the repository: ![image](https://user-images.githubusercontent.com/5280558/56584845-a0e94a80-65aa-11e9-9f36-f402cfde6100.png) https://www.nuget.org/packages/System.ComponentModel.Annotations/4.6.0-preview4.19212.13 Any idea how we can resolve this?
StephenJosey commented 5 years ago

This seems to be an issue outside of our SDK. Please see the following thread for a possible fix: https://github.com/dotnet/corefx/issues/33643#issuecomment-482475390

FrqSalah commented 5 years ago

I had the same problem. To fix it you need to go to the properties of System.ComponentModel.Annotations and check false in Specific version.

tobbyioa commented 5 years ago

I had this problem for some time and tried all sorts to no avail. However, I discovered the version showing for Version 4.5.0 in the library reference properties is 4.2.1.0. When I changed the version to 4.4.1 via NuGet, the version in the properties changed to 4.2.0.0. This fixed it for me and was able to load the Swagger UI. I hope you will find this helpful.

Rompa commented 4 years ago

I had a problem when updating Service References in an ASP.Net Web Application inside Visual Studio: The WSDL import extension encountered an exception in System.ServiceModel.Description.DataContractSerializerMessageContractImporter, stating it "Could not load file or assembly 'System.ComponentModel.Annotations, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies". As suggested by @tobbyioa I nugot System.ComponentModel.Annotations, 4.4.1, which seems to help for now.

Abouzeid commented 4 years ago

Many thanks to @tobbyioa changing the version of System.ComponentModel.Annotationsto 4.4.1 resolved the issue for me.

StephenJosey commented 4 years ago

Closing this out - work arounds above, but can't be resolved in our SDK.