/// <summary>
/// Daniel Balla's Weblog - Various posts
/// on .NET Development, ASP.NET, Agile,
/// TDD, Architecture, SQL and others.
/// </summary>
[Serializable]
class Blog<T> where T : ASP.NET, Ajax, WCF, WF, new()
{
}
Tuesday, November 21, 2006
Unable to preview web service
Seldom, but still a possible scenario: when trying to preview the generated service description for an asmx web service (both .NET 1.1 and .NET 2.0) you might get an error that is not very well described:
Line 1334: OperationBinding FindHttpBinding(string verb) {
Line 1335: foreach (ServiceDescription description in serviceDescriptions) {
Line 1336: foreach (Binding binding in description.Bindings) {
Line 1337: HttpBinding httpBinding = (HttpBinding)binding.Extensions.Find(typeof(HttpBinding));
The real issue is that in your web application’s web.config file in the pages element you probably have the autoEventWireup attribute set to false
<pages … autoEventWireup="false"…
If you want to trace the problem, you can open the DefaultWsdlHelpGenerator.aspx file (located under %windir\Microsoft.NET\Framework\[version]\CONFIG\DefaultWsdlHelpGenerator.aspx) and you would notice that the error is that the serviceDescriptions member is used without being initialized (therefore the null object reference exception). Looking up in the page you notice that the serviceDescriptions member is initialized
(as:
serviceDescriptions = (ServiceDescriptionCollection) Context.Items["wsdlsWithPost"];
or
serviceDescriptions = (ServiceDescriptionCollection) Context.Items["wsdls"];)
in the Page_Load method. However, because your settings disable the autoeventwireup that prevents the Page_Load methods from being called (it is not explicitly wired to the page load event so it relies entirely on the autoeventwireup feature).
Surely this isn’t a big finding and it wouldn’t save you more than 5 minutes of debugging but it is worth mentioning because it is a “red wiring” in the framework.
Line 1334: OperationBinding FindHttpBinding(string verb) {
Line 1335: foreach (ServiceDescription description in serviceDescriptions) {
Line 1336: foreach (Binding binding in description.Bindings) {
Line 1337: HttpBinding httpBinding = (HttpBinding)binding.Extensions.Find(typeof(HttpBinding));
The real issue is that in your web application’s web.config file in the pages element you probably have the autoEventWireup attribute set to false
<pages … autoEventWireup="false"…
If you want to trace the problem, you can open the DefaultWsdlHelpGenerator.aspx file (located under %windir\Microsoft.NET\Framework\[version]\CONFIG\DefaultWsdlHelpGenerator.aspx) and you would notice that the error is that the serviceDescriptions member is used without being initialized (therefore the null object reference exception). Looking up in the page you notice that the serviceDescriptions member is initialized
(as:
serviceDescriptions = (ServiceDescriptionCollection) Context.Items["wsdlsWithPost"];
or
serviceDescriptions = (ServiceDescriptionCollection) Context.Items["wsdls"];)
in the Page_Load method. However, because your settings disable the autoeventwireup that prevents the Page_Load methods from being called (it is not explicitly wired to the page load event so it relies entirely on the autoeventwireup feature).
Surely this isn’t a big finding and it wouldn’t save you more than 5 minutes of debugging but it is worth mentioning because it is a “red wiring” in the framework.
Labels: ASP.NET

1 Comments:
I've been banging my head on this error for hours. Setting the autoEventWireup to true fixed my problem. Thanks! Now I'm going to read this blog 10 more times to understand why.
By
Joe, at Wednesday, April 9, 2008 5:46:00 PM BST
Post a Comment
<< Home