Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RestSharp and Newtonsoft JSON references #50

Closed
ghost opened this issue Sep 24, 2016 · 27 comments
Closed

RestSharp and Newtonsoft JSON references #50

ghost opened this issue Sep 24, 2016 · 27 comments

Comments

@ghost
Copy link

ghost commented Sep 24, 2016

I already have those packages installed in their latest version (105.2.3 and 9.0.1) , but after adding EasyPost package to my project, they get overwritten by EasyPosts older own dll versions.

@ghost
Copy link
Author

ghost commented Sep 24, 2016

The problem lays with this commit: 468a16d

@att14
Copy link
Contributor

att14 commented Sep 27, 2016

There are issues with both of these libraries SNKs in the latest versions. When adding a SNK to EasyPost I had to downgrade the libraries.

RestSharp actual becomes a new library called RestSharpSigned. Which is maintained separately.

I'm not sure if the issues were fixed, but I can look and see if the issues were resolved.

@olsonkr
Copy link

olsonkr commented Oct 12, 2016

Any updates and a resolution for this issue?

Edit: Nevermind. I downgraded my version to 2.1.2.1 to get around this for now.

@att14
Copy link
Contributor

att14 commented Oct 17, 2016

Since, RestSharp does not provide a signed version, and the signed version is imported with the same name, it causes issues with which RestSharp version gets used. It looks like I'll need to make a new project for the signed version of this library and revert the newest version.

@ZubyH
Copy link

ZubyH commented Dec 30, 2016

Any movement on this?

@att14
Copy link
Contributor

att14 commented Dec 31, 2016

I upgraded to the latest versions of both libraries in the newest release. Are you still having issues?

@ZubyH
Copy link

ZubyH commented Dec 31, 2016 via email

@black-orchid
Copy link

OK, here was my final (I hope) fix to this problem:

  1. Cloned the EasyPost-csharp repo and added the EasyPost.Net40 project to my Visual Studio solution.
  2. Edited the build configuration to disable signing.
  3. Use the Nuget package manager to uninstall RestSharpSigned from the EasyPost project and then install RestSharp.
  4. Delete my website's /bin directory and also packages/EasyPost in my solution directory structure.
  5. Redeploy.
  6. Joy!

@wilbarclay
Copy link

Having the same issue with Easy Post referencing Json.Net 6.0.2 where I have version 8.

Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Installing EasyPost from Nuget does not seem to mind that I am on a higher version.

Had to downgrade Json.Net to 6.0.2 which was released nearly 3 years ago..

@santisweb
Copy link

Any updates on this issue? I'm getting a RestSharp reference issue: Could not load file or assembly 'RestSharp, Version=100.0.0.0, Culture=neutral, PublicKeyToken=598062e77f915f75' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) any help will be appreciated. Thanks.

@black-orchid
Copy link

My hacky fix is still working, let me know if you need any help trying it.

@santisweb
Copy link

santisweb commented Feb 22, 2017 via email

@black-orchid
Copy link

See my post from Jan 20th and let me know where you're stuck. :)

@santisweb
Copy link

@black-orchid It worked! thank you. Now my only concern is keeping up with updates. how do you manage that?

@black-orchid
Copy link

I'm sure you could probably fork the repo and then merge their changes into your branch on demand, but I haven't gotten around to it yet. :)

@humbersoft
Copy link
Contributor

For me, the problem went away after I installed the 'RestSharpSigned' package.
Install-Package RestSharpSigned

@jmalatia
Copy link
Contributor

jmalatia commented Mar 4, 2017

In a new .Net Framework 4.6.1 project, referencing Easypost-Official (2.2.6) package, received the error Could not load file or assembly 'RestSharp, Version=100.0.0.0...

@humbersoft solution worked, Install-Package RestSharpSigned into my project.

But @att14, Easypost needs to fix this issue, so additional packages do not need to be installed manually in the project that is calling the Easypost library or have to do some of the ugly workarounds described above.

We have another production app that uses Easypost, and I'm afraid to upgrade based on these RestSharp and Newtonsoft reference issues that have been going on for the past 6+ months...

@att14
Copy link
Contributor

att14 commented Mar 11, 2017

I just released 2.3.0 which upgrades the dependencies for NET40 and NET35 and fixes the references in the nuspec file. If you are still having issues, please let me know.

@att14
Copy link
Contributor

att14 commented Mar 28, 2017

Since there have been no new reports of this, I'm going to close. If you continue to have issue please reopen with more details.

@att14 att14 closed this as completed Mar 28, 2017
@justintcgplayer
Copy link

I am still seeing the issue reported above where the EasyPost NuGet package still seems to have a hardcoded reference to RestSharp 100.0.0, even though it lists 105.2.3 as a dependency. This is with EasyPost-Official v2.3.0.

When I install the NuGet package, it overwrites my existing reference to RestSharp 105.2.3 with a reference inside the EasyPost package folder that is version 100.0.0.

@att14
Copy link
Contributor

att14 commented Apr 4, 2017

