question

robm-4957 avatar image
0 Votes"
robm-4957 asked robm-4957 answered

missing a reference The referenced component 'System.Web.WebPages.Administration' could not be found.

I have a reference to
System.Web.WebPages.Administration that seems to be missing see attached image. How do I reinstall it?


120334-image.png


dotnet-aspnet-general
image.png (24.3 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

robm-4957 avatar image
0 Votes"
robm-4957 answered YijingSun-MSFT commented

Server Error in '/' Application.
Attempt by security transparent method 'System.Web.WebPages.Administration.SiteAdmin.RegisterAdminModule()' to access security critical method 'System.Web.WebPages.ApplicationPart..ctor(System.Reflection.Assembly, System.String)' failed.
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.MethodAccessException: Attempt by security transparent method 'System.Web.WebPages.Administration.SiteAdmin.RegisterAdminModule()' to access security critical method 'System.Web.WebPages.ApplicationPart..ctor(System.Reflection.Assembly, System.String)' failed.

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:


[MethodAccessException: Attempt by security transparent method 'System.Web.WebPages.Administration.SiteAdmin.RegisterAdminModule()' to access security critical method 'System.Web.WebPages.ApplicationPart..ctor(System.Reflection.Assembly, System.String)' failed.]
System.Web.WebPages.Administration.SiteAdmin.RegisterAdminModule() +44
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: Attempt by security transparent method 'System.Web.WebPages.Administration.SiteAdmin.RegisterAdminModule()' to access security critical method 'System.Web.WebPages.ApplicationPart..ctor(System.Reflection.Assembly, System.String)' failed..]
System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection`1 methods, Func`1 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: Attempt by security transparent method 'System.Web.WebPages.Administration.SiteAdmin.RegisterAdminModule()' to access security critical method 'System.Web.WebPages.ApplicationPart..ctor(System.Reflection.Assembly, System.String)' failed..]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +10087352
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +99
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +263

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4330.0

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @robm-4957 ,
Do you have tried remove the reference? I assume the runtime was fetching the conflicting version of System.Web.Administration from this dll instead of using the new version.
you could refer Oscar Cauich's said from this article:
https://stackoverflow.com/questions/29755925/attempt-by-security-transparent-method-system-web-webpages-administration-sitea
Best regards,
Yijing Sun

1 Vote 1 ·
YijingSun-MSFT avatar image
0 Votes"
YijingSun-MSFT answered YijingSun-MSFT commented

Hi @robm-4957 ,
First you need to check if the nuget package exists.
If you need to install it,you could do like this:
Right click your project-->Select Manage Nuget Package-->Search 'Microsoft.AspNet.WebPages.Administration' in Browse search textbox-->Select and Install it.

If the package exist but broken, you could uninstall and then reinstall it,there are two ways:

  • In Package Manager console,you could enter this command:

     Update-Package -reinstall
    
  • In Package Manager UI

    Right click your project-->Select Manage Nuget Package-->Search 'Microsoft.AspNet.WebPages.Administration' in Installed search textbox-->Select and Unstall it -->
    Search 'Microsoft.AspNet.WebPages.Administration' in Browse search textbox-->Select and Install it.

Best regards,
Yijing Sun


If the answer is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our  documentation  to enable e-mail notifications if you want to receive the related email notification for this thread.

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I now get

Server Error in '/' Application.
Attempt by security transparent method 'System.Web.WebPages.Administration.SiteAdmin.RegisterAdminModule()' to access security critical method 'System.Web.WebPages.ApplicationPart..ctor(System.Reflection.Assembly, System.String)' failed.
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.MethodAccessException: Attempt by security transparent method 'System.Web.WebPages.Administration.SiteAdmin.RegisterAdminModule()' to access security critical method 'System.Web.WebPages.ApplicationPart..ctor(System.Reflection.Assembly, System.String)' failed.

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:


[MethodAccessException: Attempt by security transparent method 'System.Web.WebPages.Administration.SiteAdmin.RegisterAdminModule()' to access security critical method 'System.Web.WebPages.ApplicationPart..ctor(System.Reflection.Assembly, System.String)' failed.]
System.Web.WebPages.Administration.SiteAdmin.RegisterAdminModule() +44
System.Web.WebPages.Administration.PreApplicationStartCode.Start() +22

0 Votes 0 ·

Hi @robm-4957 ,
As far as I think,it seems that the system.web.webpages.administration.dll was remaining in the bin folder and this caused a problem.I suggest you could delete the entire contents of the bin folder and doing a rebuild. It may be could solve your problems.
Best regards,
Yijing Sun

0 Votes 0 ·
robm-4957 avatar image
0 Votes"
robm-4957 answered

Yes I saw that posting as well , I did delete all the dll in the bin folder cleaned and re build . I still get that error

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

robm-4957 avatar image
0 Votes"
robm-4957 answered

that worked!

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.