Could not load assembly Microsoft.ReportViewer.Common, despite installing the prerequisites - c#

So, I've got a C# windows workflow project that creates a report programmatically and emails it out. It works fine on my local machine, but putting it on a scheduler in a different machine generates the following error:
Could not load file or assembly 'Microsoft.ReportViewer.Common, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Based on other topics, I tried installing MICROSOFT® REPORT VIEWER 2012 RUNTIME from the following address: http://www.microsoft.com/en-us/download/details.aspx?id=35747. This didn't help. This was the overwhelmingly prevalent solution, but I'd love any other suggestions or advice.

The accepted answer pointed me in the right direction. However, didn't provide enough details for me to reach resolution. I wanted to add this as a comment to that answer but it was too long.
In my VS project, I had a reference to Microsoft.ReportViewer.WinForms version 12.0.0.0 and when deploying to another computer got the same error as present in this question. The key to the problem is a portion of the error:
The located assembly's manifest definition does not match the assembly
reference.
It is telling you that it found a DLL with the right name, but it is the wrong version. I had added a reference to Microsoft.ReportViewer.Common through the references dialog but I didn't catch that the only one listed in the "Extensions" section of the references dialog was for version 10.0.0.0. So of course it will deploy the wrong one if you are telling it to deploy the wrong one.
What you have to do is find the Microsoft.ReportViewer.Common.dll file with version 12.0.0.0 on your system and manually include a reference to that. For me it was in the following directory:
C:\Windows\assembly\GAC_MSIL\Microsoft.ReportViewer.Common\12.0.0.0__89845dcd8080cc91\
Once I added that reference and set both DLLs to Copy Local in my VS project, then everything worked on the deployed machine.
Note: I did not require an installation of the Microsoft Report Viewer 2012 Runtime in order to have it work on the deployed machine. For any of you like me that were wanting to avoid any other installations during deployment.

try to add the dll files to the project from :
C:\Program Files\Microsoft Visual Studio 10.0\ReportViewer
add them to the bin folder after publishing the project

Related

VS2019 RegPkg.exe throws Unhandled Exception

I've just installed Visual Studio 2019 with SDK and when i try to run RegPkg.exe, I see the following error. I don't have any other VS instances installed on the machine but I'm confused why the error is reporting about version 15.0.0.0 (which is VS2017).
Can someone please help me to resolve this error.
Unhandled Exception: System.IO.FileNotFoundException: Could not load
file or assembly 'Microsoft.VisualStudio.Shell.Framework,
Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or
one of its dependencies. The system cannot find the file specified.
at Microsoft.VisualStudio.Tools.RegPkg.Main(String[] arguments)
I just noticed I got the exact same error message, using VS 2017's version. So it has nothing to do with the version you are using. I don't even have 2019 installed.
Microsoft simply broke their SDK, which has apparently been broken for 2 years, and no one noticed. For reference, I'm using VS 2017 15.9.7, also with the VSSDK installed.
I have a NuGet reference to that DLL in a VSIX extension I build, so I had a copy in my .nuget package cache ("%USERPROFILE%.nuget\packages\microsoft.visualstudio.shell.framework\15.9.28307\lib\net45\Microsoft.VisualStudio.Shell.Framework.dll"). I copied that version into the folder where regpkg.exe is located, and resolved the error (%VSSDK150INSTALL%\VisualStudioIntegration\Tools\Bin).
Probably not the best solution, but Microsoft needs to fix their product. I suspect it broke as part of their reorganization for the 2017 product, as they also added all the assemblies that extensions need for dependencies to NuGet. I guess they forgot to keep that assembly in the actual VS install folder.
EDIT: I've been looking into this more, and apparently the file actually exists in the lib sub folder right there with the exe. However none of the versions I've found actually work with CreatePkgDef.exe which was my backup plan, as it now throws this error instead:
CreatePkgDef : error : ArgumentException: No Visual Studio
registration attribute found in this assembly. The assembly should
contain an instance of the attribute
'Microsoft.VisualStudio.Shell.RegistrationAttribute' defined in
assembly 'Microsoft.VisualStudio.Shell.Framework' version '15.0.0.0'
Seems to work with regpkg.exe, though I haven't tried every combination of options.

How to resolve "The located assembly's manifest definition does not match the assembly reference." error?

