IIS 8 ASP.Net Error “configuration section cannot be used…”

iis8logoWhen working with IIS 8 (or even 7 or 7.5), you may have run across this little gem / error: “This configuration section cannot be used at this path”

HTTP Error 500.19 – Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
Module / Handler IIS Web Core
Notification BeginRequest
Handler Not yet determined

You’ll want to open the applicationhost.config located in: C:\Windows\System32\inetsrv\config

And now find the lines like this:

<section name="handlers" overrideModeDefault="Deny" />
<section name="modules" allowDefinition="MachineToApplication" overrideModeDefault="Deny" />

And change the Deny to Allow, like this:

<section name="handlers" overrideModeDefault="Allow" />
<section name="modules" allowDefinition="MachineToApplication" overrideModeDefault="Allow" />

Save the file, and you should be good!

IIS 8 ASP.Net Error “configuration section cannot be used…”

The Classic: Cannot refer to an instance member of a class from within a shared method…

I am sure you’ve gotten this before:

Cannot refer to an instance member of a class from within a shared method

Well, instead of all the reasons why, I will just tell you one simple solution:

Pretend you’re doing this:

Public Shared Function getSomething() As Integer
   For Each tControl As Control In FlowLayoutPanel1.Controls    Next

End Function

It will ERROR.

Now Add the form name:

Public Shared Function getSomething() As Integer
   For Each tControl As Control In sampleForm.FlowLayoutPanel1.Controls   Next

End Function

And run again!

The Classic: Cannot refer to an instance member of a class from within a shared method…