Reference required to assembly System.Runtime [duplicate] - asp.net

I'm preparing a brand new ASP.NET MVC 5.1 solution. I'm adding in a bunch of NuGet packages and setting it up with Zurb Foundation, etc.
As part of that, I've added a reference to an in-house NuGet package which is a Portable Class Library and I think this is causing a problem on the build server.
TeamCity fails the build with:
The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0
I originally added the fix for the same or similar error when compiling the Razor web pages, that fix being in the web.config
<compilation ... >
<assemblies>
<add assembly="System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</assemblies>
</compilation>
However, the issue is unresolved.

To implement the fix, first expand out the existing web.config compilation section that looks like this by default:
<compilation debug="true" targetFramework="4.5"/>
Once expanded, I then added the following new configuration XML as I was instructed:
<assemblies>
<add assembly="System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</assemblies>
The final web.config tags should look like this:
<compilation debug="true" targetFramework="4.5">
<assemblies>
<add assembly="System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</assemblies>
</compilation>

Adding a reference to this System.Runtime.dll assembly fixed the issue:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\Facades\System.Runtime.dll
Though that file in that explicit path doesn't exist on the build server.
I will post back with more information once I've found some documentation on PCL and these Facades.
Update
Yeah pretty much nothing on facade assemblies on the whole internet.
Google:
(Facades OR Facade) Portable Library site:microsoft.com

The only way that worked for me - add the assembly to web.config
<compilation debug="true" targetFramework="4.5">
<assemblies>
<add assembly="System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</assemblies>
</compilation>

#PeterMajeed's comment in the accepted answer helped me out with a related problem. I am not using the portable library, but have the same build error on a fresh Windows Server 2012 install, where I'm running TeamCity.
Installing the Microsoft .NET Framework 4.5.1 Developer Pack took care of the issue (after having separately installed the MS Build Tools).

I had this problem in some solutions on VS 2015 (not MVC though), and even in the same solution on one workstation but not on another. The errors started appeared after changing .NET version to 4.6 and referencing PCL.
The solution is simple: Close the solution and delete the hidden .vs folder in the same folder as the solution.
Adding the missing references as suggested in other answers also solves the problem, but the error remains solved even after you remove the references again.
As for TeamCity, I cannot say since my configuration never had a problem. But make sure that you reset the working catalog as a part of your debugging effort.

It's an old issue but I faced it today in order to fix a build pipeline on our continuous integration server. Adding
<Reference Include="System.Runtime" />
to my .csproj file solved the problem for me.
A bit of context: the interested project is a full .NET Framework 4.6.1 project, without build problem on the development machines.
The problem appears only on the build server, which we can't control, may be due to a different SDK version or something similar.
Adding the proposed <Reference solved the build error, at the price of a missing reference warning (yellow triangle on the added entry in the references tree) in Visual Studio.

I was also facing this problem trying to run an ASP .NET MVC project after a minor update to our codebase, even though it compiled without errors:
Compiler Error Message: CS0012: The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Our project had never run into this problem, so I was skeptical about changing configuration files before finding out the root cause. From the error logs I was able to locate this detailed compiler output which pointed out to what was really happening:
warning CS1685: The predefined type 'System.Runtime.CompilerServices.ExtensionAttribute' is defined in multiple assemblies in the global alias; using definition from 'c:\Windows\Microsoft.NET\Framework64\v4.0.30319\mscorlib.dll'
c:\Users\Admin\Software Development\source-control\Binaries\Publish\WebApp\Views\Account\Index.cshtml(35,20): error CS0012: The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\meseems.webapp\68e2ea0f\8c5ee951\assembly\dl3\52ad4dac\84698469_3bb3d401\System.Collections.Immutable.DLL: (Location of symbol related to previous error)
Apparently a new package added to our project was referencing an older version of the .NET Framework, causing the "definition in multiple assemblies" issue (CS1685), which led to the razor view compiler error at runtime.
I removed the incompatible package (System.Collections.Immutable.dll) and the problem stopped occurring. However, if the package cannot be removed in your project you will need to try Baahubali's answer.

Install the .NET Runtime as well as the targeting pack for the .NET version you're targeting.
The developer pack is just these two things bundled together but as of today doesn't seem to have a 4.6 version so you'll have to install the two items separately.
Downloads can be found here: http://blogs.msdn.com/b/dotnet/p/dotnet_sdks.aspx#

On our Tfs 2013 build server I had the same error, in a test project.
with the main web project running on .Net 4.5.1.
I installed a nuGet package of System Runtime and added the reference from
packages\System.Runtime.4.3.0\ref\net462\System.Runtime.dll
That solved it for me.

I needed to download and install the Windows 8.0 (and not 8.1) SDK to make the error disappear on my TeamCity server.
https://developer.microsoft.com/en-us/windows/downloads/windows-8-sdk

i added System.Runtime.dll to bin project and it worked :)

I had this problem in a solution with a Web API project and several library projects. One of the library projects was borking on build, with errors that said the Unity attributes weren't "valid" attributes, and then one error said I needed to reference System.Runtime.
After much searching, reinstalling the 4.5.2 Developer Pack, and nothing working, I figured maybe it was just a version mismatch. So I looked at the properties of every project, and one of the very base libraries was targeting 4.5 while every other one was targeting 4.5.2. I changed that one to also target 4.5.2 and the errors went away.

I copy the file "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.1\Facades\system.runtime.dll" to bin folder of production server, this solve the problem.

For me I am using Microsoft visual studio 2019 and Windows server 2019 .
This web.config compilation part
<compilation debug="true" targetFramework="4.7.2">
Suddenly this error appeared during development and coding
I tried adding the assembly and reference its not solved the issue
This error solved after close and open visual studio and open project again .

install https://www.microsoft.com/en-us/download/details.aspx?id=49978 Microsoft .NET Framework 4.6.1 Developer Pack and add this line of code in Web.config file
<compilation debug="true" targetFramework="4.5">
<assemblies>
<add assembly="System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</assemblies>
</compilation>

For me helped only this code line:
Assembly.Load("System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");

Deleting the bin folder and rebuilding the solution worked for me.

In my case the .csproj file somehow was mixed up. Some 'Compile' elements were missing a 'SubType'.
<Compile Include="Control.cs" />
Fixed the issue by adding the "SubType" again:
<Compile Include="Control.cs">
<SubType>UserControl</SubType>
</Compile>

Removing the reference over the Nuget Package Manager and re-adding it solved the problem for me.

Related

Compilation error on consuming and building .NetStandard library using MS Build

I have a couple of projects in my solution, migrated one of the class library to .netstandard(ModelLib) which is consumed by .net472 class library(serviceLib). The serviceLib is again referenced by another .net472 class library(apiLib). This apiLib is used in my asp.net website project.
Now, build works fine in VSStudio 2019, but fails when building using MS Build in test environment.
I get the following error and Build log says:-
c:\buildagent\xxxx\xxxx\web.config(186,0): error ASPCONFIG : Error ASPConfig: Could not load file or assembly 'apiLib' or one of its dependencies, the system cannot find the file specified.
The webconfig looks like this and line#186 is
<compilation debug="true" targetFramework="4.7.2">
<assemblies>
<add assembly="apiLib" />
</assemblies>
</compilation>
I checked the file in bin folder, the apiLib is missing.
Is there any .net version compatibility issues here?
Anybody faced similar issues and why apiLib is not copied into bin ? Is it something related to .NetStandard Project? Please help at the earliest..
Note: I haven't changed any package reference style of apiLib or similar libraries.
Thanks in advance.

Razor Host Factory error

