天天看點

windows phone7 添加Service Reference不成功的問題

最近幾天在學習windows phone7的開發,在做Location Service時遇到一個問題,就是添加一個Service Reference(我添加的是http://msrmaps.com/TerraService2.asmx,大家應該都熟悉,不會有什麼問題)後,出現5個警告和一個錯誤,它們分别是:

Warning 1 Custom tool warning: Cannot import wsdl:portType

Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter

Error: Could not load type 'System.Runtime.Serialization.DataContractSet' from assembly 'System.Runtime.Serialization, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.

XPath to Error Source: //wsdl:definitions[@targetNamespace='http://msrmaps.com/']/wsdl:portType[@name='TerraServiceSoap'] E:\ASP.NET\Visual Studio 2010\Projects\XapNote\XapNote\Service References\myTerraService\Reference.svcmap 1 1 XapNote

Warning 2 Custom tool warning: Cannot import wsdl:binding

Detail: There was an error importing a wsdl:portType that the wsdl:binding is dependent on.

XPath to wsdl:portType: //wsdl:definitions[@targetNamespace='http://msrmaps.com/']/wsdl:portType[@name='TerraServiceSoap']

XPath to Error Source: //wsdl:definitions[@targetNamespace='http://msrmaps.com/']/wsdl:binding[@name='TerraServiceSoap'] E:\ASP.NET\Visual Studio 2010\Projects\XapNote\XapNote\Service References\myTerraService\Reference.svcmap 1 1 XapNote

Warning 3 Custom tool warning: Cannot import wsdl:port

Detail: There was an error importing a wsdl:binding that the wsdl:port is dependent on.

XPath to wsdl:binding: //wsdl:definitions[@targetNamespace='http://msrmaps.com/']/wsdl:binding[@name='TerraServiceSoap']

XPath to Error Source: //wsdl:definitions[@targetNamespace='http://msrmaps.com/']/wsdl:service[@name='TerraService']/wsdl:port[@name='TerraServiceSoap'] E:\ASP.NET\Visual Studio 2010\Projects\XapNote\XapNote\Service References\myTerraService\Reference.svcmap 1 1 XapNote

Warning 4 Custom tool warning: No endpoints compatible with Silverlight 3 were found. The generated client class will not be usable unless endpoint information is provided via the constructor. E:\ASP.NET\Visual Studio 2010\Projects\XapNote\XapNote\Service References\myTerraService\Reference.svcmap 1 1 XapNote

Warning 5 Custom tool warning: Exception has been thrown by the target of an invocation. E:\ASP.NET\Visual Studio 2010\Projects\XapNote\XapNote\Service References\myTerraService\Reference.svcmap 1 1 XapNote

Error 6 Custom tool error: Failed to generate code for the service reference 'myTerraService'.  Please check other error and warning messages for details. E:\ASP.NET\Visual Studio 2010\Projects\XapNote\XapNote\Service References\myTerraService\Reference.svcmap 1 1 XapNote

在cs檔案中打不出來我引用服務的服務名(myTerraService),正常情況下,我打一個m就會自動提示出來,嘗試了很多辦法,也問了好多人,都沒有解決,我都快絕望了。

我試試在控制台下的項目就可以成功。實在不了解啊…………。

幾天之後,突然的一個項目中的Service Reference能用了,好激動啊…………,我比較和其它項目中的一些檔案,發現了項目中\Service References\myTerraService(定義的服務名)檔案夾下的Reference.svcmap檔案中ID不一樣,于是我把能用的檔案中的ID換到不能用的檔案中,喔…………,能用了,呵呵,高興啊,但是我感覺這還不是有效的解決辦法,分享一下,希望有更好辦法的朋友也分享一下!!!!!!!

此後,跟着林永堅的視訊學習過程中做這人題目時,出現經度和緯度資訊,就是我自己設定的這個值,而林永堅的視訊中根本顯示不出來這個經度和緯度資訊,說明這個問題沒有從根本上解決啊……………………