<!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">
You have to initialize the parameter collection manually:<br>
fs.Parameter = new MaestroAPI.NameValuePairTypeCollection();<br>
(I forgot to mention that).<br>
<br>
I just tried to download MaestroAPI.chm, and the link works for me:<br>
<a class="moz-txt-link-freetext" href="http://trac.osgeo.org/mapguide/browser/trunk/Tools/Maestro/MaestroAPI/Documentation/Msdn-Chm/MaestroAPI.chm?format=raw">http://trac.osgeo.org/mapguide/browser/trunk/Tools/Maestro/MaestroAPI/Documentation/Msdn-Chm/MaestroAPI.chm?format=raw</a><br>
<pre class="moz-signature" cols="72">Regards, Kenneth Skovhede, GEOGRAF A/S
</pre>
<br>
<br>
cagray skrev:
<blockquote cite="mid:20774513.post@talk.nabble.com" type="cite">
<pre wrap="">I tried your example and I always get an error of:
Object reference not set to an instance of an object.
when I do:
fs.Parameter["DefaultFilePath"] = "C:\my.shp";
or other similar attempts for other providers. If I take this line out it
creates the resource no problem. Do you know why this would happen?
Also I tried to download the help (MaestroAPI.chm) off the website but none
of the help links work. Have I done something daft?
Any help is appreciated.
Colin
Kenneth Skovhede, GEOGRAF A/S wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Yes, you can do just that.
Look in the Maestro source code to see how it's done.
The files "ResourceEditors/ResourceEditorBase.cs" and
"ResourceEditors/ResourceEditorGeneric.cs" shows it.
Some more customized versions are avalible in eg
"FeatureSourceEditorSDF.cs"
Basically you can do:
MaestroAPI.ServerConnectionI con; //You must initialize this, see
the developer docs
MaestroAPI.FeatureSource fs = new MaestroAPI.FeatureSource();
fs.Provider = "OSGeo.SHP.3.1";
fs.Parameter["DefaultFilePath"] = "C:\my.shp";
con.SaveResourceAs(fs, new MaestroAPI.ResourceIdentifier("my fs",
OSGeo.MapGuide.MaestroAPI.ResourceTypes.FeatureSource));
As for your actual problem, does the server error log show anything?
C:\program files\Mapguideopensource2.0\server\logs\error.log
Regards, Kenneth Skovhede, GEOGRAF A/S
cagray skrev:
</pre>
<blockquote type="cite">
<pre wrap="">Thanks for the reply. Unfortunately that did not solve my problem and I
got
the same error. Is there anything else I could try?
I was not aware you could do this without generating/manipulating the
xml.
My web tool has to fully control setting up data sources. So the user
selects a provider and then fills in the connection details. I then need
to
create a new data source from this to be stored in mapguide. Can you do
this
using the Meastro API alone?
Kenneth Skovhede, GEOGRAF A/S wrote:
</pre>
<blockquote type="cite">
<pre wrap="">I believe the problem is the .Net UTF-8 Encoder prefixes an UTF-8 BOM,
which causes problems in the Xml parser:
<a class="moz-txt-link-freetext" href="http://trac.osgeo.org/mapguide/ticket/233">http://trac.osgeo.org/mapguide/ticket/233</a>
You can try to create the UTF-8 encoder with:
UTF8Encoding utf8 = new UTF8Encoding(false);
And see if the problem goes away.
Alternatively you can use the MaestroAPI instead of messing with the raw
Xml:
<a class="moz-txt-link-freetext" href="http://trac.osgeo.org/mapguide/wiki/maestro/MaestroAPI">http://trac.osgeo.org/mapguide/wiki/maestro/MaestroAPI</a>
Regards, Kenneth Skovhede, GEOGRAF A/S
</pre>
</blockquote>
</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>