Thank you for visiting!

Please consider subscribing to the RSS feed or following me on Twitter.

Web Services And AutoEventWireUp

If you get the NullReferenceException error when dealing with web services, it might have to do with AutoEventWireUp being set to false. If you get an error pointing at something like foreach (ServiceDescription description in serviceDescriptions), it might also have to do with AutoEventWireUp set to false.

For instance, if you set AutoEventWireUp to false globally, in Web.Config, your web services will fail.

There's a fix for this though, although it's a bit of a different one.

You just have to locate the DefaultWsdlHelpGenerator.aspx file in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\CONFIG (or similar) and add this line to the top:

<%@ Page AutoEventWireup="true" %>


If the AutoEventWireup attribute of the Page directive is set to true (or if it is missing, since by default it is true), the page framework calls page events automatically, specifically the Page_Init and Page_Load methods. In that case, no explicit Handles clause or delegate is needed.

To the top