I get a MvcWebRazorHostFactory error trying to run my app, but it's not an MVC app at all. I have the following web packages installed via nuget:
Microsoft ASP.NET Razor
Microsoft ASP.NET Web API 2.1
Microsoft ASP.NET Web Pages
My app is angularjs front end using razor views (.cshtml). I don't understand why I keep getting this error.
An exception of type 'System.InvalidOperationException' occurred in System.Web.WebPages.Razor.dll but was not handled in user code
Additional information: Could not locate Razor Host Factory type: System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35
And here is the razor section in my web.config:
<system.web.webPages.razor>
<host factoryType="System.Web.WebPages.Razor.WebRazorHostFactory, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.WebPages.WebPage">
<namespaces>
<add namespace="System.Web.Configuration" />
<add namespace="System.Web.Optimization" />
<add namespace="System.Web.Routing" />
</namespaces>
</pages>
I resolved this issue by setting System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc Version to 5.2.0.0 and it worked, finally! Why 5.2.0.0? Same version as NuGet Microsoft ASP.NET project.
So, the line in /Views/Web.Config should be:
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
For the benefit of anyone developing ASP.NET MVC 5 web apps using Xamarin Studio v5.5.3 on OSX, deleting the /Views/Web.config did not work for me and created other errors.
To fix it, open /Views/Web.config and change all instances of 5.2.0.0 to 5.2.2.0
More details here
Several of the answers point in the right direction, but I was not sure where in the Microsoft Visual Studio for Mac interface I could find the appropriate version number to use for the version part of the factoryType attribute.
For the benefit of other VS for Mac users, the answer is to simply right-click on the Microsoft.AspNet.Mvc package in the Packages list in the solution explorer.
In my case, the package version was "5.2.6" after a package update, so I set the version part of the factoryType attribute to Version=5.2.6.0. This solved the problem.
Changed the version of MvcWebRazorHostFactory to the same version of System.Web.Mvc which resolved my issue.
So apparently some package I got from nuget adds a web.config to the Views folder. In this web.config there were settings for the MvcWebRazorHostFactory. I think this occurred when I added a View to my project using the dialog box.
The solution is to remove the web.config from the Views folder.
I started getting this error in my Razor .cshtml pages in an MVC project following some NuGet package management / upgrading.
I didn't want to remove the Web.config file completely from the Views folder because I had customised it width some <add namespace="..." /> elements. But I noticed that the Version=... in the <host factoryType="..." /> didn't match my version of System.Web.Mvc (checked version in Object Browser).
Altering this version number to match that of my System.Web.Mvc assembly, and restarting Visual Studio, fixed the problem for me (as suggested by Daniel)
This happened to me today. I just made sure the version number for the web.config in the views folder matches the version number for the web.config of the solution.
Hope this helps.
For MacBook users having the Visual Studio 2019, you simply go to the Web.config file and update version of the System.Web.Mvc to that which is in your Nuget packages folder.
Inside your Web project, open "References" tree node.
Look for "Assemblies" folder and open it.
Look for System.Web.Mvc, right click on it, and select "Properties"
A dialog will prompt, read carefully the package full name field and look for the version number. For example, I have this one:
System.Web.Mvc, Version=5.2.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
So, in the Web.config (inside Views folder) replace the version number!
In my case, it originally was:
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
Now I have (look at the Version value):
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.7.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
Hope it helps!

Compilation error at runtime from Microsoft.AspNet.WebApi.HelpPage version 4.0.30506

I am getting the following error when I try to use version 4.0.30506 (unfortunately we are tied to this version of ASP.NEt Web API for now) of the Microsoft.AspNet.WebApi.HelpPage nuget package. I am using Windows 7 and .NET 4.5.
Compilation Error
Description: 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.
Compiler Error Message: CS0012: The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Source Error:
Line 11:
Line 12: // Group APIs by controller
Line 13: ILookup<string, ApiDescription> apiGroups = Model.ToLookup(api => api.ActionDescriptor.ControllerDescriptor.ControllerName);
Line 14: }
Line 15:
As far as I can see I have all the correct references for this to work. I have tried looking for a System.Runtime assembly as it suggests, but I can't find it on my system. I have added using statements to the top of Index.cshtml, but with no affect.
#using System
#using System.Runtime
Any suggestions of what is causing this error?
check your web.config:
<compilation debug="true" targetFramework="4.5">
<assemblies>
<add assembly="System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</assemblies>
</compilation>
In my case, this error disappeared when I removed System.Collections.Immutable.dll from Bin directory. This DLL is from NuGet package and is available only for Win8 platforms and I was working with Win7. So it might help you too..
I ran into this error after updating all Nuget packages in an MVC 5, .NET 4.5.1 project, and thanks to Dmitry Lyalin's post discovered the issue related to an updated Nuget package that has become a Portable Class Library.
For those who like to dig, I figured out the culprit by doing the following:
Unload the project
Edit the project
Search for "portable"
Having found Humanizer, I changed it back to pre-PCL version 1.37.7, retested the page, and found that everything worked again.
Knowing the culprit(s), Humanizer in my case, there's two options:
Cap the Humanizer Nuget at version 1.x.y so as not to use the new PCL libraries in v2 via allowedVersions attribute in packages.config:
<package id="Humanizer " version="1.37.7" allowedVersions="[1,2)" />
Do what giammin suggests in his answer and add the System.Runtime assembly under system.web in web.config:
<system.web><compilation ...><assemblies><add assembly="System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /></assemblies></compilation></system.web>

"Invalid token ',' in class, struct, or interface" after checkout

I am having problems compiling an EPiServer Web Application after checking it out of Subversion.
I get this error
Compiler Error Message: CS1519: Invalid token ',' in class, struct, or interface member declaration
Source Error:
Line 116: }
Line 117:
Line 118: public virtual EPiServer.Personalization.SubscriptionInfo, EPiServerSubscription Info {
Line 119: get {
Line 120: return ((EPiServer.Personalization.SubscriptionInfo, EPiServer)this.GetPropertyValue("SubscriptionInfo")));
Source File:
c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\956e6fc5\66c11597\App_Code.9_fan95p.0.cs Line: 118
As you can see from the error, this file is in the "Temporary ASP.NET Files" folder and is part of the build process. This is not my source code.
I have seen this question which suggests that the web config contains type references
specified in the "Namespace.ClassName,
AssemblyName" format.
So I went into my web.config and changed the section
...
<profile ...>
<properties>
...
<add name="SubscriptionInfo"
type="EPiServer.Personalization.SubscriptionInfo, EPiServer"
provider="SqlProfile" />
...
to
...
<profile ...>
<properties>
...
<add name="SubscriptionInfo"
type="EPiServer.Personalization.SubscriptionInfo"
provider="SqlProfile" />
...
This removed the immediate error above but then I got the same error for a different type. So I went through all the types that were in "Namespace.TypeName, AssemblyName" format and removed the ", AssemblyName". This stopped all the CS1519 errors but then I start getting CS0234:
Compiler Error Message: CS0234: The
type or namespace name
'Personalization' does not exist in
the namespace 'EPiServer' (are you
missing an assembly reference?)
Source Error:
Line 116: }
Line 117:
Line 118: public virtual EPiServer.Personalization.SubscriptionInfo
SubscriptionInfo {
Line 119: get {
Line 120: return
((EPiServer.Personalization.SubscriptionInfo)(this.GetPropertyValue("SubscriptionInfo")));
I am using VisualStudio 2008, Episerver 5.2.372.7, VisualSVN 1.7.2 and a Debian box as the Subversion repo running svn version 1.4.2 (r22196).
The application built fine, then I checked it in to the repo. Checked it out to a different location on the same computer and hit F5 and these errors start to appear.
Does anyone have any suggestions.
UPDATE:
Thanks for your replies devio, Zhaph.
I have added the following to my web.config in the <compilation> section:
<assemblies>
<add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="EPiServer, Version=5.2.375.7, Culture=neutral, PublicKeyToken=8fe83dea738b45b7"/>
<add assembly="EPiServer.BaseLibrary, Version=5.2.375.7, Culture=neutral, PublicKeyToken=8fe83dea738b45b7"/>
<add assembly="EPiServer.Configuration, Version=5.2.375.7, Culture=neutral, PublicKeyToken=8fe83dea738b45b7"/>
<add assembly="EPiServer.Enterprise, Version=5.2.375.7, Culture=neutral, PublicKeyToken=8fe83dea738b45b7"/>
<add assembly="EPiServer.Implementation, Version=5.2.375.7, Culture=neutral, PublicKeyToken=8fe83dea738b45b7"/>
<add assembly="EPiServer.Lucene, Version=5.2.375.7, Culture=neutral, PublicKeyToken=8fe83dea738b45b7"/>
<add assembly="EPiServer.Scheduler, Version=5.2.375.7, Culture=neutral, PublicKeyToken=8fe83dea738b45b7"/>
<add assembly="EPiServer.Web.WebControls, Version=5.2.375.7, Culture=neutral, PublicKeyToken=8fe83dea738b45b7"/>
<add assembly="EPiServer.WorkflowFoundation, Version=5.2.375.7, Culture=neutral, PublicKeyToken=8fe83dea738b45b7"/>
<add assembly="EPiServer.Wsrp, Version=5.2.375.7, Culture=neutral, PublicKeyToken=8fe83dea738b45b7"/>
<add assembly="EPiServer.XForms, Version=5.2.375.7, Culture=neutral, PublicKeyToken=8fe83dea738b45b7"/>
</assemblies>
There was no <assemblies> section previously.
The project has all of those DLLs in its References. All the EPiServer DLLs are in the GAC.
The new (non-working) checkout is on the same machine that the original project was created on.
I now get :
Parser Error Message: Could not load
file or assembly 'EPiServer.Scheduler'
or one of its dependencies. The system
cannot find the file specified.
(C:\Projects\web\ProvidentPPC2\ProvidentPPC\web.config line 301)
Source Error:
Line 299: <add name="InitializationModule" type="EPiServer.Web.InitializationModule" />
Line 300: <!--<add name="BasicAuthentication" type="EPiServer.Security.BasicAuthentication, EPiServer" />-->
Line 301: <add name="Initializer" type="EPiServer.Scheduler.Initializer, EPiServer.Scheduler" />
Line 302: <add name="WorkflowRuntime" type="EPiServer.WorkflowFoundation.WorkflowSystem" />
Line 303: <add name="UrlRewriteModule" type="EPiServer.Web.UrlRewriteModule" />
Source File:
C:\Projects\web\ProvidentPPC2\ProvidentPPC\web.config
Line: 301
As I say EPiServer.Scheduler is in my GAC and added to the project as a reference.
Any more ideas would be greately appreciated.
I encountered this problem as I was restructuring the dll references in a project.
I had moved the external/third part dlls from the bin folder to a library folder outside the web project root.
My problem was that some of the dll references did not have copy local set to true, so they were never copied to the bin folder on build.
It's been a while since I asked this and I keep looking thinking that I need to remember what the issue was and post the answer. I think this is it.
It turned out that there was an issue with application finding the DLLs that EPiServer installed. I'm not sure exactly and I'll update this post once I get chance to try it out on a clean machine, I'm still mid-project so it's not a very good time to be faffing about.
The way I fixed it was to get the DLLs from c:\Program Files\EPiServer\CMS\VERSION\bin and put them in the bin folder for the application.
Once I get chance to do a clean install somewhere I'll see if it is infact the project (which I doubt) or, more likely, the installation on my computer which is broken.
Have you tried referencing the EPiServer assembly correctly?
I assume that it's displaying ok in the project references node in the Solution Explorer, and hasn't got a yellow exclaim overlay on it?
Perhaps you could reference it in the web.config compilation section as well:
<compilation debug="false">
<assemblies>
[...]
<add assembly="Episerver, Version=5.2.372.7"/>
</assemblies>
</compilation>
You may either not need the version number, or you may need to add the version number and culture type - there should be a few other assemblies referenced in there already for reference.
You could also try:
<add assembly="EPiServer" />
and other variations.
Sounds like an Assembly Load issue then:
Check that the EPiServer DLL is accessable in your new location - is it installed to your computers Global Assembly Cache, or is it a local reference to the /bin folder? Is the dll in the bin folder? Is the dll included in source control?
I ran into this several times and done it for me is when I manually copied the EPiServer assemblies to the bin folder. That works for sure but it's not very elegant. Zhaph's solution with the assemblies tag looks much nicer I'll try it next time.
I just had a similar problem this afternoon. The problem was that the EpiServer dlls were not present in the bin directory of the website, so I got bind failures.
The project had been created by one of my colleagues and the relevant EpiServer dlls were added as solution items in a lib folder and referenced from there. However, as he had initially created it from the EpiServer project template, the libraries had automatically been added to the bin folder also. When he updated the references to point to the lib folder, copy local defaulted to false. This still worked on his machine due to the original copies placed in the bin folder by the template. Updating them to CopyLocal = True fixed the issue.
I just had this same problem, again with an EPiServer site. It was because I was referencing the EPiServer DLLs, but they did not have the "copy to local" property set to true on all the references, and so they were not all being placed in the bin directory.
Delete everything from BIN Folder and copy all the files from [ASSEMBLIES] in to BIN Folder fixed the problem for me.
Khizer Jalal
I guess the original error message meant you had a malformed C# expression in
return ((EPiServer.Personalization.SubscriptionInfo, EPiServer)...
nothing to do with the config file.
Probably you typed "," instead of "." ? (As the compiler reads this, you provide 2 types in the cast)
Revert web.config to its original version and fix the typo, that should work.
update after Greg's comment:
I didn't realize the config section you posted were part of the EPIServer configuration. You were right then to remove the assembly names.
However I guess you need to reference the EPiServer from the web app (Add Reference...). I think I noticed this in my projects too: If you checkout an ASP.Net app to a new location, you need to add all references again.

Microsoft ASP.NET ReportViewer Parser Error

I've been using a MS ReportViewer component in a website for a while now, but recently I've been getting the error shown below.
Parser Error Message: The base class
includes the field 'xyz', but its
type
(Microsoft.Reporting.WebForms.ReportViewer)
is not compatible with the type of
control
(Microsoft.Reporting.WebForms.ReportViewer).
<rsweb:ReportViewer ID="xyz" runat="server" Width="100%" Font-Names="Verdana" Font-Size="8pt" Height="400px" ProcessingMode="Local" ShowExportControls="false">
Now, I get this error in Visual Studio as well as in production. I have the ReportViewer Redistributable installed in production.
Am I somehow missing a reference in my project, or something?
I discovered the answer: Somehow the reference to version 9 of Microsoft.Reporting.WebForms got switched to version 8. This caused the error. So deleting the reference and adding in the correct version of the reference seems to have fixed the problem.
Edit:
Well, according to the previous version of the .vbproj file, it was a reference to 9, despite that the project references properties screen told me 8. In short I'm not really sure what managed to get screwed up, but it seems to be working now.
If anyone has experienced this or has some insight, please contribute.
Following a clean install, my project didn't compile because the reference to the dll was broken, so I deleted it and added it again, then the web page where the ReportViewer is used gave a parser error:
The base class includes the field 'rprtReportsViewer', but its type (Microsoft.Reporting.WebForms.ReportViewer) is not compatible with the type of control (Microsoft.Reporting.WebForms.ReportViewer).
I found a reference on the webpage with version number different to the one I had just added:
<%# Register Assembly="Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
I changed the version to 9.0.0.0, and this time got a compiler error when I refreshed the page:
CS0433: The type 'Microsoft.Reporting.WebForms.ReportViewer' exists in both 'c:\Windows\assembly\GAC_MSIL\Microsoft.ReportViewer.WebForms\8.0.0.0__b03f5f7f11d50a3a\Microsoft.ReportViewer.WebForms.dll' and 'c:\Windows\assembly\GAC_MSIL\Microsoft.ReportViewer.WebForms\9.0.0.0__b03f5f7f11d50a3a\Microsoft.ReportViewer.WebForms.dll'
I then searched the solution for "Microsoft.ReportViewer" and found more references in compilation.config:
<add assembly="Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="Microsoft.ReportViewer.Common, Version=8.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
</assemblies>
<buildProviders>
<add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.Common, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</buildProviders>
I changed the version numbers here too and it stopped the errors
You may also need to Remove from \bin files:
Microsoft.ReportViewer.Common.dll
Microsoft.ReportViewer.ProcessingObjectModel.dll
Microsoft.ReportViewer.WebForms.dll
Microsoft.ReportViewer.WinForms.dll
I just moved them into a sub directory.
Check your page rdlc version like
<%# Register Assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
Having the same issue. Clean Windows 2008 Server install with SQL Server 2005 and SQL Reporting. The server hosts the site. Installed ReportViewer 2008 SP1. Web.config references version 9.0.0.0.
The same error message comes up: The base class includes the field but its type (Microsoft.Reporting.WebForms.ReportViewer) is not compatible with the type of control (Microsoft.Reporting.WebForms.ReportViewer).
Searched online and lots of people experience the same issue. Some people suggest manually editing project file.
I managed to fix it by setting Specific Version = True (Version=9.0.0.0) in the Solution Explorer->[Web Project Name]->References->Microsoft.Reporting.WebForms->Properties.
In one of the environments we also found Microsoft.Reporting dlls in the web bin folder. And, they were conflicting with the dlls registered in the GAC. Deleting of the dlls solved the issue.
I had this problem on a Production server. I installed the correct version of ReportViewer and made sure all the references in the project were pointing at the correct version. However, I was still getting errors.
Eventually I solved the problem by going to 'Temporary ASP.NET Files' and deleting the files for my app. To do this you'll need to stop the app first. This then solved the problem. On DEV servers I had not encountered this problem because after installing ReportViewer I re-started the machine.
Hope this helps someone. I pulled a lot of hair out before I solved this particular 'challenge'.
References -> (Microsoft.ReportViewer.WebForms), click the right mouse button.
The Specify Version option, leave it as false.
After that, just save and run again.
I came across the same error. What worked for me was to delete the reference Microsoft.ReportViewer.WebForms and add it again.

Resources