5 July 2007

Fix for SOAP reflection error in VS 2005 web projects

Posted by Barnabas under: How To; Programming .

VS 2005Today we found a fix for a strange error experienced while deploying a web project built in Visual Studio 2005 that has a web reference (SOAP), specifically to the Microsoft Live search service. We were using a web deploy project, and although everything compiled all right and ran well on the local development server, on pre-deployment testing the following error stack would be raised:

  • CustomAttributeFormatException: Binary format of the specified custom attribute was invalid.
  • InvalidOperationException: There was an error reflecting type ‘com.msn.search.soap.SourceRequest’.
  • InvalidOperationException: There was an error reflecting property ‘Requests’.
  • InvalidOperationException: There was an error reflecting type ‘com.msn.search.soap.SearchRequest’.
  • InvalidOperationException: There was an error reflecting ‘Request’.
  • InvalidOperationException: Method MSNSearchService.Search can not be reflected.

It turns out that good old web projects do a lot of things for you in the background. When you create a web reference, the only thing that gets stored with the web project is the .disco file and the WSDL output. Something somewhere dynamically creates and compiles the web proxy class for you on the fly, and I suspected this mechanism is broken. Without finding an exact answer, this post from the blog of Andrew Arnott of the MS .NET CF team illuminated the possible problem: the proxy class needs to be created with certain arguments, specifically with an explicit order. The command-line tool that is being invoked behind the scenes is called WSDL.EXE.

To fix our problem, we first removed the web reference from the project. By invoking the following command, we could manually create a VB.NET proxy class, which we were then able to save in the App_Code directory and check in to the project:

wsdl.exe /out:MSNSearch.vb /language:VB /order http://soap.search.msn.com/webservices.asmx?wsdl

3 Comments so far...

Eric Says:

3 October 2007 at 7:21 am.

Sweet!
I just hit the same problem and you saved me a bunch of headache.

Thanks!

Tejal Says:

14 March 2008 at 3:09 am.

Hi
i face a same problem.
At localhost my code is working properly , but when my application goes to live it give me the same error.

i tried your solution but it didn.t work ,i got the same error

Can you please help me

Thanks.

Jurjen Says:

27 May 2008 at 7:04 am.

Hi, Just wanted to say THANK YOU!!! I just ran into this problem also and ‘/order’ saved me.

Thanks !!

Leave a Reply

Categories

Archives

Links

Meta