1

I'm trying to connect to an 3g network using MBN Api. But when i call the connect method in IMbnConnection it throws an exception.

The network connection profile is corrupted. (Exception from HRESULT: 0x800704B6)

I have tried to find typos and other errors in the profile i generate in my code using Microsoft's Mobile Broadband Documentation (Link), but i can't find one.

I also found on a blog that this HRESULT can be from a wrong IMSI number (here), so i connected manually with Windows and compared the numbers in my profile with the one in the properties of the connection and found that they are the same, both the IMSI and ICC numbers.

This is how my XML is currently generated.

<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>

And this is the code that generated the XML profile. //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();
}

What else can give this HRESULT? can you guys give an example of MBN profile? or is there something wrong in my code that generates the profile?

4

1 回答 1

2

伙计们,我已经解决了我的问题。事实证明,我在 xml 之上没有我的 XMl 声明。

我的xml现在是这样的:

<?xml version="1.0" encoding="utf-8" ?>
<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>

所以事实证明我的代码没有任何问题,我只是删除了一些我不应该拥有的东西。我知道我犯了一个愚蠢的错误。

于 2013-07-15T11:41:07.833 回答