@justintcgplayer I preformed the following actions.

  1. Added RestSharp 105.2.3 as a dependency.
  2. Added EasyPost 2.3.1 as a dependency.
  3. Wrote a simple application to ensure they are both working:
using System;
using System.Collections.Generic;

using RestSharp;
using EasyPost;

namespace ConsoleApplication2 {
    class Program {
        static void Main(string[] args) {
            RestClient client = new RestClient();
            client.Execute(new RestRequest());

            ClientManager.SetCurrent("");

            Address address = new Address() {
                company = "Simpler Postage Inc",
                street1 = "164 Townsend Street",
                street2 = "Unit 1",
                city = "San Francisco",
                state = "CA",
                country = "US",
                zip = "94107",
                verify = new List<string>() { "delivery" }
            };

            address.Create();
            Console.WriteLine(address.id);
            Console.ReadLine();
        }
    }
}

Because this package is signed and the RestSharp team will not create their own signed version (restsharp/RestSharp#216) I am using RestSharpSigned. There is an open issue for the version numbers (restsharp/RestSharp#925).

I don't believe it is an actual issue unless you are experiencing problems. You can see the Newtonsoft.JSON maintainer's reasoning for pinning the assembly version number (http://james.newtonking.com/archive/2012/04/04/json-net-strong-naming-and-assembly-version-numbers). I do the same thing in this package. If you look at the version of EasyPost-Official it will be 1.0.0.0.

Let me know if you are having actual issues or if you run into errors regarding this and I will take a look.

@vongillern
Copy link

this issue should be fixed now if you update your EasyPost nuget package to 2.3.1.2. This is my PR that fixed the issue: #90

Long story short, the EasyPost nuspec was packaging the entire project and had the release build put all referenced assemblies in /lib/ and when you installed the EasyPost package, it would change the references for RestSharp and Newtonsoft to look in the /packaged/EasyPost****/lib/ directories instead of the RestSharp and Newtonsoft package directories.

In 2.3.1.2, only EasyPost assemblies are included in the package and the nuget package properly references the RestSharpSigned package instead of the older RestSharp package (the project was referencing RestSharpSigned, but the nuspec incorrectly had RestSharp)

IMPORTANT: It is possible and/or probable that when you upgrade to 2.3.1.2, you will need to go to and manually change your references to NewtonSoft and RestSharpSigned BACK to the relevant directories in your packages folder (i.e. /packages/NewtonSoft.Json.9.0.1/, /packages/RestSharpSigned.105.2.3/, respectively).

@vongillern
Copy link

Follow up. If you have any other nuget packages that rely on the UNSIGNED version of restsharp, you're about to endure a lot of pain because binding redirects won't work between the signed and unsigned versions/references. I understand why RestSharp didn't want to sign it, but it would have been a lot easier to deprecate the old nuget project and make RestSharpSigned the official one.

If you're in this boat, you can do a few things:

  1. Abstract out the different parts of your code that rely on the RestSharp and RestSharpSigned into different projects that don't reference each other and communicate via a queue or a message bus. This is a MAJOR pain in the ass for most people.

  2. Clone the source of Twilio (and/or any other project that uses RestSharp instead of RestSharpSigned), move the head to the proper version (FYI - Twilio doesn't have a tag for their 4.7.2 version). Change the nuget ref to RestSharpSigned. Possibly add a strong name to twilio (if you need it). Change your project references to the newly build custom Twilio Version. This is a MAJOR pain in the ass.

  3. Use Brutal Dev to sign twilio and restsharp's existing dlls. I've outlined the steps here at StackOverflow. This is still a pain in the butt, but it is much less invasive than the previous 2 options.

  4. Upgrade Twilio to 5.x which doesn't reference RestSharp anymore. Lots of breaking changes however. For projects other than Twilio an option is to just kill your need and find another way around.

My personal choice was to do option 3 as a temporary fix until I have time to do option 4 properly.

What a horrible, horrible mess. With any luck the next version of .Net will gain AI consciousness and kill strong naming.

@Yesuah
Copy link

Yesuah commented Sep 6, 2018

Hello,

Are there any official updates regarding this issue? We need to upgrade the EasyPost library due to TLS issues and this RestSharp versioning thing is preventing us from using the latest library. If anyone has some suggestions on what I can do to remedy this via Nuget install and not forking the code that would be great.

@att14
Copy link
Contributor

att14 commented Sep 28, 2018

RestSharp is now signed. I am upgrading to v106.4.2. Note that this only applies to .Net 4.5.2 and .Net Core.

Please reopen if you continue to have issues.

@att14 att14 closed this as completed Sep 28, 2018
@nesterenes
Copy link

@att14 I'm currently using RestSharpSigned on .Net 4.6.1. So this is still an issue for me because the EasyPost Library is requiring RestSharp. Why was this issue closed if it only resolves it for .Net 4.0 and lower or .NetCore 2.0?

@att14
Copy link
Contributor

att14 commented Oct 5, 2018

This library doesn't currently support 4.6. I can add support but that would be a different task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests