Problems with Report Viewer assemblies on production site - asp.net

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.

Related

Could not load file or assembly 'App_Code' or one of its dependencies.

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.

bindingRedirect suddenly stopped working

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>

Newer version of Telerik.Web.UI (trial version) not found

A client or ours is asking us to look at his application to fix a few bugs but his application references Telerik.Web.UI. I downloaded a trial version of Telerik on my machine hoping that that would work but I get the error: Could not load file or assembly 'Telerik.Web.UI, Version=2014.3.1024.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4' or one of its dependencies
When I look at my version it's version 2015.1.225.40. How does one solve these types of situations, especially when you just want to help a client? I tried to do some binding redirect:
<runtime>
<dependentAssembly xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity name="Telerik.Web.UI" publicKeyToken="121fae78165ba3d4" culture="neutral"/>
<bindingRedirect oldVersion="2014.3.1024.35" newVersion="2015.1.225.40"/>
</dependentAssembly>
But that didn't work. Still get the same error.
Open a ticket with Telerik and ask for access to the version you need.
That aside, a bindingRedirect should usually work, but you should target the .NET 3.5 build (2015.1.225.35) you can get from the bin35 folder in the installation.
It turned out to be that the .aspx pages had a directive at the top that referenced the Telerik.Web.UI, including the version number. After I installed the trial version, and referencing it (even though it's a newer version), all I really had to do is rem out the directive at the top of the .aspx pages and the app was able to reference the assembly and the application worked. Hope this helps anyone that might go through the same path.

Could Not load NewtonSoft.JSON after deploying MVC app to Azure

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.

ASP.NET value changing on method call

This is driving me nuts!
I have an asp.net application on my server. It references two dll-files which are placed in my GAC on the server. I have also placed pdb-files in the GAC-folders so I can debug remotely.
Here is my problem:
When I call the following:
addToAbsenceList(e.Initials, a.StartDate, a.EndDate, a.Type.TypeId, vacationDays);
I can see that e.Initials contains the value "OFR".
When I press F11 to jump into addToAbsenceList:
addToAbsenceList(string initials, DateTime startDate, DateTime endDate, int AbsenceType, double duration)
the variable initials now contains the value NULL.
I have just corrected this problem (previously it always sent NULL - now it works), so somehow it seems as if it still gets information from my previous code.
I only have one version of the dll in my GAC folder.
I have made sure that the version in my dll-folder is the new version (based on date of the file).
To be 100% sure I have also put the new dll-file in my BIN folder of the project.
When decompiling the dll-file with dotPeek from JetBrains I see that it contains my corrections.
I have tried restarting my web application from IIS
It works in my development environment.
So somehow it seems as if the old dll file is still active in my GAC. How can I assure that the new one is invoked? Preferable not by restarting the production server.
Server: MS Windows 2008 R2 64-bit
Deveveloment: Windows 7 32-bit
If you have 2 dlls of same assemble in the GAC than in web.config you can specify that which dll must be used as:
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="YourClassLibrary" publicKeyToken="b035c4774706cc72" culture="neutral"/>
<bindingRedirect oldVersion= "1.0.1830.10493" newVersion= "1.1.1830.10461"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
In newVersion you can specify that which version must be used.
Believe I have to "upgrade" my comment to an answer:
And now it works! I tried opening a command prompt as administrator. Then I copied the dll-files directly into the GAC-folders. Then it worked. Why it should be different from opening a Windows Explorer in administrator mode and copying the same is a mystery to me. Also because I did check date/times and they were updated correctly. –

Resources