I am currently working on an Asp.Net MVC web project. My project is being used on 3 different web servers, each with their own SQL database. Recently I have been having a very annoying bug that doesn't hurt anything, but wastes my time and is making me pull my hair out.
The issue only occurs when I switch between web servers (ie, when I want to quit publishing to Site A and publish the change to Site B also), or when I make a change to the web.config file in my project.
This is a look at how my connection strings are sorted in my web.config. When I need to publish to site or test changes via localhost, I simply just comment the current string, and uncomment the desired choice.
Web.config code (Server C is being user here)
<connectionStrings>
<!-- Server A-->
<!--add name="MyEntities" connectionString="******;user id=********;password=**********;multipleactiveresultsets=True;application name=EntityFramework"" providerName="System.Data.EntityClient"-->
<!--Server B-->
<!--add name="MyEntities" connectionString="******;user id=********;password=**********;multipleactiveresultsets=True;application name=EntityFramework"" providerName="System.Data.EntityClient"-->
<!--Server C-->
<add name="MyEntities" connectionString="******;user id=********;password=**********;multipleactiveresultsets=True;application name=EntityFramework"" providerName="System.Data.EntityClient"/>
</connectionstrings>
If i were to comment out Server C, and then uncomment Server A and build the project, this error would occur:
BindingRedirect is missing required field 'newVersion'
When I double click and check the error's location it leads me to this line of code:
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" nembnwVersion="5.5.0.0" />
As you can see, "newVersion" somehow was changed to "nembnwVersion = "5.5.0.0""...
I then have to correct the error and rebuild again. Once rebuilding I get a message saying that my file has been edited, and needs to be reloaded. I reload and the error occurs. This happens every single time I change the web.config or attempt to edit what server I am currently using. How can I stop my web.config to automatically changing "newVersion" to the random string of characters? As i mentioned, its not a project-breaking bug but it sure is very annoying and wastes my time.
I encountered binding redirect do working because of a missing namespace on the assemblyBinding element.
Correct Code:
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="CMS.CompanyValues" publicKeyToken="1a696d1f90f6158a"/>
<bindingRedirect oldVersion="1.0.0.0-1.0.3191.28836" newVersion="1.0.3191.28836"/>
</dependentAssembly>
Incorrect Code:
Note missing: xmlns="urn:schemas-microsoft-com:asm.v1"
<assemblyBinding>
<dependentAssembly>
<assemblyIdentity name="CMS.CompanyValues" publicKeyToken="1a696d1f90f6158a"/>
<bindingRedirect oldVersion="1.0.0.0-1.0.3191.28836" newVersion="1.0.3191.28836"/>
</dependentAssembly>
Hope it will helps you.
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'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>
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.
Is it possible within the web.config to set the local file path location of specific DLLs to load rather than having those DLL in the GAC or C:\Windows\System32.
This would make it much easier to deploy the web service, without having to mess around with either of those.
I have tried already to add the DLLs to the project but with out success. They are the 4 oracle instant client DLLs.
oci.dll
orannzsbb11.dll
oraocci11.dll
oraociicus11.dll
If anyone knows of a way of doing this that would be great.
EDIT:
Please note, note of the DLLs are "strongly named" so I cannot reference them using their public key.
Also, they are not referenced directly in the project currently because they fail to add.
You can use the dependentAssembly element to specify where a dll lives through the codeBase element.
However, I believe this needs to be a valid URL.
Example from MSDN:
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="myAssembly"
publicKeyToken="32ab4ba45e0a69a1"
culture="neutral" />
<bindingRedirect oldVersion="1.0.0.0"
newVersion="2.0.0.0"/>
<codeBase version="2.0.0.0"
href="http://www.litwareinc.com/myAssembly.dll"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Probing paths let you specify where an application should look for assemblies. This won't affect putting things in the GAC, but gives you an alternative to storing everything in the bin folder.
http://msdn.microsoft.com/en-us/library/823z9h8w.aspx