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?