I am using Visual Studio 2010 and I installed "Microsoft Report Viewer 2012 Runtime" hoping to test the new reporting system in SQL 2012. After which I cleared for ref to "Microsoft.ReportViewer.WebForms" from my Web.config and removed the ReportViewer control from my toolbox and added the new version 11 ReportViewer.
I added the new control to a testing page and for one it adds this register to the test page:
<%# Register Assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
and it adds these entry to the Web.config:
<buildProviders>
<add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</buildProviders>
<httpHandlers>
<add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" validate="false" />
</httpHandlers>
<handlers>
<add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</handlers>
The control in the toolbox is the version 11 addition but the system keeps trying to ref the verion 10 edition. Also when I try to compile it I get the error:
The type 'Microsoft.Reporting.WebForms.ReportViewer' exists in both 'c:\Windows\assembly\GAC_MSIL\Microsoft.ReportViewer.WebForms\10.0.0.0__b03f5f7f11d50a3a\Microsoft.ReportViewer.WebForms.dll' and 'c:\Windows\assembly\GAC_MSIL\Microsoft.ReportViewer.WebForms\11.0.0.0__89845dcd8080cc91\Microsoft.ReportViewer.WebForms.DLL'
I think I had the exact same problem. If so, my solution was to delete all entries in web.config referencing ReportViewer, then do the same in References, build the project and then re-ADD a reportviewer in the page.
web.config will update with new handlers and assemblies for the newer version.
I had the same error, and resolved it by doing the following:
In the aspx page (HTML code), updated the #Register Version value to correspond to the version of the assembly I was using, and updated the PublicKeyToken value with the correct value for the assembly.
In your web config, it means you have specified both v 10 and 11 dlls. Remove one or the other.
I have removed the following entry from package.config and it works
<package id="MicrosoftReportViewerWebForms_v10" version="1.0.0" targetFramework="net45" />
Related
Our project is built with VS 2010 and reports are built with SSRS 2005 and it works just fine, in this environment.
We are trying to migrate to SSRS 2012. In run time we get this error
'Microsoft.ReportViewer.Common, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
I copied the file "MicrosoftReportViewerCommon.dll" to the bin folder, but its version is 10.0.x.x. I don't know how to find version 8.0.0.0.
I don't know exactly what we should do. Is it supposed to add this file to the project? Or the references in the project should be changed to refer to another file version?? And how this should be done??
In the web form we have this line of code:
<%# Register Assembly="Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
and in web.config:
<system.web>
<httpHandlers>
<add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
validate="false" />
</httpHandlers>
......
</system.web>
<system.webServer>
<handlers>
<add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</handlers>
</system.webServer>
Any help is appreciated.
After 2 days of searching the web, I figured out how to overcome this error.
I had to install ReportViewer 2005, and this installer will register “Microsoft.ReportViewer.Common Version=8.0.0.0” in GAC automatically.
I've been told that is not a good practice and it is just a workaround, because the project is not running using the most updated controls and it is still using the old ones.
For now the project is working fine, but I hope some body provide me with a real solution.
I had a similar problem and found I needed three files:
Microsoft.ReportViewer.Common.dll
Microsoft.ReportViewer.ProcessingObjectModel.dll
Microsoft.ReportViewer.WebForms.dll
And the config file looked like this:
<assemblies>
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="Microsoft.ReportViewer.Common, Version=9.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
</assemblies>
<buildProviders>
<add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.Common, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</buildProviders>
I have a report (rdlc) file made on VS2008 and can work on both Report Viewer 2008 & 2010.
Then I converted the rdlc report file to Report Viewer 2010 by using xmlns="http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition" and using <ReportSections> appropriately inside the file. (I did this because when I open the report file in vs2010 it didn't gave any alert for converting the file; so I thought I could do it manually.)
After that manual conversion, I continued using VS2010 with Report Viewer 2010 in my project but it gives me an error text : "The report definition has an invalid target namespace 'http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition' which cannot be upgraded."
I'm sure that the Microsoft.ReportViewer.WebForms assembly is version 10 in my project references. And also I used the following configurations in config file
<system.webServer>
<handlers>
<add name="ReportViewerWebControl10" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" resourceType="Unspecified" />
<!--<add name="ReportViewerWebControl9" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" resourceType="Unspecified" />-->
...
</handlers>
...
</system.webServer>
...
<system.web>
<httpHandlers>
<add verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" validate="false" />
<!--<add verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" validate="false" />-->
...
</httpHandlers>
</system.web>
So what is the problem? How can I convert rdlc files from 2008 to 2010 for the best? And if the problem is not caused by the rdlc itself how can I fix this? Is there a way to show the conversion popup in vs2010 as described here?
I'm getting this error:
Error: AjaxControlToolkit requires ASP.NET Ajax 4.0 scripts. Ensure the correct version of the scripts are referenced. If you are using an ASP.NET ScriptManager, switch to the ToolkitScriptManager in AjaxControlToolkit.dll.
I've searched Hi and Low and can not resolve this. When I went to VS2008 I had the same issue and resolved it with changing my web.config
Now I ma running VS 2012 express. I've installed AjaxControlToolkit version 4.1.60501.0
Web.config:
<compilation debug="false" targetFramework="4.5">
<assemblies>
<add assembly="AjaxControlToolkit, Version=4.1.60501.0, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e"/>
<add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
and
<controls>
<add tagPrefix="cc1" namespace="AjaxControlToolkit" assembly="AjaxControlToolkit"/>
</controls>
In ASPX I have:
<cc1:ToolkitScriptManager ID="ScriptManager1" runat="server">
</cc1:ToolkitScriptManager>
And I'm getting the above error. I know the Toolkit DLL is the correct version.
I am also running VS2008 / Ajax 3.5 on the same machine, but I cleared out the Temporary ASP.Net Files folder of all other projects and still have the issue. When I run this new VS2012 project, a ROOT folder is created in the in the Temp folder and the AjaxControlToolkit.DLL in that folder is version 4.1.60501.0
What needs to change?
Thanks Much,
Jim
Working against the current RC2 - the template that is generated Razor views includes:
#{
ViewBag.Title = "Details1";
Layout = "/Views/Shared/_Public.cshtml";
}
With a red squiggly under ViewBag.Title and this compiler error:'
Error 4 One or more types required to compile a dynamic expression cannot be found. Are you missing references to Microsoft.CSharp.dll and System.Core.dll? c:\Visual Studio 2010\Projects\myProj\Views\Webinar\Details1.cshtml 6 2 TTSTrain.Webinars.WebEntry
But the project builds and functions correctly. Is the error indicative of other problems that should be addressed?
I got the same problem after I removed the targetFramework attribute from the <compilation> element in the Web.config file.
Once I restored it to
<compilation debug="true" targetFramework="4.0">
Everything worked fine again!
I solved it in the following way:
First i noticed using gacutil (Global Assembly Cache Utility) that it contained two references to System.Core, one to version 4.0 and one to version 3.5. Apparently inside the razor views, even if in the project i had the correct reference to version 4.0, it was still using version 3.5 and that's why i was getting the error about the dynamic types.
To check if that's your case open as administrator Visual Studio Command Prompt and execute:
gacutil -l System.Core
To remove the reference to the old version of System.Core i did the following steps:
- cd %systemroot%\assembly\
From here you may have more that one "gac" directory, so you will have to search within each to find your component. For me, it was within the "gac_MSIL" directory.
- cd gac_msil
- cd System.Core
- cd <assembly version number>__<public key token>
- erase *.* Say "y" to are you sure.
- cd ..
- rd <assembly version number>__<public key token>
- cd ..
- rd System.Core
After that I opened my solution again in visual studio and the error was gone, it references properly to System.Core 4.0 and I was not getting the dynamic errors anymore :)
I hope it will help you as well,
Best, N.
Similar to #Kaiser's answer, I experienced this problem as a result of having multiple System.Core assemblies in the GAC.
I chose not to delete the 3.5 assembly, however. Instead, in the Views web.config, I modified the configuration/system.web/compilation node as follows:
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
</assemblies>
</compilation>
The important line is the last assembly node: it tells the Razor compiler which GAC assembly version to use.
Once I did this, all was well in my Razor views.
I do not have this problem when running VS 2012 as administrator.
Otherwise, what worked for me:
in root web config have added as recommended reference to correct assembly as child of compilation node`
<system.web>
<compilation debug="true" targetFramework="4.5">
<assemblies>
<add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</assemblies>
</compilation>
</system.web>
set copy local = true properties for System.Core and Microsoft.CSharp`
Do you have a reference to Microsoft.CSharp and System.Core?
MVC Views (usually) get compiled dynamically when you access your site, not when you compile the application in VS. I imagine you will see issues when running the site. Just add the two references and you should be fine.
By using Peters answer i managed to solve the issue with Html.EditorFor(m => m.xxx) underline errors in the chtml files.
Althought the ViewBar error persisted.
So i changed the web.config like this
<compilation debug="true" targetFramework="4.5.1">
<assemblies>
<add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<add assembly="Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</assemblies>
</compilation>
Notice the Microsoft.Csharp line.
The above did the trick and now the chtml editor is clear from the red underlines.
Thanks Peter
I had the exact same problem. By default, when you create an MVC3 app it sticks a web.debug.config and a web.release.config in the solution. When I got rid of those two items, the ViewBag issue resolved itself. It may have something to do with what Peter was saying above but I didn't test that.
That is the time when other fields in ViewBag is read. So if you are passing them from controller.
ViewBag.yourobjectDto = yourObjectDto;
make sure this line is not blocked through if condition or something.
Try
Page.Title = "Details1";
It might work.
If I set <compilation targetFramework="4.0"> in web.config, Visual Studio 2010 shows all Linq extension methods in ASPX files (not codebehinds). But when I change my project to target 3.5 (which supports Linq extension methods) Visual Studio removes the previously mentioned attribute in web.config, but Linq intellisense in APSX files goes with it as well.
Question
Is it possible to convince Visual Studio 2010 to not assume and fall back to 2.0 when editing ASPX files, so Linq extension methods would still be listed in intellisense dropdown?
Edit
Manually adding assemblies and import namespaces doesn't do the trick as I've pointed out in one of my previous questions, when I didn't know what was going on.
Problem reproduction
To reproduce this issue do the following:
In Visual Studio 2010 open Asp.net MVC project properties and target NetFx 3.5
Open web.config and remove targetFramework attribute if it's still there.
Write some code in the view itself (ASPX) that uses Linq extension method (ie. (new List<string>()).Any(s => string.IsNullOrEmpty())). You should see that Any is not recognised by Visual Studio 2010.
Start adding one configuration setting by one in web.config. There should be no difference about Any method.
Add <% # Imports ... %> to the view. There should be no difference about Any method either.
Running the application is not a problem. It runs and it also executes Any Linq extension method. No problem with that. Design time support is the issue here.
My web.config file
This is the complete content of my web.config file, that doesn't do the expected (I can include commented out parts as well, but that doesn't make any difference - original Asp.net MVC 2 project template doesn't include these either):
<?xml version="1.0"?>
<configuration>
<system.web>
<httpHandlers>
<add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/>
</httpHandlers>
<compilation debug="true" batch="true">
<assemblies>
<!--
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
-->
<add assembly="System.Web.Abstractions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
<pages enableViewState="false">
<controls>
<add tagPrefix="SharePoint" assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" namespace="Microsoft.SharePoint.WebControls" />
</controls>
<namespaces>
<add namespace="Microsoft.SharePoint"/>
<add namespace="System.Collections.Generic"/>
<add namespace="System.Linq"/>
<add namespace="System.Web.Mvc"/>
<add namespace="System.Web.Mvc.Html"/>
<add namespace="System.Web.Routing"/>
<add namespace="MyApp.Objects"/>
<add namespace="MyApp.Web.General"/>
<add namespace="MyApp.Web.Helpers"/>
</namespaces>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<remove name="BlockDirectAccessHandler"/>
<add name="BlockDirectAccessHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
</handlers>
</system.webServer>
</configuration>
This is how it looks like in Visual Studio 2010. In the image you can't see the extra line <%# Import Namespace="System.Linq" %> that should be right after <%# Control ... %>, but I've tried with and without. system.web/pages/namespaces is the global setting for this anyway.
The root web.config for .NET 4.0 has System.Linq added to system.web/pages/namespaces. This is not the case for .NET 3.5 which, although it includes the Linq library, did not introduce changes to the root web.config for backwards-compatibility reasons, so you have to add it to the system.web/pages/namespaces in your web.config.
See ASP.NET Configuration File Hierarchy and Inheritance
I think it's because LINQ is assumed to be included in the 4.0 framework. For older versions, you can manually import the LINQ namespace by adding this to each ASPX page at the top:
<%# Import Namespace="System.Linq" %>
Or if you don't want to do that in each file, you can put it in your web.config.
Edit - As has been pointed out by others, your problem may come from the fact that you have System.Core commented out of your web.config, which is required for those extension methods.
Including System.Core assembly is of course important. But doesn't do anything is you don't also do this next thing.
To make everything work in Visual Studio 2010 as expected (and under framework 3.5) you have to add <system.codedom> configuration element in web.config as well. This is the part that was missing:
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">
<providerOption name="CompilerVersion" value="v3.5"/>
<providerOption name="WarnAsError" value="false"/>
</compiler>
</compilers>
</system.codedom>