I have a simple question about adding references to a .NET project. I'm adding reCAPTCHA to a website and i have downloaded the dll.
After setting the reference to the dll i build and run the project and gets this error:
[ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.]
System.Reflection.Module._GetTypesInternal(StackCrawlMark& stackMark) +0
System.Reflection.Assembly.GetTypes() +96
StarSuite.Core.Settings.GetSingletonInstancesOfBaseType(Type baseType, String staticMethodName, Type returnType) +149
[ApplicationException: Unable to load types from 'Recaptcha, Version=1.0.5.0, Culture=neutral, PublicKeyToken=9afc4d65b28c38c2'. LoaderExceptions: [FileNotFoundException: Could not load file or assembly 'System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.]
]
What am i missing, why do i get this error?
Sorry if the question is silly...Is it your web project MVC? It seems that If you're using web form based project you shouldn't use that component since it relies on mvc assemblies (maybe there is a web form version?).
File Not Found:
This is you reason - its in the output:
FileNotFoundException
Double check where your reference is pointing to
Have you added the DLL under references in your project so it will be included in the build?
For people finding this whilst searching for a fix for Umbraco, the fix can be found here:
http://our.umbraco.org/forum/developers/xslt/19383-referencing-catcha-dll-breaks-xslt
The same fix can be applied to websites that are not running Umbraco.
Summary to save you having to read the whole forum post, add this to your web config:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0"
newVersion="2.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
Related
Can anybody help to resolve this.
I have added third party reference (Json newtonsoft) dll in my script component, but when i run the package through sql server agent, I am getting an error
Could not load file or assembly 'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.
I have registered the dll in gac and same dll (even same version) is also used in uat but while executing on prod it is getting failed.
Any suggestions?
Firstly I would check that the version in the web.config matches the version of the DLL. Right click on the newstonsoft.dll and go to details tab, product version.
You should then have a corresponding assembly identity in your web.config like
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json"
publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-10.0.0.0"
newVersion="10.0.0.0" />
</dependentAssembly>
Also if you have multiple projects in your solution then right click your solution, manage nuget packages for solution and go to the consolidate tab to check that you don't have multiple versions of newtonsoft
Finally resolved the issue-
The command to register DLL was having space before the DLL name. While registering through cmd it showed registering success however the folder was not created in gac_msil location I. E. dll was not registered.
I am adding a Web Reference in my website. Reference is added successfully. But when i add namespace in my webpage it give me following error.
Error 22 Reference.svcmap: Could not load file or assembly
'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral,
PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot
find the file specified. App_WebReferences/FaxService/
Namespace name I give to my web reference is "FaxService".
In pages.aspx.cs page I have added
using FaxService;
What I have tried.
1) Removed web reference and add it again.
2) Update web refernce
3) Uninstall newton soft from "Pakage Manager Console" and removed all the dll's of newtonsoft from my solution.
PM> UnInstall-Package Newtonsoft.Json
4) Installed newton soft again through "Pakage Manager Console".
PM> Install-Package Newtonsoft.Json
5) Adding following lines in web.config
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
</dependentAssembly>
</assemblyBinding>
This web reference is not newly added. It was working fine before.
Error says about Version=6.0.0.0, try to find where is reference to it? But your web.config uses 7.0.0.0. Try to find reference to 6.0.0.0 and delete it.
My thoughts are:
- maybe one of dependencies of it was updated and now it cannot be loaded?
- use option "DELETE ALL" before deploy, maybe something old is there in deployment directory.
I am implementing sign-in with google-plus in my web. But after signing in, this error occurs,
Could not load file or assembly 'System.Net.Http.Primitives,
Version=1.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or
one of its dependencies. The located assembly's manifest definition
does not match the assembly reference. (Exception from HRESULT:
0x80131040) Please try again in several minutes.
I've tried every steps that is mentioned here : Could not load file or assembly System.Net.Http.Primitives. Located assembly's manifest definition does not match the assembly reference
At last, I've fixed this problem with adding this to machine.config :
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Net.Http.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
Problem : I don't want a machine.config changed so I want to move it to web.config on a root folder of my web.
Is there any other solution?
Finally I found how to fix this..
deleting xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0" from tag fix my problem.. I don't know what's the side effect of that action, can someone tell me??
So I was persistently getting this error on the System.Web.Optimization package
Could not load file or assembly 'System.Web.Optimization' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
I finally found the solution after much trying.
The key was in the Assembly load trace.
LOG: Redirect found in application configuration file: 1.0.0.0 redirected to 1.1.0.0.
Here are the steps I took to resolve the issue. It might be possible to skip some of these but this worked for me:
Uninstall the nuget package
Microsoft.AspNet.WebOptimization.WebForms
Delete bin folder
open web.config and locate the redirection.
It will look something like this:
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
</dependentAssembly>
</assemblyBinding>
I removed the entire assemblyBinding section from the web.config.
Finally re-install the Microsoft.AspNet.WebOptimization.WebForms
package and rebuild.
I don't know where this section came from in the web.config but having removed it everything seems to be working once again.
We are getting an assembly conflict after we updated Newtonsoft.Json. I am having trouble understanding where the specific version that is referenced in the error is coming from. There is nothing in the web.config that points to a specific version.
System.IO.FileLoadException: Could not load file or assembly
'Newtonsoft.Json, Version=3.5.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)
Would GAC-ing the two versions of the assembly work to solve the issue?
As #jammykam commented in marto's answer you can redirect the assembly. I have done this in the past with Newtonsoft and Sitecore without a problem. You can take a look at my Sitecore Content as Service code where I have it working.
You are specifically interested in these lines in the web.config file:
https://github.com/HedgehogDevelopment/sitecore-content-service/blob/master/Sitecore/Web/Web.config#L3499
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.8.0" newVersion="4.5.0.0" />
</dependentAssembly>
GACing them might work but it will create a maintenance nightmare. Don't do it!
I think you have 2 options:
Use the version that came with Sitecore which will depend on which version of Sitecore you are running.
Leave the one sitecore version untouched and use ilmerge to combine the Newtonsoft.Json version you need with your own assembly.
I would recommend 1 if you don't need any of the most recent features of the library like (dynamics... etc)