我已经构建了一个Windows Phone 8应用程序,可以毫无问题地编译和运行。但是,当我运行内置的VS Store测试工具包时,它会在XAP包需求下带来很多错误,格式如下:
[错误]:后台代理无法使用不支持的API。 程序集Microsoft.Phone.Controls.Toolkit.dll试图使用 Microsoft.Phone.Shell.ApplicationBarIconButton。
我的项目dll([projectname] .dll)和Toolkit dll出现错误。它似乎带回了所有东西,甚至是我没有使用的引用(例如add_OrientationChanged)。
现在我已经浏览了Microsoft列出的Unsupported APIs,我没有使用它们中的任何一个。在页面的底部是一个“值得注意的API”列表,我使用的是HTTPWebRequest连接到Web服务。我假设这是问题所在,因为我在整个应用程序中使用它。
以下是我正在使用HTTPWebRequest做的一个例子:
Public Sub LoadRequest()
Dim request As HttpWebRequest = CType(WebRequest.Create(_ServiceURL), HttpWebRequest)
request.ContentType = "text/xml;charset=utf-8"
request.Method = "POST"
request.Headers("SOAPAction") = "<web service address>"
Start the asynchronous operation.
Dim result As IAsyncResult = _
CType(request.BeginGetRequestStream(AddressOf GetRequestsStreamCallback, request), _
IAsyncResult)
End Sub
Public Sub GetRequestsStreamCallback(ByVal asyncResult As IAsyncResult)
Dim request As HttpWebRequest = CType(asyncResult.AsyncState, HttpWebRequest)
Dim soapBody As System.Xml.Linq.XDocument = System.Xml.Linq.XDocument.Parse( _
"<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' " & _
"xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'><soap:Header><[SOAP Header Here]></soap:Header>" & _
"<soap:Body><[SOAP Body Here]></soap:Body></soap:Envelope>")
'End the operation
Dim postStream As Stream = request.EndGetRequestStream(asyncResult)
'Convert the string into byte array.
Dim byteArray As Byte() = Encoding.UTF8.GetBytes(soapBody.ToString())
'Write to the stream.
postStream.Write(byteArray, 0, soapBody.ToString().Length)
postStream.Close()
Dispatcher.BeginInvoke(Sub()
Dim result As IAsyncResult = _
CType(request.BeginGetResponse(AddressOf GetRequestsResponseCallback, request), IAsyncResult)
End Sub)
End Sub
Public Sub GetRequestsResponseCallback(ByVal Result As IAsyncResult)
'Get the response
Dim request As HttpWebRequest = CType(Result.AsyncState, HttpWebRequest)
Dim response As HttpWebResponse = CType(request.EndGetResponse(Result), HttpWebResponse)
Dim streamResponse As Stream = response.GetResponseStream()
Dim streamRead As New StreamReader(streamResponse)
Dim responseString As String = streamRead.ReadToEnd()
streamResponse.Close()
streamRead.Close()
'Take action on the response
Dim Xml As XDocument = XDocument.Parse(responseString)
Dim ns As XNamespace = "<Service Address>"
etc...
End Sub
然后我继续拆分应用程序所需数据的XML响应。关于测试工具包在这里不满意的任何想法?我假设因为它在这个阶段没有通过验证,它很可能会被拒绝。
提前感谢任何想法。
答案 0 :(得分:1)
问题是我不知道的现有后台代理(我接管了另一个开发人员的项目)。 WMAppManifest.xml文件中有一个引用,这显然是使用Wallet的早期测试的一部分,不再需要它。删除此引用可解决此问题。
<ExtendedTask Name="BackgroundTask">
<BackgroundServiceAgent Specifier="WalletAgent" Name="WalletAgent" Source="<ProjectName>" Type="<ProjectName>.WPWalletAgent" />
</ExtendedTask>