Re: DMProcessConfigXML CM_MAPPINGS



My guess is the issue is with the mapping index you are using (1005). Suggest you add a mapping manually, then call the provisioning API to query the current mappings and see how it is setup e.g.

<wap-provisioningdoc>
<characteristic-query type="CM_Mappings"/>
</wap-provisioningdoc>

Also while the first code example is 99% correct, you should free the returned string pointer with free not LocalFree e.g.
[DllImport("coredll.dll", SetLastError = true)]
private static extern void free(IntPtr ptr);

Peter

--
Peter Foot
Device Application Development MVP
www.peterfoot.net | www.inthehand.com


"Peter Morris" <support@xxxxxxxxxxxxxxxxxxxx> wrote in message news:uar82ZnWHHA.468@xxxxxxxxxxxxxxxxxxxxxxx
Hi all

I am using the following code to try to add a URL exception to the networks list on my PocketPC 2003.

================
public enum ConfigFlag : uint
{
/// <summary>
/// The configuration management service and the
/// Configuration Service Providers (CSPs) process
/// the input data.
/// </summary>
Process = 1,

/// <summary>
/// The configuration management service gathers
/// and returns metadata for any XML parm elements
/// it encounters.
/// </summary>
Metadata = 2
}

public class ConfigWrapper
{
[DllImport("aygshell.dll")]
private extern static UInt32 DMProcessConfigXML(string xmlIn, UInt32 flag, out IntPtr xmlOutPtr);

[DllImport("coredll.dll")]
private extern static IntPtr LocalFree(IntPtr hMem);

public static string ProcessXml(string xml)
{
return ProcessXml(xml, ConfigFlag.Process);
}

/// <summary>
/// This function wraps acts as a managed interface to the
/// DMProcessConfigXML in Pocket PC 2003+ and Smartphone 2002+
/// The DMProcessConfigXML function grants remote access to the
/// configuration management functionality of the mobile device.
/// This function enables the submission of Extensible Markup
/// Language (XML) information that causes the settings of a
/// mobile device to change. See "Configuration Service Providers"
/// in the API for details on the XML schema.
/// </summary>
/// <param name="xml">
/// String of valid XML containing configuration data
/// </param>
/// <param name="flag">
/// Action flag (see ConfigFlag for details)
/// </param>
/// <returns>
/// String of valid XML containing the result of this operation
/// </returns>
public static string ProcessXml(string xml, ConfigFlag flag)
{
IntPtr xmlOutPtr;
string xmlOutStr;
long result;

result = DMProcessConfigXML(xml, (uint)flag, out xmlOutPtr);

// marshal the output string
xmlOutStr = Marshal.PtrToStringUni(xmlOutPtr);

// free the memory allocated by the API
LocalFree(xmlOutPtr);

// throw an exception if an error code was returned
if (result != 0)
{
throw new ArgumentException(String.Format(
"DMProcessConfigXML returned error code {0}", result),
xml);
}

return xmlOutStr;
}
}
================================


I have also tried this



=================================
internal static class XmlConfig
{
[DllImport("aygshell.dll")]
private static extern int DMProcessConfigXML(string pszWXMLin, int dwFlags, IntPtr ppszwXmlOut);

[DllImport("coredll.dll")]
private static extern void free(int buffer);

unsafe static public void ProcessXml(string Xml)
{
fixed (int* OutPtr = new int[1])
{
IntPtr outptr = (IntPtr)OutPtr;
int result = DMProcessConfigXML(Xml, 1, outptr);
if (result != 0)
throw new Exception("Could not set network preferences");
else
free(*OutPtr);
}
}
==============================



The XML being sent is as follows:
<wap-provisioningdoc>

<characteristic type="CM_Mappings">

<characteristic type="1005">

<param name="pattern" value="http://myserver.com/MyWebServiceFolder/SyncService.asmx"; />

<param name="network" value="{A1182988-0D73-439e-87AD-2A5B369F808B}" />

</characteristic>

</characteristic>

</wap-provisioningdoc>







If I manually add an exception then my app does not invoke the GPRS dialler and connects to the server through the WORK connection, if I remove this manual exception and try to add it using either of the two above methods the dialler dialog still appears and the Internet connection is used. As far as I can see from all sources on the web I am doing this correctly, but it just isn't working. Can anyone help me with this? I saw Peter Foot asking how to do the same thing quite some time ago so I hope he at least has achieved his goal and might share the answer :-)





Thanks in advance!





Pete



.



Relevant Pages

  • Re: DMProcessConfigXML CM_MAPPINGS
    ... documentation says is used for the standard mappings - and user mappings start at 0x1000000. ... Also while the first code example is 99% correct, you should free the returned string pointer with free not LocalFree e.g. ... /// Configuration Service Providers process ... /// and returns metadata for any XML parm elements ...
    (microsoft.public.dotnet.framework.compactframework)
  • DMProcessConfigXML CM_MAPPINGS
    ... I am using the following code to try to add a URL exception to the networks ... /// Configuration Service Providers process ... /// and returns metadata for any XML parm elements ... /// String of valid XML containing configuration data ...
    (microsoft.public.dotnet.framework.compactframework)
  • XML Serialization problems related to framework versions
    ... I get an exception when trying to deserialize a simple configuration ... .NET 1.0 XML assembly. ... at System.Reflection.Assembly.nLoad(AssemblyName fileName, String ... Boolean stringized, Evidence assemblySecurity, StackCrawlMark& ...
    (microsoft.public.dotnet.framework)
  • Re: Surely someone has come across this problem before........
    ... running the configuration wizard again (probably will get you past this ... Event Type: Error ... see Help and Support Center at ... connectionString, SqlFile sqlFileId, String sqlSignaturePath, ...
    (microsoft.public.sharepoint.windowsservices)
  • Re: Surely someone has come across this problem before........
    ... Technologies Configuration Wizard ... I've unsuccessfully run the Sharepoint Products and Technologies ... see Help and Support Center at ... connectionString, SqlFile sqlFileId, String sqlSignaturePath, ...
    (microsoft.public.sharepoint.windowsservices)

Quantcast