【问题标题】:Server Error in '/asp.netwebadminfiles' Application - VS 2013“/asp.netwebadminfiles”应用程序中的服务器错误 - VS 2013
【发布时间】:2015-09-01 00:19:42
【问题描述】:

我正在使用 ASP.Net Web 应用程序,我想创建一个会员用户,因此我必须访问 ASP.NET 的 Web 配置工具。我已经在 Prompt 中运行了 IISExpress 命令,它工作正常,但是每当我在浏览器中运行 http://localhost:5376/asp.netwebadminfiles/default.aspx?applicationPhysicalPath=C:\Users\user\Documents\Visual%20Studio%202013\Projects\MyWebsite&applicationUrl=/ 时,我都会收到此错误!

错误信息:

“/asp.netwebadminfiles”应用程序中的服务器错误。

编译错误

描述:编译资源时出错 需要为该请求提供服务。请查看以下具体内容 错误详情并适当修改您的源代码。

编译器错误消息:CS0122:“System.Configuration.StringUtil”是 由于其保护级别而无法访问

来源错误:

第 987 行:

第 988 行:// 将一些唯一的应用程序 ID 放在一起

第 989 行:字符串 appId =StringUtil.GetNonRandomizedHashCode(String.Concat(appPath,appPhysPath)).ToString("x", CultureInfo.InvariantCulture);

第 990 行:

第 991 行:

源文件: c:\Windows\Microsoft.NET\Framework\v4.0.30319\ASP.NETWebAdminFiles\App_Code\WebAdminPage.cs 线路:989

【问题讨论】:

标签: asp.net error-handling asp.net-membership configuration-files iis-express


【解决方案1】:

我在 Mr_Coinche 的评论下方的 post 中找到了答案。

对于遇到“CS0122”的人: 'System.Configuration.StringUtil' 是不可访问的,因为它 保护级别”问题。这是.net 4.6的错。

所以你可以卸载这个框架(如果你在 Windows 8 上), 那些使用 Windows 10 的人,似乎很难或不可能 卸载 .net 4.6,因为它与 Windows 10 一起安装。

所以有一个替代方案,你可以修改

c:\Windows\Microsoft.NET\Framework64\v4.0.30319\ASP.NETWebAdminFiles\App_Code\WebAdminPage.cs 文件代码或

c:\Windows\Microsoft.NET\Framework\v4.0.30319\ASP.NETWebAdminFiles\App_Code\WebAdminPage.cs ,(取决于您要安装的)

换行

string appId = StringUtil.GetNonRandomizedHashCode(String.Concat(appPath, appPhysPath)).ToString("x", CultureInfo.InvariantCulture);

这些行:

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);

此外,请确保您以管理员身份运行记事本(或您选择的任何代码编辑器),否则一旦进行更改,您将无权保存文件。我对这两个文件进行了更改 - 这只是调用相同方法的不同方式,但其方式与 .NET 4.6 中的新保护级别一致

【讨论】:

    猜你喜欢
    • 2021-12-26
    • 1970-01-01
    • 2017-09-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-01
    • 1970-01-01
    相关资源
    最近更新 更多