CS0122: "System.Configuration.StringUtil" is unavailable due to security level

I am currently engaged in a school project whereby I can allow students and teachers to look for cross-country assignments.

I am trying to go on to configure ASP.Net to add users and roles, but I got this error.

-

Server error in application /asp.netwebadminfiles.

Compilation Error Description: An error occurred while compiling the resource required to service this request. Please review the following specific error information and change the source code accordingly.

Compiler Error Message: CS0122: 'System.Configuration.StringUtil' is unavailable due to its level of protection

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 \ Framework64 \ v4.0.30319 \ ASP.NETWebAdminFiles \ App_Code \ WebAdminPage.cs Line: 989

-

In any case, can I fix this or do I need to redo the whole project? (I hope not because a lot of work has been done.)

I'm new to troubleshooting, so the walkthroughs will be greatly appreciated. thanks!

+7
c # configuration
source share
6 answers

Open ASP.NETWebAdminFiles website with any Visual Studio

 Add - Existing Website Browse to C:\Windows\Microsoft.NET\Framework\v4.0.30319\ASP.NETWebAdminFiles 

Inside the wesbite project find the c # file

ASP.NETWebAdminFiles \ App_Code \ WebAdminPage.cs

Go to Line 989

Comment out the string // string appId = StringUtil.GetNonRandomizedHashCode...

Add new line string appId = "1"

Save the website, unload it from Visual Studio

Launch IIS Express in CMD

 iisexpress.exe /path:C:\Windows\Microsoft.NET\Framework\v4.0.30319\ASP.NETWebAdminFiles /vpath:/WebAdmin /port:8181 /clr:4.0 /ntlm 

Launch your website

 http://localhost:8181/webadmin/default.aspx?applicationPhysicalPath=B:\TFS\MyWebsite\MyWebsiteRoot\&applicationUrl=/ 
+9
source share

In visual studio

File - Open - Website

GoTo: C: \ Windows \ Microsoft.NET \ Framework \ v4.0.30319 \ ASP.NETWebAdminFiles

Open

Now open App_Code \ WebAdminPage.cs

GoTo Line 989

Comment on the current text and insert

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

now try again

+1
source share

The problem occurs if you installed the .NET Framework 4.6 . This is fixed in 4.6. 1 , so just downloading it (or a later version) solves the problem. No code changes are required.

0
source share

check the target infrastructure if it is 4.0, then change it to 3.5 and create a project and open the asp.net configuration, this will work for me

0
source share

StringUtil is the (static) class in your project. This class is most likely defined as:

 private static void StringUtil 

This means that your WebAdminPage cannot see it, because it is private . This will result in an error. Change it to:

 public static void StringUtil 

Now any class can use it at any time.

Learn more about security levels in Microsoft Documentation :

EDIT

After reviewing the error code again, I see that the namespace for StringUtil is System.Configuration.StringUtil , which means that it is a system class, not a class in your project. According to Microsoft source code, this class is defined as a static internal class StringUtil . Following the previous link on protection levels, we can see that:

Internal: access is limited to the current assembly

This means that the StringUtil class can only be used from the assembly (DLL file) in which it is limited. If you cannot add your own code to the Microsoft system DLL files, you cannot use this method (since Microsoft added it for your own internal use).

-one
source share

change

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

to

 string appId = ToString(); 

fix it

-2
source share

All Articles