Problems with ReportViewer assemblies in VS2010 - asp.net

I'm using the ReportViewer 10.0.0.0 from VisualStudio2010 into my Web Application and I'm having problems with it's assemblies.
The server have ReportViewer 8.0.0.0 and 9.0.0.0 installed and I'm trying to avoid the installation of the 10.0.0.0 version.
I was thinking if it's possible to use the ReportViewer10 dll's on the server even not having it installed. I set the Build Action property of the dlls to Content for them to be copied to the output bin folder. The property Copy to Output Directory is Do not copy.
As the following error shows, my project is finding two assemblies from ReportViewer, one in the GAC and another in the Temporary ASP.NET Files. Searching, I've discovered too that the Temporary ASP.NET Files are re-generated each request to the server.
Trying to solve my problem, I deleted the dll from the Temporary ASP.NET Files and the whole application stop working, showing that my application was using the dll from the Temporary ASP.NET Files, not from GAC or the bin folder. I want to set my application to use the dll from the bin folder OR the Temporary ASP.NET Files, because in these places the dll is in it's correct version (10.0.0.0). The error below shows a conflict between the ReportViewer9 dlls from GAC and ReportViewer10 dlls from Temporary ASP.NET Files.
An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
CS0433: The type 'Microsoft.Reporting.WebForms.ReportViewer' exists in both
'c:\\WINDOWS\assembly\GAC_MSIL\Microsoft.ReportViewer.WebForms\9.0.0.0__b03f5f7f11d50a3a\Microsoft.ReportViewer.WebForms.dll' and 'C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\project\4ec9147f\d072b522\assembly\dl3\662a86a1\009c93d3_afeccc01\Microsoft.ReportViewer.WebForms.DLL'
Line 180:
Line 181: [System.Diagnostics.DebuggerNonUserCodeAttribute()]
Line 182: private global::Microsoft.Reporting.WebForms.ReportViewer #__BuildControlReportViewer1() {
Line 183: global::Microsoft.Reporting.WebForms.ReportViewer #__ctrl;
Line 184:
Source File: C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\project\4ec9147f\d072b522\App_Web_default.aspx.cdcab7d2.dmkwuxko.0.cs
Line: 182

My problem was solved by doing the following:
I left the dlls be referenced by my project but I've removed them from the bin folder. This way the dll's stopped being re-generated inside Temporary ASP.NET Files folder, ending the conflict:
CS0433: The type 'Microsoft.Reporting.WebForms.ReportViewer' exists in both
'c:\\WINDOWS\assembly\GAC_MSIL\Microsoft.ReportViewer.WebForms\9.0.0.0__b03f5f7f11d50a3a\Microsoft.ReportViewer.WebForms.dll' and 'C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\project\4ec9147f\d072b522\assembly\dl3\662a86a1\009c93d3_afeccc01\Microsoft.ReportViewer.WebForms.DLL'
Report Viewer kept not working, how it was expected to (GAC had only versions 8 and 9 of the dlls). Then the Report Viewer 10.0.0.0 was installed on the server, and this time a new error has shown:
CS0433: The type 'Microsoft.Reporting.WebForms.ReportViewer' exists in both
'c:\\WINDOWS\assembly\GAC_MSIL\Microsoft.ReportViewer.WebForms\9.0.0.0__b03f5f7f11d50a3a\Microsoft.ReportViewer.WebForms.dll' and 'c:\\WINDOWS\assembly\GAC_MSIL\Microsoft.ReportViewer.WebForms\10.0.0.0__b03f5f7f11d50a3a\Microsoft.ReportViewer.WebForms.dll'
I thought that was strange that this conflict had happened between different versions of the dlls, and this time the solution was to add the following tag to the web.config file:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1" appliesTo="v2.0.50727">
<dependentAssembly>
<assemblyIdentity name="Microsoft.ReportViewer.WebForms" publicKeyToken="b03f5f7f11d50a3a"/>
<bindingRedirect oldVersion="9.0.0.0" newVersion="10.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
Done. It worked without any conflict and it was possible to export the reports.
My problem was solved, but I still have one doubt, and I hope someone help me with this one:
Why did the server had the conflict between two dll's from GAC_MSIL within different versions? Shouldn't the server look only for the version I've referenced in my project and specified in the Web.config? (10.0.0.0)
Does it have any relation with the machine.config file?

Related

Telerik doesn't work after moving project to another env