I downloaded source code for pdfiumviewer from git hub. I made changes to one of the projects in that solution.Then I added that project to my application and added reference of that project to one my application's project.I had to uncheck the Signing option for the PDfiumViewer project, as some of the dll in that project are unsigned.I am able to build the application successfully.But at run time when I create an object of one of the class of PDfiumviewer project.It gives me the following error:
Could not load file or assembly 'PdfiumViewer, Version=2.11.0.0,
Culture=neutral, PublicKeyToken=null' or one of its dependencies. The
located assembly's manifest definition does not match the assembly
reference. (Exception from HRESULT: 0x80131040)
The version number of the assembly is correct.So, why am I getting this error?
The problem was that I had added reference of old unmodifed PdfiumViewer dll to another project.Hence, there was conflict between the two dlls (old and customized) at runtime.I removed the old dll reference and it worked.
Ive also encountered this issue, my scenario was thou that I had to add a reference from another solution into my project removing the reference was not an option - what worked for me was reinstall SQLclient from nuget package managerer on both solution. Hopes it helo someone else
The issue here is that you have a library that references v2.11.0.0 of the Pdfium library. This library could be an assembly that you built earlier, or another assembly that came from Pdfium that references this version of the library. When you built your version of the library you probably didn't use this same version number, and it wouldn't have been strong named correctly. To fix this, you can add an assembly binding redirect in your applications configuration file to redirect the offending library to your custom built one.
I wrote a program to fix this issue automatically: https://github.com/BackTrak/DependencyFixup/releases/tag/1.0.0.0
I know this question is old, but hopefully this helps out others!

Server Error- Could not load file or assembly 'log4net, Version=1.2.10.0'

I am trying to generate a crystal report on a website that i created using visual studio 2012. I installed the Support Pack 8 Executable from this site: http://scn.sap.com/docs/DOC-7824 and integrted Crysital reports with my visual studio. I am able to generate the report on my computer, but when i moved my website to a different server I get an error. Initially i had errors about different .dll's missing, but after adding them it fixed the problem. I could not however get passed this one error:
Could not load file or assembly 'log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
I found this log4net.dll on my computer and added it to my website on the server, but i can not get passed this error. it is a Windows 2008 Server running IIS 7. I am using ASP.net 4.0.
Is there a reference that i need to Thanks in advance.
This is most likely a duplicate of several similar questions, amongst which the consensus seems to be making sure that the installer for the correct target platform (x86 vs x64) is used.
See the following for more detail:
Could not load file or assembly 'log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=692fbea5521e1304'
Log4net.dll + C# + Crystal Reports = error
Crystal Reports error when deployed..Could not load file or assembly 'log4net
I solved it this way:
The issue was on IIS in which I set in the Advanced Settings of the AppPool the option "Enable 32 Bit Applications" to False and in that way the Crystal Runtime For 64 Bits worked perfectly without needing to install the 32 bit Runtime, and so on the whole application.

Error : add a reference to assembly 'System.ServiceModel, Version=3.0.0.0'

I can able to build my silverlight 4.0 application in Win xp(IIS 5.1). But when i try to build the same app in Win Server 2008 R2(IIS 7), i am getting the error,
"error CS0012: The type 'System.ServiceModel.ClientBase`1' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'".
The path actually it is refereing the dll on both the machines is,
"C:\Program Files\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0\System.ServiceModel.dll".
What may be the issue?
Thanx in advance
Make sure that under the Reference Folder of your project you see System.ServiceModel.
This issue might happen when you move your solution from one higher level environment to another.
ex: my colleague created it on VS2015 which has this dll automatically generated.
then, when i tried to run it on my environment. it shows this error. because my environment does not generate such a library automatically.
Hopefully, you just have to add "System.ServiceModel.ClientBase" manually through "Add reference"
Is one a 64bit environment and the other is a 32bit environment, I have seen cases before when an assembly decides that it will only work on certain platforms, so the "Any CPU" build option is telling it to build in the wrong platform.

Deploying assembly normally in the GAC with my project?

I built a web application that uses the J# libraries which works fine in my cpu, however, when I deploy it to my shared server. I get an error message: Parser Error Message: Could not load file or assembly 'vjslib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
So basically, the server doesn't have visual j# installed. The problem is they wont install it because it is a shared server.
Is there a way I can deploy the J# assemblies with my project so that it will work on the shared server without it being registered in the GAC?
Thanks for your help!!
Simplest solution: Try to copy the assemblies your application needs into the same folder where your application resides.
The following MSDN article explains How the Runtime Locates Assemblies.
Also, you may find more options (including copying all J# related dlls into a subfolder of the application folder if needed) in the following link when the runtime cannot find the assembly in the GAC: Locating the Assembly through Codebases or Probing
Without knowing anything about J# I can only suggest that you try just distributing the required libraries along with your program (place them in the same directory), I believe if it can't find the library in the GAC it will revert to look in the current directory.

Categories

Resources