RestSharp dll in SharePoint 2013 - sharepoint-2010

I am trying to make Rest Call through C#, to do that I am using RestSharp dll.
I have created farm level solution and added webpart, then installed RestSharp through NuGet.
The issue I am facing is in following line:
var client2 = new RestClient(webURL);
The moment I add this line, I am getting 'does not have strong name' error.
Referenced assembly 'RestSharp, Version=105.0.0.0, Culture=neutral, PublicKeyToken=null' does not have a strong name.
Then I created a console application added same dll and tried, it worked.
Then I created a simple web application and then added same dll and tried, it worked.
It is only failing when I am trying through webpart.
I really appreciate if anyone can guide me or give me some tip to solve this issue.

Have you tried signing your DLL with the key.snk file provided to you in your SharePoint project? Most of the time, 3rd party libraries need to be rebuilt with the snk file.
You just need to use ildasm to convert your dll to an .il file then use the ilasm to sign your il file with the snk file and convert it back to .dll
Let me know if you need more details regarding this.

Related

How to bundle c++ dll files?

I am working on a Dot Net project and I am using C++ .dll files. I want the output of the program as just a single .exe file(which can easily be given to the customer) rather than multiple files. I have added those files under Properties>> Resources. However, when I tried adding them as Reference, I get the following error: Please make sure that the file is accessible and that is a valid assembly or COM component.
Is there a way to bundle these file into one without using 3rd party tools/extensions?
Plz advise.
Thanks in advance.

Error CS0433 The type 'WebUtility' exists in two places

I'm creating an asp.net core app using Visual Studio 2017. I'm trying to encode a URL component using web utility.
var value = System.Net.WebUtility.UrlEncode("some text here");
When I include that in my code, I see the below error. I'm at a loss as to finding the issue. I see no project.json file. I have searched for anyplace where System.Runtime.Extensions are being included.
I have the following packages installed: AspNetCore, AspNetCore.Mvc, AspNetCore.StaticFiles, .netCore.App, PaulMiami.AspNetCore.Mvc.Recaptcha
I have tried to remove the captcha package without it fixing the issue.
Error CS0433 The type 'WebUtility' exists in both 'System.Runtime.Extensions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
Other posts I've seen about this issue ask for a project.json file, which I don't seem to have. Any thoughts?
Update 1:
I tried to create a new asp.net core web app - all defaults out of the box, I then installed the PaulMiami.AspNetCore.Mvc.Recaptcha package, the call to WebUtility works fine in the newly created app. There must be something I'm not finding in the existing application that is causing this issue.
I found the problem.
Under “Dependencies” I noticed an entry for Assemblies, and in that was an entry for “System”. I’m not sure how it got there, but after removing it my issue went away and the app compiles.
In the future, I’ll be sure to check this location. Of note, the newly created out of the box asp.net core web app I created had no entry for Assemblies in the Dependencies list. I must have added a package and then removed it, which caused this issue. (perhaps the asp.net pre-.net core captcha framework by mistake?)

Reference VB.NET DLL in Kofax Document Validation Script

We are working on a validation script for Kofax Capture 9.0 / 10.0 in VB.NET 3.5.
We know how to create a script using the Admin Module, and how to get it operational.
The problem is that we need to reference a dll, located on a remote machine. (GAC is no option) This dll holds abstract classes we need in each validation script.
Even when putting the dlls locally (copy local), the Validation Module (index.exe) immediately throws the "cannot find reference" exception, even though the project compiled perfectly.
I guess the basic question comes down to: where do we put the dlls, in order for the Validation Module to find them?
The simple answer is to put the dll in the same folder as the application because this is one of the places which .NET will probe when trying to find it. The Validation module is run from the Capture bin directory which will be something like "C:\Program Files (x86)\Kofax\CaptureSS\ServLib\Bin\". This would need to be done on each client using Validation.
If you have a more complicated scenario, you could look implementing the AppDomain.AssemblyResolve Event and using Assembly.LoadFile to get the assembly from a custom location, but the using the bin path is less complicated.
If you end up having further trouble, you can troubleshoot by using the Assembly Binding Log Viewer (Fuslogvw.exe) which can tell you more details about why the assembly failed to load and where .NET tried to search for it. Assembly loading can fail for reasons other than just the path.
For more detail on how .NET loads assemblies, see the following:
How the Runtime Locates Assemblies
Locating the Assembly through Codebases or Probing
We found a solution: add all library files as "links" to the project. (Add --> Existing File --> small arrow next to "Add" --> Add as Link)
This ensures the files are compiled when you build the project. The Kofax Validation Module can now find the files, whereas when referencing the file, it could not. Why it could not, remains a mystery...

Can't load assembly at runtime

I'm working with a 3rd party assembly to implement something in our in-house software. I can make the refence and work with the library without a problem, but when I run the program to test it i'm getting this error
"Can't load file or assembly "assembly file" nor either of its dependencies. The system couldn't find the specified file" (i'm from Mexico, exception is in Spanish so i had to tanslate it, sorry for the poor translation)
I have given read and write permission to the file, the folder, and for all users and still wont load it.
I saw that the assembly has the PublicKeyToken=null, does that have any to do with that i cant load the assembly????
I already asked the people who developes this assembly, but i'm not getting any response and I really wanna get this project finished
If this is a web application, is the DLL in the bin folder? If it is a deskop application, is it in the same directory as the executable? If not, you may need to set the "Copy Local" attribute on the dll to true in Visual Studio.
Assembly Binding Log Viewer:
The Assembly Binding Log Viewer displays details for assembly binds. This information helps you diagnose why the .NET Framework cannot locate an assembly at run time.
Plus to what Chris said, you have to ensure that if the 3rd party dlls need any other dlls then they must be also in the bin directory, (you can check this by looking at the original directory of the 3rd party dlls and copy all dlls that come with it)

VB.Net plugin using Matlab COM Automation Server...Error: 'Could not load Interop.MLApp'

My Problem: I am using Matlab COM Automation Server to call and execute matlab .m files from a VB.Net plugin for a CAD program called Rhino 3D. The code works flawlessly when set up as a simple Windows Application in Visual Studio, but when I insert it (and make the requisite reference) into my .Net plugin and test it in the CAD program I get the following error:
"Could not load file or assembly 'Interop.MLApp, Version 1.0.0.0,
culture=neutral, PublicKeyToken=null' or one of its dependencies.
the system cannot find the file specified."
What I've Tried: I am baffled as to why this occurs, but I was able to contact the CAD program's technical support staff and they suggested that it has something to do with their DotNet SDK having trouble with references that are located far outside the CAD program directory. They didn't have any solutions so I tried playing around with copylocal and this made no difference. I tried using other COM libraries and the Open Office automation server works fine, although uses url's instead of requiring a reference. I also tested Excel, which does require a reference, and it returned the error: "retrieving the COM class factory for component with CLSID {...} failed due to the following error: 80040154." This may or may not be related to the issue with the Matlab COM reference, but I thought was worthwhile to share. Perhaps is there another way to reference Interop.MLApp?
I would appreciate any suggestions or thoughts on how I might make the Matlab Interop.MLApp reference work.
Best regards,
Ben
Try moving the assembly file(s) for MLApp into the bin directory. Based on everything I've read, this seems to be a glitch of some sort during the generation of the assembly binding where all the assemblies are merged together and their locations are assumed. I've included some links where I gleaned a bit of information about it.
http://blogs.msdn.com/isha/archive/2009/04/04/issues-with-wcf-service-when-the-asp-net-website-is-deployed-using-the-web-deployment-project-and-as-non-updatable-project.aspx
ttp://social.msdn.microsoft.com/Forums/en/netfxremoting/thread/30df57a8-2a57-4f9f-a120-30c24bc11681
ttp://social.msdn.microsoft.com/Forums/en/netfxremoting/thread/30df57a8-2a57-4f9f-a120-30c24bc11681
ttp://www.sitefinity.com/support/forums/sitefinity-3-x/bugs-issues/cannot-load-file-or-assembly-error.aspx
ttp://forums.asp.net/t/986130.aspx?PageIndex=8
ttp://stackoverflow.com/questions/408002/could-not-load-file-or-assembly-xxxx-or-one-of-its-dependencies-the-system-can