i moved my project from one env, and from then on i have issue running my application.
The error i receive below.
'Could not load file or assembly 'Telerik.Web.UI, Version=2016.2.504.45, Culture=neutral, PublicKeyToken=121fae78165ba3d4' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)'
The error code 0x80131515 usually tells that the assembly file has been blocked or not referenced properly (because VS thinks referenced assembly still untrusted). Here is an explanation from Telerik's FAQ:
Operation is not supported HRESULT: 0x80131515
The HRESULT: 0x80131515 error usually means that the file was downloaded from the Internet and
Windows has blocked it. In such cases you need to simply do the
following:
In Windows Explorer, right-click the file.
Select Properties
Click the Unblock button.
Clear the read-only attribute.
Other things you should try to solve this issue:
Using bin folder assembly deployment
Copy Telerik assemblies to \bin folder and use reference from that folder.
Restart VS IDE.
Using GAC assembly deployment
Add Telerik.Web.UI.dll assembly to GAC using this command:
gacutil /i "[InstallDir]\BinXX\Telerik.Web.UI.dll
Note: [InstallDir] belongs to Telerik location path and "X" means numeric value which should be adjusted based on folder hierarchy.
Remove previously used Telerik.Web.UI.dll from bin folder and add reference to the newer one.
Ensure that this line exists in web.config:
<add assembly="Telerik.Web.UI, Version=2016.2.504.45, Culture=neutral, PublicKeyToken=121FAE78165BA3D4" />
Restart VS IDE.
If all possible solutions above are fruitless, create a new project with current Telerik assembly and all required assemblies then move old project files into new project.
Additional references:
Could not load file or assembly 'Telerik.Web.UI'
Upgrade Compile Error
Visual Studio Project Sample Loading Error: Operation is not supported. (Exception from HRESULT: 0x80131515)
Having two versions of Telerik DLLs in the solution is also a culprit. In my case I had subproject that was using a different version of .Net and hence, Telerik DLLs.

Visual Studio looks for dll in the wrong directory

I am getting an error of "Could not load file or assembly 'Microsoft.AI.Web' or one of its dependencies" in the browser of my asp.net app. Microsoft.AI.Web is from Microsoft.ApplicationInsights.Web NuGet package.
I noticed this:
LOG: Appbase = file:///D:/Source/Workspaces/AppName/Branches/Main/Application/WT/
LOG: Initial PrivatePath = D:\Source\Workspaces\AppName\Branches\Main\Application\WT\bin
the dll in question is located at D:\Source\Workspaces\AppName\Branches\Main\Application\packages\Microsoft.ApplicationInsights.Web.2.4.1\lib\net45\Microsoft.AI.Web.dll
As for personal dll's -- In the project-->properties-->build-->output path--> I have it set as "..\Any\Debug\". When I build the project the DLL's populate there.
I checked References and code in .csproj file and all the dll are located where I specified to.
I am not sure why it's trying to look at the bin file of the project when I told the output is somewhere else AND to look for the dlls in that same folder(through references and .csproj file). How do I make it so that VS will look for the dlls in the folder path I want instead of "WT\bin"?
When I change my project output path to "bin", it can detect the dll's there EVEN though the path of the dll remains the same( D:\Source\Workspaces\AppName\Branches\Main\Application\packages\Microsoft.ApplicationInsights.Web.2.4.1\lib\net45\Microsoft.AI.Web.dll).
Since it's a Microsoft strong signed DLL, add it to the server's GAC.
If you place it in the GAC, it'll find the file automatically. Another plus there is that if you need it for another project deployed on the same server, you don't need to deploy it again.
Here's some information on how to install a DLL into the GAC on the server machine, assuming gacutil is not installed there. Look at the accepted answer, not the question.
Drag and drop a DLL to the GAC ("assembly") in windows server 2008 .net 4.0
Copy gacutil.exe and gacutil.exe config from your machine to the server's C:\Windows\Microsoft.NET\Framework\v4.0.30319
Then run on the server:
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\gacutil.exe" /i "PATH TO YOUR DLL"

Could not load file or assembly 'AForge.Video.FFMPEG.dll' or one of its dependencies

