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!

4
  • It seems to be a problem with the last framework .net 4.6 : since I installed VS2015, I have the same problem. I'm not sure, but I think uninstalling VS2015 and .net Fx 4.6 may solve the problem.
    – glacasa
    Commented Sep 7, 2015 at 14:13
  • @glacasa did it work? Commented Oct 19, 2015 at 18:54
  • 1
    @riaandelange's answer worked for me, I didn't have to uninstall anything
    – glacasa
    Commented Oct 20, 2015 at 8:38
  • This is the best answer I have found ever...--->> stackoverflow.com/a/33115202/5506779 Commented Oct 30, 2015 at 10:59

6 Answers 6

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=/
3
  • 2
    I had to run VS as administrator to modify the file, and now it's ok.
    – glacasa
    Commented Sep 11, 2015 at 8:10
  • 1
    Yes @riaandelange, you saved me from downgrading my OS.
    – Jon P
    Commented Oct 5, 2015 at 7:43
  • 1
    Worked great, thanks. I set my code to the following to avoid conflicts: string appId = Guid.NewGuid().ToString();
    – Farskeptic
    Commented Dec 15, 2015 at 14:09
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.

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

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

5
  • 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
    Commented Aug 20, 2015 at 11:31
  • If you're using Visual Studio, you can right-click on StringUtil.GetNonRandomizedHashCode() and choose "Go To Definition". Commented Aug 20, 2015 at 11:38
  • how do i go about finding the code ''StringUtil.GetNonRandomizedHashCode()'' ? sorry about it. I'm quite blur at troubleshooting
    – X-men
    Commented Aug 20, 2015 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. Commented Aug 20, 2015 at 11:57
  • The issue you reported is already fixed in .net framework 4.6.1 which you can download from microsoft.com/en-us/download/details.aspx?id=49982
    – Arun
    Commented Dec 6, 2016 at 23:08
-2

change

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

to

string appId = ToString();

fix it

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.