Whiskey Tango Foxtrot, but this was super unpleasant to uncover.
I’ve got a website up ‘n running and wanted to add a webservice to it, aight? Wizards make the job easy so here i go:
“Add > New item > Asp.Net > Web Service > Ok” Programming has never been so easy…
Navigate to webservice and … *poof!*
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Line 1333: 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));[NullReferenceException: Object reference not set to an instance of an object.] ASP.defaultwsdlhelpgenerator_aspx.FindHttpBinding(String verb) in c:WINDOWSMicrosoft.NETFrameworkv2.0.50727CONFIGDefaultWsdlHelpGenerator.aspx:1335Dang wizards! Obviously badly generated code? Not so…
All the performance hints and profilers will tell you, if you don’t need to automatically wire up your events, set the AutoEventWireUp=false (no, i’m not going on a blatant tangent here) in your .config. What they don’t tell you is that the @Page directive influences the generation of Wdsl for your webservice. Obviously. :Shttp://www.dotnet247.com/247reference/msgs/35/177335.aspx
http://forums.asp.net/p/385662/385662.aspx#385662
http://support.microsoft.com/default.aspx?scid=kb;en-us;324151
And in the immortal words of John Lennon: “I’m not the only one” (who got duped).
MS, you’re gonna have to do better than that if you want to catch us out 😉
2 replies on “DefaultWsdlHelpGenerator Gotcha”
In case you’re wondering where this is problematic- you cannot add a web-reference to a referencing application ‘cos the wdsl discovery is broken. You can of course “deploy” with AutoEventWireUp=false, provided you don’t need to do discovery on the web service again :S
after some follow-up with leppie, it turns out the whole reason for the fiasco lies in the way the c:WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG\DefaultWsdlHelpGenerator.aspx file has been implemented. It’s got some embedded server-side script (which needs to wire up event handling, particularly the page_load) in the markup, and it looks more like a classic asp page than anything else. ah well. so you could rewrite that, host it properly and still achieve what you want to achieve.