Partilhar via


How to generate Begin/End invocation pattern methods in web service proxies in VS 8+

It is a problem asked by some customers.  They were using Begin/End invocation pattern to call web service asynchronously.  Those async methods were generated in web proxies in Visual Studio 7.x, and when they are using wsdl.exe tool, but were gone when they use the Visual Studio 2005 or Orcas Beta 2.  In both VS 2005 and Orcas, the generated proxy only contains event-driven programming pattern methods.

First, for who is using the event-driven model, there is no reason to turn on the Begin/End pattern methods, because only one of them should be used.  For many users, the event-driven model is also easier to use.

For those who still need use the Begin/End pattern methods, it is still possible to turn on a project level option to get them back:

To do that, we need unload the project from VS, and edit the project file directly in an editor. (Please backup one in case we do something wrong.)

In the first section of PropertyGroup, you will see many properties like:
<ProjectGuid>{F4DC6946-F07E-4812-818A-xxxxxxxx}</ProjectGuid>
<OutputType>Exe</OutputType>
...
Don't change any of those, but do add an extra property just like the OutputType into that section like:
<WebReference_EnableLegacyEventingModel>true</WebReference_EnableLegacyEventingModel>
Ignore the warning from the xml editor, save the file, and reload the project into VS.

After that, you have to regenate all proxy code (by updating the reference, or running the custom tool on the .map file)

Note: it is only for old web reference proxies.  For old service references (WCF proxies), the Begin/End pattern async methods will be generated when "Generate async method" is turned on for that reference. (That is beta 2 feature.)  The methods for another pattern (event model) will not be generated in beta 2, but will be added in RTM when the project is targetting the new 3.5 framework.