Unable to include report viewer web part. Error is, assembly has a higher version than referenced assembly - visual-studio-2010

I am making a web part in VS 2010 for SharePoint 2010. The web part uses Report Viewer control.
The files I have referenced in my project with Copy Local = True option are:
Microsoft.ReportViewer.Common.dll
Microsoft.ReportViewer.WebForms.dll
Both are version 10 files.
When I build the project it works fine. But when I add this web part in a page it shows following error.
Compiler Error Message: CS1705: Assembly 'MySolution, Version=1.0.0.0, Culture=neutral, PublicKeyToken=8acc41a360fa228d' uses 'Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' which has a higher version than referenced assembly 'Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
I have already installed both Report Viewer 10 redistribute able and its SP1 but no luck. Also copied these DLLs to my SharePoint side bin folder. Did iisreset many times.
How to fix this issue?

Fixed it by updating my web.config which was referencing version 9 instead of 10.

Related

Spurious mscorlib of wrong version showing up in dll build

I am building a Cpp/Clr dll with .NET Framework 2.0. Builds fine. However, when I create an Example program to use the dll, also with 2.0, I get this error:
The primary reference "C:\...\MemBuffDll.dll" could not be resolved because it has an indirect dependency on the .NET Framework assembly "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which has a higher version "4.0.0.0" than the version "2.0.0.0" in the current target framework.
I have very carefully rebuild the entire solution (not too hard, only two projects in it) and made sure I used only cut and paste of code from one file to another in the re-creation. I as VERY careful to make sure I specified the 2.0 Framework.
When I exclude the Example Solution, everything builds fine. When I reload it, I get the above message. So, I searched in the contents of every file in the entire solution and found the reference in both the .dll and in a file ending with .metagen. The metagen lines of interest are:
ImageRuntimeVersion: v4.0.30319
Assembly MemBuffDll, Version=0.0.*, Culture=Invariant Language (Invariant Country):
hash=SHA1, flags=PublicKey
Assembly mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089:
hash=None, flags=None
Assembly mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089:
hash=None, flags=None
Assembly System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089:
hash=None, flags=None
Why are the two lines with 4.0.0.0 in there? This is supposed to be a 2.0 build.
Really puzzled,
-greenhorn greg
The answer to the question is:
"The C++ IDE does not support multi-targeting"
Because I didn't understand this answer when I'd seen it in other posts, I'm going to try and clarify for the benefit of other poor souls who stumble upon this "feature".
What this means is that my VS 2010 cannot (correctly) target .net 2.0 when I'm doing a C++ project. I had specified .net framework 2.0 for both of my projects in my solution and the settings were accepted. However, the C++ portion (actually C++/CLI) actually built with two references, both the v2.0 that I had specified and v4.0 that is the native(?) for my VS 2010. Note that it did not throw an error or warning and only the .dll and the .metagen files contained this reference.
When the other project in my solution tried to reference the project, I got the error mentioned in my OP. It would not build.
The solution to the problem is twofold:
Install VS 2008 and recreate the problem project under that. Will probably need refactoring. Note that the Express edition worked just fine for this.
Change your targets to .net 4.0. This is what I did because refactoring the dll would be a PITA and the target platform (Windows Embedded 8 Standard) supports .net 4.0
Hope this helps somebody else like me that runs into this.

Upgrading VS2010 to 2013 introduced compile error with SendGrid

I installed the ultimate trial of Visual Studio 2013 yesterday to see if it had any negative impact on our current 2010 based projects. When trying to compile a project that previously had no problems and still compiles on my colleagues computers I encountered this error:
The type or namespace name 'SendGridMail' could not be found (are you missing a using directive or an assembly reference?)
The error is the same when run from Visual Studio 2010 or 2013
Looking at similar questions on here suggests that this happens when using the .net 4 Client Profile instead of standard .net 4, but this project has always used standard .net 4.
Another question was using the latest version of sendgrid (4.x) with .net 4 which I understand doesn't work, but we are using an older version (1.2.1).
Personally I have tried:
Removing and Readding the reference (originally it was referenced inside the project, I also tried referencing it externally)
Running Visual Studio with no addons
Recreating the project in another solution
The only luck I have had so far has been to use nuget to install the sendgrid package instead but this seems to add a lot of additional files and at the moment I'm more interested in why a previously working build has stopped working with no changes to the project other than installing another version of Visual Studio.
Edit:
This is the output when trying to build with the SendGridMail dll (succeeds since it's not used in code):
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3268: The primary reference "SendGridMail, Version=1.2.1.0, Culture=neutral, processorArchitecture=MSIL" could not be resolved because it has an indirect dependency on the framework assembly "System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0". To resolve this problem, either remove the reference "SendGridMail, Version=1.2.1.0, Culture=neutral, processorArchitecture=MSIL" or retarget your application to a framework version which contains "System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3268: The primary reference "SendGridMail, Version=1.2.1.0, Culture=neutral, processorArchitecture=MSIL" could not be resolved because it has an indirect dependency on the framework assembly "System.Threading.Tasks, Version=2.5.19.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0". To resolve this problem, either remove the reference "SendGridMail, Version=1.2.1.0, Culture=neutral, processorArchitecture=MSIL" or retarget your application to a framework version which contains "System.Threading.Tasks, Version=2.5.19.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3268: The primary reference "SendGridMail, Version=1.2.1.0, Culture=neutral, processorArchitecture=MSIL" could not be resolved because it has an indirect dependency on the framework assembly "System.Runtime, Version=2.5.19.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0". To resolve this problem, either remove the reference "SendGridMail, Version=1.2.1.0, Culture=neutral, processorArchitecture=MSIL" or retarget your application to a framework version which contains "System.Runtime, Version=2.5.19.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
I was able to resolve this by removing the .NET 4.5 SDK (but not the framework itself). I assume it was looking at the latest framework for the dlls despite the project being set to .NET 4

Fails to Compile C# project due to primary reference

I'm trying to compile the project with targeted framework as ".NETFramework 4.0". But I get the following warning:
The primary reference "XXX" could not be resolved because it has an
indirect dependency on the framework assembly
"System.Runtime.Serialization, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089" which could not be resolved in the
currently targeted framework. ".NETFramework,Version=v4.0". To resolve
this problem, either remove the reference "Fdi" or retarget your
application to a framework version which contains
"System.Runtime.Serialization, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089".
I found an earlier (but similar) problem: Visual Studio 2010: Reference Assemblies Targeting Higher Framework Version
Johannes Rudolph found this answer on MSDN's forums ( http://social.msdn.microsoft.com/Forums/en-US/msbuild/thread/dfadfb34-5328-4c53-8274-931c6ae00836 ):
However, there're 2 workarounds.
Option 1:
Step1: Unload the referencing project targeting .NET 2.0
Step2: Right click the unloaded project and select edit from context menu
Step3: Add <SpecificVersion>true</SpecificVersion> to the reference.
Below is a sample from my repro solution:
<ProjectReference Include="..\HighFX\HighFX.csproj">
<Project>{8DD71CAF-BEF7-40ED-9DD0-25033CD8009D}</Project>
<Name>HighFX</Name>
<SpecificVersion>true</SpecificVersion>
</ProjectReference>
Step4: Reload the project.
Now your should be able to build within the Visual Studio 2010, there could still be a warning as below, but the build can be successful.
Warning 1 The project 'XXX' cannot be referenced. The referenced project is targeted to a higher framework version (3.5)
Option2:
Use the command line tool csc.exe to build each of your source file, which won't prevent the building.

Having errors running JigLibX 0.3.1 on XNA 4.0

Warning 1:
The referenced assembly "Microsoft.Xna.Framework.Content.Pipeline,
Version=4.0.0.0,Culture=neutral, PublicKeyToken=842cf8be1de50553"
could not be resolved because it has a dependency on
"Microsoft.Build.Utilities.v4.0, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a" which is not in the currently
targeted framework ".NETFramework,Version=v4.0,Profile=Client". Please
remove references to assemblies not in the targeted framework or
consider retargeting your project. JigLibX
Warning 2:
The referenced assembly "Microsoft.Xna.Framework.Content.Pipeline,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553"
could not be resolved because it has a dependency on
"Microsoft.Build.Framework, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a" which is not in the currently
targeted framework ".NETFramework,Version=v4.0,Profile=Client". Please
remove references to assemblies not in the targeted framework or
consider retargeting your project. JigLibX
Error 3:
Error loading pipeline assembly "HeightmapProcessor, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null". JigLibGame
How can I solve this?
Your assembly (you didn't give details - is it an application? a game? a library? a content pipeline extension?) is depending on the XNA content pipeline assemblies, which themselves require the full .NET 4 framework -- currently you are targeting the .NET 4 Client Profile framework.
You need to do exactly what the exception says:
You could remove the assembly references to the content pipeline assemblies, if that is possible.
Or you could change the target framework. To do this, right click your project in the Solution Explorer, select Properties, on the Application tab find the Target framework drop-down and change from ".NET Framework 4 Client Profile" to ".NET Framework 4"
It is worth pointing out that the XNA content pipeline assemblies are not redistributable: you cannot include them with your game.

'access is denied' error when using VS 2010, VSTO, Excel 2007 for customized ribbon

I'm trying to get a simple ribbon add-in build using VS 2010 and Excel 2007 utilizing VSTO. I've tried both an Excel Worksheet and Excel Add-in with the same results when I launch Excel (listed below).
I have a larger prototype I'm trying to build, but for now I can't get off the ground with customizing the Excel ribbon. Has anyone had any luck with building a simple prototype using VS 2010 and Excel 2007? Did you encounter any Access denied issues when attempting to load in your add-in dll? Let me stress there is nothing fancy here .. just 2 buttons that don't even do anything at this point (excel doesn't even load the dll, so there's no breakpoints, etc).
I have tried using the 'caspol.exe' tool to grant full trust to my dll, this changed nothing. I've made sure the folder where the dll is built to has 'Everyone' privileges. I've tried publishing and installing the add-in, I've also tried just starting it directly from the debugger in VS 2010, same issue over and over again. I am admin on the server.
Thank you.
Jim
Could not load file or assembly 'MyRibbonAddIn, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Access is denied.
***** Exception Text *******
System.IO.FileLoadException: Could not load file or assembly 'MyRibbonAddIn, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Access is denied.
File name: 'MyRibbonAddIn, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' ---> System.IO.FileLoadException: Could not load file or assembly 'MyRibbonAddIn, Version=1.0.0.0, Culture=neutral' or one of its dependencies. Access is denied.
File name: 'MyRibbonAddIn, Version=1.0.0.0, Culture=neutral'
ARGH! It was our virus scanner. I disabled it and things showed up. So many hours wasted. Hopefully this question helps someone else avoid losing time in their life on something stupid

Resources