8

i am currently doing a school project whereby i can allow students and teachers to search for intership jobs.

I am trying to get to the ASP.Net Configuration to add users and roles but i got this error.

-

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

-

Is there anyway i can fix this or do i have to redo my whole project?(hopefully not because theres alot of work done.)

I'm quite a newbie at troubleshooting so step by step guides will be greatly appreciated. thanks!

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
X-men
  • 121
  • 1
  • 2
  • 8

6 Answers6

9

Open the ASP.NETWebAdminFiles website using any Visual Studio

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

Inside your wesbite project, browse to the C# file

ASP.NETWebAdminFiles\App_Code\WebAdminPage.cs

Go to Line 989

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

Add a new line string appId = "1"

Save the website, Unload it from Visual Studio

Run 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

Run your website

http://localhost:8181/webadmin/default.aspx?applicationPhysicalPath=B:\TFS\MyWebsite\MyWebsiteRoot\&applicationUrl=/
Riaan
  • 3,423
  • 4
  • 30
  • 36
1

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 out the current text and paste

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

now re-try

1

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 issue. No code changes necessary.

Tobias
  • 2,089
  • 2
  • 26
  • 51
0

check your targeted framework if it is 4.0 then change to 3.5 and build the project and open asp.net configuration it is work for me

Milap Pancholi
  • 134
  • 1
  • 12
-1

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

private static void StringUtil

This means that your WebAdminPage can't see it, because it is private. This will cause the error you see. Change it to:

public static void StringUtil

Now any class can use it at any time.

Read more about protection levels in Microsoft's documentation:

EDIT

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

Internal: Access is limited to the current assembly

Which means that the StringUtil class can only be used from the assembly (DLL file) it is confined in. Seeing as you can't add your own code to Microsoft's system DLLs, you can't use this method (As Microsoft has added it for their own internal use).

TheHvidsten
  • 4,028
  • 3
  • 29
  • 62
  • where do i go to change the code? i cant seem to find "private static void StringUtil" in my codes to change it. – X-men Aug 20 '15 at 11:31
  • If you're using Visual Studio, you can right-click on `StringUtil.GetNonRandomizedHashCode()` and choose "Go To Definition". – TheHvidsten Aug 20 '15 at 11:38
  • how do i go about finding the code ''StringUtil.GetNonRandomizedHashCode()'' ? sorry about it. I'm quite blur at troubleshooting – X-men Aug 20 '15 at 11:47
  • I updated my answer with more information. I think you're out of luck and have to use another way to generate your `appId`. – TheHvidsten Aug 20 '15 at 11:57
  • The issue you reported is already fixed in .net framework 4.6.1 which you can download from https://www.microsoft.com/en-us/download/details.aspx?id=49982 – Arun Dec 06 '16 at 23:08
-2

change

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

to

string appId = ToString();

fix it