问题
I'm working with ASP.Net web application and i want to create a membership user so i have to access the Web Configuration Tool for ASP.NET . i have run IISExpress commands in Prompt and it's works fine but whenever i run the http://localhost:5376/asp.netwebadminfiles/default.aspx?applicationPhysicalPath=C:\Users\user\Documents\Visual%20Studio%202013\Projects\MyWebsite&applicationUrl=/
in the browser i got this error !
the error message :
Server Error in '/asp.netwebadminfiles' Application.
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: CS0122: 'System.Configuration.StringUtil' is inaccessible due to its protection level
Source Error:
Line 987:
Line 988: // Put together some unique app id
Line 989: string appId =StringUtil.GetNonRandomizedHashCode(String.Concat(appPath,appPhysPath)).ToString("x", CultureInfo.InvariantCulture);
Line 990:
Line 991:
Source File: c:\Windows\Microsoft.NET\Framework\v4.0.30319\ASP.NETWebAdminFiles\App_Code\WebAdminPage.cs Line: 989
回答1:
I found the answer in this post way down in the comment from Mr_Coinche.
For those who are encountering the "CS0122: 'System.Configuration.StringUtil' is inaccessible due to its protection level" issue. It's the fault of .net 4.6.
So you can uninstall this framework (if you are on windows 8), for those who are using windows 10, it's seems difficult or impossible to uninstall .net 4.6 because it's install with windows 10.
So there is an alternative, you can modify the
c:\Windows\Microsoft.NET\Framework64\v4.0.30319\ASP.NETWebAdminFiles\App_Code\WebAdminPage.cs file code or
c:\Windows\Microsoft.NET\Framework\v4.0.30319\ASP.NETWebAdminFiles\App_Code\WebAdminPage.cs , (depending which you are trying to install)
Replace the line
string appId = StringUtil.GetNonRandomizedHashCode(String.Concat(appPath, appPhysPath)).ToString("x", CultureInfo.InvariantCulture);
with these lines:
Assembly sysConfig = Assembly.LoadFile(@"C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Configuration.dll");
Type sysConfigType = sysConfig.GetType("System.Configuration.StringUtil");
string appId = ((int)sysConfigType.GetMethod("GetNonRandomizedHashCode")
.Invoke(null, new object[] { String.Concat(appPath, appPhysPath), true }))
.ToString("x", CultureInfo.InvariantCulture);
In addition, make sure you run Notepad (or whatever code editor you choose) As Administrator, otherwise you won't have permissions to save the file once you've made the change. I made the change to both files - it's just a different way of calling the same method, but in a way that is consistent with its new protection level in .NET 4.6
来源:https://stackoverflow.com/questions/32321757/server-error-in-asp-netwebadminfiles-application-vs-2013