1
我試圖連接到使用MBN Api的3G網絡。但是當我調用IMbnConnection
中的連接方法時,它會引發異常。MBN配置文件損壞的HRESULT 0x800704B6
The network connection profile is corrupted. (Exception from HRESULT: 0x800704B6)
我試圖找到拼寫錯誤和其他錯誤使用微軟的移動寬帶文檔(Link)在我的代碼生成的配置文件,但我不能找到一個。
我在博客上也發現這個HRESULT可能來自於一個錯誤的IMSI號碼(here),所以我手動連接Windows並將我的個人資料中的數字與連接屬性中的數字進行比較,發現他們是同樣,IMSI和ICC號碼。
這是我的XML當前如何生成的。
<MBNProfile xmlns="http://www.microsoft.com/networking/WWAN/profile/v1">
<Name>boomer3g</Name>
<ICONFilePath>Link/To/BMPFILe</ICONFilePath>
<Description>3G Network profile created by Boomerweb</Description>
<IsDefault>true</IsDefault>
<ProfileCreationType>UserProvisioned</ProfileCreationType>
<SubscriberID>IMSI Number (i counted 15 characters)</SubscriberID>
<SimIccID>ICC number (i counted 19 characters)</SimIccID>
<AutoConnectOnInternet>false</AutoConnectOnInternet>
<ConnectionMode>auto</ConnectionMode>
</MBNProfile>
這是生成XML配置文件的代碼。 // XML Namespaces
XNamespace xmlns = XNamespace.Get("http://www.microsoft.com/networking/WWAN/profile/v1");
XDocument xmlDocument = new XDocument(
new XElement(xmlns + "MBNProfile",
new XElement(xmlns + "Name", "boomer3g"),
new XElement(xmlns + "ICONFilePath", Path.GetFullPath("Resource/KPN-icon.bmp")),
new XElement(xmlns + "Description", "3G Network profile created by Boomerweb"),
new XElement(xmlns + "IsDefault", true),
new XElement(xmlns + "ProfileCreationType", "UserProvisioned"),
new XElement(xmlns + "SubscriberID", subscriberInfo.SubscriberID),
new XElement(xmlns + "SimIccID", subscriberInfo.SimIccID),
new XElement(xmlns + "AutoConnectOnInternet", false),
new XElement(xmlns + "ConnectionMode", "auto")
)
);
//Create xml document
string xml;
XmlWriterSettings XmlWriterSet = new XmlWriterSettings();
XmlWriterSet.OmitXmlDeclaration = true;
using (StringWriter StrWriter = new StringWriter())
using (XmlWriter XWriter = XmlWriter.Create(StrWriter, XmlWriterSet))
{
xmlDocument.WriteTo(XWriter);
XWriter.Flush();
xml = StrWriter.GetStringBuilder().ToString();
}
還有什麼可以給這個HRESULT?你們能舉一個MBN配置文件的例子嗎?或者在我的代碼中生成配置文件有什麼問題?