I'm having a problem with bindingRedirect in the web.config file for a website.
These are the circumstances. I have the 4.1.0.0 version of a third-party assembly. I have another third-party assembly that references version 4.0.0.0 of the first assembly. And I have a bindingRedirect in my web.config which causes 4.1.0.0 to be loaded when 4.0.0.0 is asked for. This works in my development environment and, until 5 days ago, it worked on the hosting company's server, where the production website is. But five days ago I started getting an error on the hosting company's server saying that version 4.1.0.0 could not be found -- in other words, suddenly my bindingRedirect was being ignored.
Since I haven't made any changes, I am assuming that something in the hosting company's environment changed. I'm trying to work with the hosting company's tech support team, but they don't seem to completely understand bindingRedirect and the question "what changed in your environment on Saturday?" is too broad for them to answer. Perhaps if I could pin down what sorts of changes could cause a bindingRedirect to stop working I might have a chance at getting their tech support team to dig a little more deeply on their end.
Thus, my primary question to this forum is "what could have changed in the environment that would cause the bindingRedirect to suddenly be ignored?" Could a change to machine.config have done it? What else could do it? I am not [yet] asking for actions I can take on my end to make it start working again -- I need more information before I try to fix it or ask for advice.
This is the relevant portion of the web.config file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="DotNetOpenAuth.Core"
publicKeyToken="2780ccd10d57b246" />
<bindingRedirect oldVersion="1.0.0.0-4.0.0.0"
newVersion="4.1.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Related
Problem: I want to deploy modified code into web server. web server is having IIS version set to V2.0. and now I have developed and published code on my local machine with version 4.0. (there is App_code.dll as part of all dll files).
Now whenever I am deploying all files along with App_code.dll I am getting following error:"
Could not load file or assembly 'App_Code' or one of its dependencies.
This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded"
1) My question is how do I build App_code.dll in older version.
2) I tried changing target framework to V2.0 while publishing but then its not working because AJAX functions from other dll are not compiling..
can anyone please suggest what to do to run the site..
Help is appreciated.
Thanks
Sorry about the answers I've given... But try this...
Try adding <codeBase> elements to the application config file to specify the exact location of each dll, and the version of .Net it requires. Apparently this works because <codebase> is checked BEFORE the probing heuristics kick in each time an assembly needs to be loaded.
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="sharedlibA" culture="neutral" publicKeyToken="..." />
<codeBase version="1.0.0.0" href="bin\sharedlibA.dll" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="sharedlibB" culture="neutral" publicKeyToken="..." />
<codeBase version="1.0.0.0" href="bin\sharedlibB.dll" />
</dependentAssembly>
</assemblyBinding>
</runtime>
If that doesn't work try this.
Late answer but, I'm writing this for future viewers.
I had same error after publish the application to the Server.
I figure it out doing like this.
While publish there is configuration in Setting.
In publish section there is option called
Precompile during publishing
you have to check the checkbox and save then Publish. This will takes your code files .vb/.cs and converts them into a compiled DLL files.
In my case it was unchecked.
I recently setup a new Windows 10 workstation , imported my IIS settings from previous windows 10 IIS.
Everything is setup correctly with IIS, however everytime I run a new project I get an error about Missing System.Web.WebPages.Deployment :
Could not load file or assembly 'System.Web.WebPages.Deployment, Version=1.0.0.0
The fix is simple, I just add the following to the web config.
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31BF3856AD364E35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-X.X.X.X" newVersion="X.X.X.X"/>
</dependentAssembly>
</assemblyBinding>
The problem is that now just because I'm having an issue I'm forcing a checkout on all projects and questions from other developers all of which do not have this issue. I've attempted to re-register .net framework like I did back in the day, however that's now part of Windows 10 to include 4.6.2
This is happening on older ASP.NET WebForms written in VS2013 with a mix of newer MVC apps written in VS 2015.
I've found nothing to address a System wide issue with this assembly.
Make sure you have System.Web.WebPages.Deployment.dll on your BIN folder.
I've deployed a MVC 4.5 web site here
However, when I view the site in browser after deployment, I have to turn custom errors off to see the following error:
Exception Details: System.IO.FileNotFoundException: Could not load file or assembly
'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or
one of its dependencies. The system cannot find the file specified.
I ensured that CopyLocal is set to True for the DLL in my References folder. What other changes need to be made for a successful deployment?
I was having this same issue today and I'm not completely sure what I did to fix it. So I'll try giving a detailed walk through of my process.
I tried deploying a default app out of VS13 and it was too bombing with this message. FAIL.
I then removed the Newtonsoft.Json assembly and manually added the 5.0.6 version I needed. I also made sure CopyToLocal was set to true. FAIL. My sadness grows.
I enabled NuGet Package Restore. FAIL. My sadness turns to anger.
I deleted my Azure site in a fit of rage, recreated it, and the republished out again. SUCCESS!!!
So, the only logical(ish) answer I think I can give is to delete your Azure website, recreate it, and then publish again.
I hope this helps someone.
I fixed this problem by redirecting the assembly version from 0.0.0.0-6.0.0.0 to 6.0.0.0
by adding a depententAssembly in Web.config:
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<!-- Add these 4 lines to Web.config, under runtime/assemblyBinding -->
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<!-- End of copy -->
</assemblyBinding>
</runtime>
<configuration>
You will find other dependentAssemblies there too, like System.Web.Mvc, WebGrease.
The newest version of Newtonsoft.Json is now 6.0.3. You may have to increase 6.0.0.0 later. Find the current newest version by looking at the version in the Solution Explorer. References -> Newton.Json -> (right click -> Properties) -> Version in the Property view
If you're sure CopyLocal is true, then the only other possibility is that you have project reference to a different assembly version than what's listed in your packages.config. Make sure the DLL version matches the version in the packages.config.
we switched recently our asp.net 3.5 solution from VS 2008 to VS 2010 while still wanting it to be in .net 3.5 (as the deployment server runs on 3.5 only)
The libraries are ok, but the web site is causing us problems. The error message we get on every aspx page is like this:
D:\WebSites\.....aspx: ASP.NET runtime error: Could not load type 'Microsoft.Build.Framework.ITaskItem2' from assembly 'Microsoft.Build.Framework, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
I found out that the interface the compiler is looking for (ITaskItem2) is only available in .net 4.0, but it keeps looking for it in 3.5 assembly which is obviously wrong.
We were trying to locate where this discrepancy is originating, but with no luck.
It hinders our work significantly, because the intellisense is not working for asp components, also debugging of the web pages is not working.
But even when this error occurs in VS, the pages work ok when displaying them in browser (using IIS), so this is VS-only problem.
If you have any idea, what could be wrong here, please let me know.
Thanks
So, I managed to get things right after lots of experimenting.
The solution was to let the VS generate new standard web.config for web site and adding the few extra options we are using into it..
There are only 2 differences between the old and new web.config:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
was changed to
<runtime>
<assemblyBinding appliesTo="v2.0.50727" xmlns="urn:schemas-microsoft-com:asm.v1">
Not sure if this affects something.
But what seems more important, in the non-working web.config there was one additional section in <runtime>:
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Build.Framework"
publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-99.9.9.9" newVersion="3.5.0.0"/>
</dependentAssembly>
</assemblyBinding>
I am not a web.config guru and I do not see what's wrong with the provided section, but without it the things started to work miraculously.
I'm having a weird issue with report viewer on my production site. I have a stage and demo version of the site deployed on the same machine. Recently I've been working on an update and have been deploying to the stage version which works fine. Today I deployed to Demo and suddenly the report viewer is broken, only on Demo.
The error I'm getting is:
CS0433: The type 'Microsoft.Reporting.WebForms.ReportDataSource' exists in both
'c:\Windows\assembly\GAC_MSIL\Microsoft.ReportViewer.WebForms\10.0.0.0__b03f5f7f11d50a3a\Microsoft.ReportViewer.WebForms.dll'
and 'c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\h2o-demo\d354e6e4\ac3ce3e\assembly\dl3\67b85cd6\0027fec0_ed32ca01\Microsoft.ReportViewer.WebForms.DLL'
The project was updated from Report Viewer 9 to 10 in this update. All references in the Web Config have been updated as well as in my project's "References". I have noticed that the version that is getting put in "Temporary ASP.NET Files" is actually version 9 for some reason.
Again to recap; the project works fine on my local machine. It also works on the Stage site which is deployed on the same server as the broken Demo site.
Does anybody have any ideas on what I can do to troubleshoot this? I can't seem to find any resources that have solutions that are working for me. I tried the compilation batch = false and adding an assembly bindingredirect from 9 to 10 (though I suppose I could have done this incorrectly). I'm just really confused on why it would work on one site but not the other.
EDIT 1: After some more looking around I tried the binding redirect again. My config file now looks like this:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="log4net" publicKeyToken="1b44e1d426115821" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.2.10.0" newVersion="1.2.10.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.ReportViewer.WebForms" publicKeyToken="b03f5f7f11d50a3a" />
<bindingRedirect oldVersion="9.0.0.0" newVersion="10.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.ReportViewer.Common" publicKeyToken="b03f5f7f11d50a3a" />
<bindingRedirect oldVersion="9.0.0.0" newVersion="10.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
The "Log4Net" redirect was already there and is the only thing there on stage. After adding the "WebForms" I got an error on "Common" and so I added that one too. Now I'm getting this error:
Could not load file or assembly 'log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821' or one of its dependencies. The system cannot find the file specified.
This error looks like you have multiple assemblies, then corrected that issue by pointing to explicit GUID of assembly now you are missing one. Can you verify that the 'log4net' assembly even exists? I would take a look at an existing working SSRS system if you have one. See if that config is the same and if that file for the assembly exists. If it does you could always attempt a copy of it to the non working environment. In many cases assemblies or class libraries are either getting changed or overwritten by one installment over the other. Running multiple versions of similar products on one machine is hard at times.
I do it at home with SQL Server running on my Dev box for 2008 Enterprise, 2008R2 express, and 2012 Developer. I get lots of issues with hex errors and their pointing to problems where it cannot locate a file. The simple answer is don't install multiple versions of the same product on the same machine if you can help it but I know that is not always applicable for testing on the cheap or what you have. Generally with DLL issues with duplication I relist one to dllOLD or similar and see if it then works. If you are doing the more proper method and listing explicitly, which you are. I would just ensure the DLL's really exist and could remote to anther environment via RDP and have that screen up at the same time. Hopefully you have two monitors to see one environment compared to the other ;)
I figured it out. Turns out there was an old DLL hanging out in the Bin directory on the demo site. It wasn't getting overwritten with a new version because it's not in use anymore so it was just sitting there messing with the project somehow. I cleaned out the bin directory on the Demo site and then did a re-deploy and it worked fine. Thanks for the help guys.