سؤال

My application requirement is to use Signed assembly. I signed RestSharp assembly using Visual Studio 2012 command tool. The application builds successfully, but when it runs, the following error appears:

Could not load file or assembly 'RestSharp, Version=104.4.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. A strongly-named assembly is required. (Exception from HRESULT: 0x80131044)

Is there any solution to this?

هل كانت مفيدة؟

المحلول 2

The blog http://buffered.io/posts/net-fu-signing-an-unsigned-assembly-without-delay-signing/ has helped me to solve the problem. Actually I am using twilio.api.dll in my project and twilio.api.dll is referencing RestSharp.dll. Now after making RestSharp as "Strong Name", it was required to enter Public Key token in Twilio assembly so that it can access RestSharp.

The problem has been fixed now.

نصائح أخرى

Just a remind, There is signed version of RestSharp(RestSharpSigned) in Nuget.

There is a way to add strong name to an existing dll. All you need is sn.exe, ildasm.exe and ilasm.exe These are .NET Framework tools designed by Microsoft: https://learn.microsoft.com/en-us/dotnet/framework/tools/ . To run these tools, use the Developer Command Prompt for Visual Studio.

Step 1: You should create a key file using sn.exe:

sn.exe -k C:\IAmWorkingHere\KeyFile1.snk

A KeyFile1.snk was created to C:\IAmWorkingHere folder. We will use it in step 3.

Step 2: Use ildasm.exe to "extract" IL code, resources etc. from the dll.

ildasm.exe /out c:\IAmWorkingHere\RestSharp.il

It is depending on your RestSharp version, but for me 2 file was created a RestSharp.il file that contains the IL Code in text format, and a RestSharp.res file that contains the resource information of the dll.

Step 3 (Rename the original RestSharp.dll if you want to keep it safe) and use ilasm.exe to create your strong named RestSharp.dll

ilasm.exe c:\IAmWorkingHere\RestSharp.il /dll /key=c:\IAmWorkingHere\KeyFile1.snk /resource:c:\IAmWorkingHere\RestSharp.res

And your strong named RestSharp.dll was created.

I hope it is help.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top