I'm developing a .NET app using Visual Studio Community 2015, which uses some of the AForge.NET libraries. I added the references to my project, and when I debug the app the libraries work fine. However, when I publish the app and install it in the same computer, as soon as I reach a part of the application in which the AForge.NET libraries are used, the app crashes with the following error:
System.IO.FileNotFoundException: Could not load file or assembly 'AForge.Video.FFMPEG.dll' or one of its dependencies. The specified module could not be found.
Filename: 'AForge.Video.FFMPEG.dll'
on MyApp.mySecondForm..ctor(Int32 id)
on MyApp.myMainForm.myListView_DoubleClick(Object sender, EventArgs e)
on System.Windows.Forms.Control.OnDoubleClick(EventArgs e)
on System.Windows.Forms.ListView.WndProc(Message& m)
on System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
on System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
on System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
I've searched online for solutions to this, and so far none of the following has worked for me:
Installing Visual Studio C++ Redistributable (thinking it might have been a missing dependency)
Using the File System Editor to add the library on installation (I can't find the editor in Visual Studio).
Also, I searched for the folder where the app was installed, and I see all the DLL files are there, each in a different folder, along with a single folder with every DLL among other files.
I have no issues with other libraries (the ones in the Global Assembly Cache), such as MySql.Data.
Following a suggestion by Chris O, I used the Process Monitor to check on my app, and it shows it's looking for the AForge libraries in the GAC; since I haven't added them there, there's no way they can be found.
What do I need to do in order to configure my app so it can access the libraries from an app folder instead of looking for them in the GAC?
External libraries must be copied to the installation folder that contains the AForge.Video libraries.
The AForge.Video library includes a few external DLL files that cannot be added as references. Instead, they must be copied to the bin folder of the project. Likewise, after installing the app, they must be copied to the folder where the other DLL files reside. The exact name of the folder varies, but in my case, I had to copy them to the following directory:
C:\Users\ User Name \AppData\Local\Apps\2.0\3V9YACJD.EPJ\V4BGBR0L.485\appe..tion_0000000000000000_0001.0008_b483b48e9712fa89
The DLL files that need to be copied are:
avcodec-53.dll
avdevice-53.dll
avfilter-2.dll
avformat-53.dll
avutil-51.dll
postproc-52.dll
swresample-0.dll
swscale-2.dll
I noticed this after making the same app as a new Visual Studio project, and forgetting to copy the external libraries in the new project, which caused the same error in development (which I didn't get before).
add useLegacyV2RuntimeActivationPolicy="true" on app.config after startup
like
`<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>`
and copy AForge external dll in Externals\ffmpeg\bin to project bin\debug folder.
Try building your project in x86 platform.

Could not load file or assembly Devart.Data

I have such issue.
On my PC where VS is installed and project is developing I use Devart linqconnect.
I set option "Copy Local" for Devart.Data.Linq, Devart.Data.SQLite and Devart.Data.SQLite.Linq to true. All goes OK.
When try to run application on client side error Could not load file or assembly 'Devart.Data, Version=5.0.828.0 ... appears. What can be solution for this?
It is also necessary to add the Devart.Data assembly of the corresponding version to your project and set Copy Local for it to True.
To deploy applications written with the help of LinqConnect you should register run-time assemblies Devart.Data.SQLite.dll, Devart.Data.dll, Devart.Data.SQLite.Linq.dll and Devart.Data.Linq.dll at Global Assembly Cache (GAC) or place them to the bin folder of your application.
JIC: these assemblies can be found in the folder where LinqConnect is installed.

MVC 4 can not find assemblies and shows file structure

have a mvc 4 application. I have changed "Copy Local" property for all referenced assemblies (even system.dll). each time I deploy it to WinHost (Asp.NET hosting) it complains and says could not load file or assembly. I deleted the Bin folder on WinHost redeployed everything, each time I deploy the application, it shows one of the following errors
Could not load file or assembly 'Microsoft.Data.Edm' or one of its dependencies. ....
Could not load file or assembly 'Microsoft.Data.oData' or one of its dependencies. ...
Could not load file or assembly 'WebGrease' or one of its dependencies. ...
Could not load file or assembly 'EntityFrameWork' or one of its dependencies. ...
I removed EntityFrameWork by running unistall-package EntityFrameWork, it had some dependencies so I had to remove them first.
Now When I browse to my application it shows the file structure.
I have two questions:
why it cannot find assemblies while all are there in bin folder? it must be something else than assemblies.
why it shows my file structure now after I removed EntityFramework and its dependencies?
I really appreciate any kind of help.

Resources