I am working on porting a Visual Studio 2017 project from Windows 10 Pro to Windows 11 Pro and Visual Studio 2019 (Visual Studio 2017 installation is no longer available from Microsoft).
The project originated in 2011. It used System.Web.WebPages (and Razor) along with SQL server 2012 and Entity Framework 4.0.
The target data environment on Windows 11 Pro is SQL Server 2019 and Entity Framework 6.x.
After building the solution on the new machine and fixing a number of Entity Framework issues, I encountered the following exception:
The pre-application start initialization method Start on type System.Web.WebPages.Administration.PreApplicationStartCode threw an exception with the following error message: Method 'get_IsBindingRedirectSupported' in type 'System.Web.WebPages.Administration.PackageManager.WebProjectSystem' from assembly 'System.Web.WebPages.Administration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation..
On the target PC, the installed version of System.Web.WebPages.Administration is 2.0.30506
Web.Config has the following assembly binding:
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
I suspect that there are versioning issues somewhere within SystemWeb..WebPages.Administration that do not immediately jump out beyond the version issue raised in the exception error (2.0.0.0 vs. 2.030506).
I tried changing the "new version" number in Web.Config's "System.Web.WebPages" webassembly binding to 2.030506, but this just threw another exception that WebPages for that version did not exist.
The resolution of this is beyond my limited skill set. I cannot seem to find out what or how to do to deal with this issue.
Any help would be greatly appreciated. I am ddesparate. Here is the YSOD:
Server Error in '/' Application.
Method 'get_IsBindingRedirectSupported' in type 'System.Web.WebPages.Administration.PackageManager.WebProjectSystem' from assembly 'System.Web.WebPages.Administration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.TypeLoadException: Method 'get_IsBindingRedirectSupported' in type 'System.Web.WebPages.Administration.PackageManager.WebProjectSystem' from assembly 'System.Web.WebPages.Administration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[TypeLoadException: Method 'get_IsBindingRedirectSupported' in type 'System.Web.WebPages.Administration.PackageManager.WebProjectSystem' from assembly 'System.Web.WebPages.Administration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.] System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes) +0 System.Reflection.RuntimeAssembly.GetExportedTypes() +22 System.Web.WebPages.ApplicationParts.ResourceAssembly.GetTypes() +13 System.Web.WebPages.ApplicationParts.ApplicationPartRegistry.Register(ApplicationPart applicationPart, Func`1 registerPageAction) +116 System.Web.WebPages.ApplicationPart.Register(ApplicationPart applicationPart) +53 System.Web.WebPages.Administration.SiteAdmin.RegisterAdminModule() +91 System.Web.WebPages.Administration.PreApplicationStartCode.Start() +22
[InvalidOperationException: The pre-application start initialization method Start on type System.Web.WebPages.Administration.PreApplicationStartCode threw an exception with the following error message: Method 'get_IsBindingRedirectSupported' in type 'System.Web.WebPages.Administration.PackageManager.WebProjectSystem' from assembly 'System.Web.WebPages.Administration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation..]
System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection1 methods, Func1 setHostingEnvironmentCultures) +646
System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +147
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +107
System.Web.Compilation.BuildManager.ExecutePreAppStart() +165
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +590
[HttpException (0x80004005): The pre-application start initialization method Start on type System.Web.WebPages.Administration.PreApplicationStartCode threw an exception with the following error message: Method 'get_IsBindingRedirectSupported' in type 'System.Web.WebPages.Administration.PackageManager.WebProjectSystem' from assembly 'System.Web.WebPages.Administration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation..] System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +10072264 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +99 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +263