<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Try to look at the Maestro code:<br>
<a class="moz-txt-link-freetext" href="http://trac.osgeo.org/mapguide/browser/trunk/Tools/Maestro/MaestroAPI/LocalNativeConnection.cs#L182">http://trac.osgeo.org/mapguide/browser/trunk/Tools/Maestro/MaestroAPI/LocalNativeConnection.cs#L182</a><br>
<br>
Hopefully you will find a small difference there.<br>
<pre class="moz-signature" cols="72">Regards, Kenneth Skovhede, GEOGRAF A/S
</pre>
<br>
<br>
sekko970 skrev:
<blockquote cite="mid:1234519848383-2320483.post@n2.nabble.com"
type="cite">
<pre wrap="">Yes, the "OuterXml" property contains the XML header line.
Fabio
------------------------------------------------------------------------------------------------------
Kenneth Skovhede, GEOGRAF A/S wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Does the "OuterXml" property contain the <? version="1.0"
encoding="utf-8" standalone="true" ?> line?
Regards, Kenneth Skovhede, GEOGRAF A/S
sekko970 skrev:
</pre>
<blockquote type="cite">
<pre wrap="">Hi Kenneth, and thanks for your promptly reply.
I had used an ancoding instance.
Below, you can see my code to create the new map:
Dim resID As New
MgResourceIdentifier(Library://.../maps/MyMap.MapDefinition)
Dim enc As New System.Text.UTF8Encoding(False)
Dim newMapDef As New MgByteSource(enc.GetBytes(XMLMapTemplate.OuterXml),
enc.GetByteCount(XMLMapTemplate.OuterXml))
newMapDef.SetMimeType(MgMimeType.Xml)
Dim resourceSrvc As MgResourceService =
siteConn.CreateService(MgServiceType.ResourceService)
resourceSrvc.SetResource(resID, newMapDef.GetReader(), Nothing)
Dim map As New MgMap()
map.Create(resourceSrvc, resID, MapName)
...
Then, this is my code to create the map layout:
Dim resID As New
MgResourceIdentifier(Library://.../Layouts/MyMap.WebLayout)
Dim enc As New System.Text.UTF8Encoding(False)
Dim newLayoutDef As New
MgByteSource(enc.GetBytes(XMLLayoutTemplate.OuterXml),
enc.GetByteCount(XMLLayoutTemplate.OuterXml))
newLayoutDef.SetMimeType(MgMimeType.Xml)
resourceSrvc As MgResourceService =
siteConn.CreateService(MgServiceType.ResourceService)
resourceSrvc.SetResource(resID, newLayoutDef.GetReader(), Nothing)
map.Save(resourceSrvc)
Thanks for your help.
Fabio
------------------------------------------------------------------------------------------------------
Kenneth Skovhede, GEOGRAF A/S wrote:
</pre>
<blockquote type="cite">
<pre wrap="">You could have the problem that .Net emits an utf-8 byte-order-marker
(BOM), when
writing xml.
<a class="moz-txt-link-freetext" href="http://en.wikipedia.org/wiki/Byte-order_mark">http://en.wikipedia.org/wiki/Byte-order_mark</a>
To counter this, explicitly create an encoding instance:
System.Text.Encoding enc = new System.Text.UTF8Encoding(false);
Then implement a xml writer, or manually convert the xml to bytes, using
the encoding.
FYI, the MaestroAPI is LGPL, and so you may use it as a library, even
for commercial applications,
and it handles this quirk and others.
Regards, Kenneth Skovhede, GEOGRAF A/S
sekko970 skrev:
</pre>
<blockquote type="cite">
<pre wrap="">Dear all,
I have created programmatically a map (and its layout) using MG .Net
web
API.
After creation, the new map and layout are visible in MG Maestro, and
using
the 'Show in browser" button are correctly shown in browser.
The problem happens when I load the map directly from browser, and the
following error appears:
<< The type 'OSGeo.MapGuide.MgNullArgumentException' in assembly
'MapGuideDotNetApi, Version= 2.0.2.30 11, Culture=neutral,
PublicKeyToken=null' is not marked as serializable >>.
Then, simply saving the new layout from MG Maestro (without any
modification), and reloading the map directly from browser, the error
disappears and the map is correctly shown.
After saving the layout, there aren't differences in map and layout XML
definitions.
Have you any idea about?
Thank you in advance.
Fabio
</pre>
</blockquote>
<pre wrap="">_______________________________________________
mapguide-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:mapguide-users@lists.osgeo.org">mapguide-users@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/mapguide-users">http://lists.osgeo.org/mailman/listinfo/mapguide-users</a>
</pre>
</blockquote>
<pre wrap="">
</pre>
</blockquote>
<pre wrap="">_______________________________________________
mapguide-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:mapguide-users@lists.osgeo.org">mapguide-users@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/mapguide-users">http://lists.osgeo.org/mailman/listinfo/mapguide-users</a>
</pre>
</blockquote>
<pre wrap=""><!---->
</pre>
</blockquote>
</body>
</html>