日期:2014-05-18  浏览次数:21044 次

vs2010 WebService为何找不到Begin、End方法
WebService中写一个方法应该会在外部调到3个方法,第一个是自己写的,第二个是begin开头的,第三个是end开头的.. 在网上查了一下,http://www.cnblogs.com/smallstone/archive/2010/05/27/1745275.html。
To do that, you need unload the project from VS, and edit the project file directly in an editor. (Please backup one in case you do something wrong.)
In the first section of PropertyGroup, you will see many properties like:
  <ProjectGuid>{F4DC6946-F07E-4812-818A-F35C5E34E2FA}</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) 

问题是我在winform中在哪添加相应的 <WebReference_EnableLegacyEventingModel>true</WebReference_EnableLegacyEventingModel>  
谢谢!!

------解决方案--------------------
E文没有看懂吗,大概的意思是关闭对应的Project文件,以防万一先做个备份,然后用notepad这样的编辑器打开Project文件,在第一个PropertyGroup节点中添加Project的属性。把WebReference_EnableLegacyEventingModel节点添加到OutputType节点后面就可以。然后在VS中重新打开Project,选择WebService右键菜单中选择“更新Web引用”,更新完后就有Begin/End方法了。

对于Service Reference(服务引用)如WCF的,可以通过添加Reference时选择下面的“高级(V)...”后选中“生成异步操作”或者针对已添加的Service Reference右键菜单“配置服务引用”后选中“生成异步操作”确定后就有Begin/End方法了。