ASP.NET网站CS0433错误:ReportViewer程序集冲突解决方案咨询
Fixing CS0433 Error: ReportViewer Exists in Two Assemblies (ASP.NET)
Hey there, let's tackle this CS0433 error head-on—it's a super common gotcha when maintaining legacy ASP.NET projects with conflicting ReportViewer assemblies. Here are actionable, tested steps to resolve it:
1. Clean Up Duplicate Project References
- Open your project in Visual Studio, right-click the project in Solution Explorer → select Manage NuGet Packages. Check if you have multiple versions of
Microsoft.ReportViewerpackages (e.g., WebForms and WinForms variants, or old/new versions coexisting). Uninstall all except the 8.0.0.0 version you need. - Navigate to your project's
binfolder and manually delete all ReportViewer-related.dllfiles (likeMicrosoft.ReportViewer.WebForms.dllandMicrosoft.ReportViewer.Common.dll). Rebuild the project to let VS copy the correct version back intobin.
2. Refine Assembly Binding Redirects in web.config
A basic newVersion setting might not cover all old versions. Update your <runtime> section to force all redirects to 8.0.0.0:
<runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="Microsoft.ReportViewer.WebForms" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/> <bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0"/> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="Microsoft.ReportViewer.Common" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/> <bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0"/> </dependentAssembly> </assemblyBinding> </runtime>
3. Check GAC and IIS Application Pool Settings
- Global Assembly Cache (GAC): Open an admin Command Prompt and run
gacutil /l Microsoft.ReportViewer.WebFormsto see if multiple versions are installed in the GAC. If so, remove unused versions (be cautious—this affects all apps on the server) or add acodeBaseentry in web.config to explicitly point to your project's 8.0.0.0 DLL:<dependentAssembly> <assemblyIdentity name="Microsoft.ReportViewer.WebForms" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/> <codeBase version="8.0.0.0" href="file:///C:/Your/Project/Path/Bin/Microsoft.ReportViewer.WebForms.dll"/> </dependentAssembly> - IIS Application Pool: Ensure your app pool uses the same .NET Framework version as your project. Mismatched versions can cause IIS to load the wrong assembly.
4. Fix Page/Control Directive Conflicts
Check your ASPX pages and ASCX user controls for Register directives that reference a different ReportViewer version, like:
<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=9.0.0.0, ..." Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
Update the version number to 8.0.0.0 to match your configuration.
5. Clear Temporary Files
- Delete your project's
objfolder and clear Visual Studio's project cache (via Tools → Options → Projects and Solutions → Clean Project Cache). Rebuild the solution afterward. - If deployed to IIS, clear the temporary ASP.NET files at
C:\Windows\Microsoft.NET\Framework\[Your .NET Version]\Temporary ASP.NET Files(target your site's subfolder).
内容的提问来源于stack exchange,提问作者Josh Russo
相关产品推荐
相关产品推荐

