<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 10 (filtered)">
<title>ByteReader Problem</title>

<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Webdings;
        panose-1:5 3 1 2 1 5 9 6 7 3;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;}
p
        {margin-right:0in;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman";}
span.emailstyle18
        {font-family:Arial;
        color:navy;}
span.EmailStyle19
        {font-family:Arial;
        color:navy;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
        {page:Section1;}
-->
</style>

</head>

<body lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>This is what I use in real life &#8230; I did
not understand. &nbsp;I was illustrating the 8K thingee. It caught me to. &nbsp;</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;&nbsp;&nbsp;&nbsp; string lib_layer_definition
= resourceService.GetResourceContent(resId).ToString();</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;&nbsp;&nbsp;&nbsp; byte[] layerDefinition
= new byte[lib_layer_definition.Length];</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;&nbsp;&nbsp;&nbsp; int byteCount =
Encoding.UTF8.GetBytes(lib_layer_definition, 0, lib_layer_definition.Length, layerDefinition,
0);</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=2 face=Tahoma><span
style='font-size:10.0pt;font-family:Tahoma'>-----Original Message-----<br>
<b><span style='font-weight:bold'>From:</span></b>
mapguide-users-bounces@lists.osgeo.org
[mailto:mapguide-users-bounces@lists.osgeo.org] <b><span style='font-weight:
bold'>On Behalf Of </span></b>Campbell, Keith A<br>
<b><span style='font-weight:bold'>Sent:</span></b> </span></font><font size=2 face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'>Friday, August
 31, 2007</span></font><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma'> </span></font><font size=2 face=Tahoma><span
 style='font-size:10.0pt;font-family:Tahoma'>11:32 AM</span></font><font
size=2 face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'><br>
<b><span style='font-weight:bold'>To:</span></b> MapGuide Users Mail List<br>
<b><span style='font-weight:bold'>Subject:</span></b> RE: [mapguide-users]
ByteReader Problem</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'>&nbsp;</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=2 color=blue face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:blue'>Thanks Dennis.</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'>&nbsp;</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=2 color=blue face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:blue'>I've tried this, but I'm
only getting 8192 bytes read into the byte buffer. This seems to be the problem
mentioned by Kenneth. The Read method doesn't seem to allow the start location
for the read to be set, so looping until the entire content of the Resource is
read into the buffer doesn't seem to be an option.</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'>&nbsp;</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=2 color=blue face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:blue'>Presumably somebody must
have found a way around this.</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'>&nbsp;</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=2 color=blue face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:blue'>Keith</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'>&nbsp;</span></font></p>

<div class=MsoNormal align=center style='margin-left:.5in;text-align:center'><font
size=3 face="Times New Roman"><span style='font-size:12.0pt'>

<hr size=2 width="100%" align=center>

</span></font></div>

<p class=MsoNormal style='margin-right:0in;margin-bottom:12.0pt;margin-left:
.5in'><b><font size=2 face=Tahoma><span style='font-size:10.0pt;font-family:
Tahoma;font-weight:bold'>From:</span></font></b><font size=2 face=Tahoma><span
style='font-size:10.0pt;font-family:Tahoma'>
mapguide-users-bounces@lists.osgeo.org
[mailto:mapguide-users-bounces@lists.osgeo.org] <b><span style='font-weight:
bold'>On Behalf Of </span></b>Jonio, Dennis (Aviation)<br>
<b><span style='font-weight:bold'>Sent:</span></b> </span></font><font size=2 face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'>31 August 2007</span></font><font
size=2 face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'> </span></font><font size=2 face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'>14:05</span></font><font
size=2 face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'><br>
<b><span style='font-weight:bold'>To:</span></b> MapGuide Users Mail List<br>
<b><span style='font-weight:bold'>Subject:</span></b> RE: [mapguide-users]
ByteReader Problem</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'><!-- Converted from text/rtf format -->&#8230;
this sequence tends to work &nbsp;&nbsp;&nbsp;&nbsp;</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'>&nbsp;</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'>&nbsp;&nbsp;&nbsp;&nbsp; //
For some reason the MgByteReader &quot;disappears&quot;</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'>&nbsp;&nbsp;&nbsp;&nbsp;
// This seems to work ....</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
long long_length = rs.GetResourceContent(resId).GetLength();</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
byte[] byteBuffer = new byte[long_length];</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
int numBytes = rs.GetResourceContent(resId).Read(byteBuffer, (int)long_length);</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'>&nbsp;</span></font></p>

<p class=MsoNormal style='margin-left:.5in' defanghtml_style="margin-left:.5in"><font
size=2 face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'>-----Original
Message-----<br>
<b><span style='font-weight:bold'>From:</span></b>
mapguide-users-bounces@lists.osgeo.org
[mailto:mapguide-users-bounces@lists.osgeo.org] <b><span style='font-weight:
bold'>On Behalf Of </span></b>Campbell, Keith A<br>
<b><span style='font-weight:bold'>Sent:</span></b> </span></font><font size=2 face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'>Friday, August
 31, 2007</span></font><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma'> </span></font><font size=2 face=Tahoma><span
 style='font-size:10.0pt;font-family:Tahoma'>7:10 AM</span></font><font size=2
face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'><br>
<b><span style='font-weight:bold'>To:</span></b> MapGuide Users Mail List<br>
<b><span style='font-weight:bold'>Subject:</span></b> [mapguide-users]
ByteReader Problem</span></font></p>

<p class=MsoNormal style='margin-left:.5in' defanghtml_style="margin-left:.5in"><font
size=3 face="Times New Roman"><span style='font-size:12.0pt'>&nbsp;</span></font></p>

<p style='margin-left:.5in' defanghtml_style="margin-left:.5in"><font size=2
face=Arial><span style='font-size:10.0pt;font-family:Arial'>I am trying to
alter a map definition through the API and cannot get the contents of the
MgByteReader in string format. Here's the code:-</span></font></p>

<p style='margin-left:.5in' defanghtml_style="margin-left:.5in"><font size=2
face="Courier New"><span defanghtml_style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><span
style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<font color="#2b91af"><span style='color:#2B91AF'>String</span></font>
mapDefinition = <font color="#a31515"><span style='color:#A31515'>&quot;Library://My
Folder/Maps/My Map.MapDefinition&quot;</span></font>;</span></span></font> <br>
<font size=2 face="Courier New"><span defanghtml_style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><span
style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<font color="#2b91af"><span style='color:#2B91AF'>MgResourceIdentifier</span></font>
MapResID = <font color=blue><span style='color:blue'>new</span></font> <font
color="#2b91af"><span style='color:#2B91AF'>MgResourceIdentifier</span></font>(mapDefinition);</span></span></font>
</p>

<p style='margin-left:.5in' defanghtml_style="margin-left:.5in"><font size=2
face="Courier New"><span defanghtml_style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><span
style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<font color="#2b91af"><span style='color:#2B91AF'>MgByteReader</span></font>
mapByteRdr = res.GetResourceContent(MapResID);//res is instantiated Resource
Service.</span></span></font> </p>

<p style='margin-left:.5in' defanghtml_style="margin-left:.5in"><font size=2
face="Courier New"><span defanghtml_style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><span
style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<font color="#2b91af"><span style='color:#2B91AF'>XmlDocument</span></font> doc
= <font color=blue><span style='color:blue'>new</span></font> <font
color="#2b91af"><span style='color:#2B91AF'>XmlDocument</span></font>();</span></span></font>
<br>
<font size=2 face="Courier New"><span defanghtml_style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><span
style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></font><br>
<font size=2 face="Courier New"><span defanghtml_style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><span
style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
doc.LoadXml(mapByteRdr.ToString());</span></span></font> </p>

<p style='margin-left:.5in' defanghtml_style="margin-left:.5in"><font size=2
face=Arial><span style='font-size:10.0pt;font-family:Arial'>LoadXML fails with
an error ' Root element is missing'. I can copy the contents of</span></font> <font
size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'>mapByteRdr
from Visual Studio at runtime and it contains properly formatted XML for the
map definition. If I use the ToFile() method, the resultant file is empty. I
cannot see why these two methods do not return the xml string in the reader.
Any help is welcome.</span></font></p>

<p style='margin-left:.5in' defanghtml_style="margin-left:.5in"><font size=2
face=Arial><span style='font-size:10.0pt;font-family:Arial'>Cheers,</span></font>
</p>

<p style='margin-left:.5in' defanghtml_style="margin-left:.5in"><font size=2
face=Arial><span style='font-size:10.0pt;font-family:Arial'>Keith</span></font>
</p>

<p class=MsoNormal style='margin-left:.5in'
defanghtml_style="margin-right:0in;margin-bottom:12.0pt;margin-left:&#13;&#10;.5in"><font
size=3 face="Times New Roman"><span style='font-size:12.0pt'>&nbsp;</span></font></p>

<p class=MsoNormal align=center style='margin-left:.5in;text-align:center'
defanghtml_style="margin-left:.5in;text-align:center"><b><font size=2
face=Arial><span style='font-size:10.0pt;font-family:Arial;font-weight:bold'>This
email and any attached files are confidential and copyright protected. If you
are not the addressee, any dissemination of this communication is strictly
prohibited. Unless otherwise expressly agreed in writing, nothing stated in
this communication shall be legally binding.</span></font></b> </p>

<p align=center style='margin-left:.5in;text-align:center'
defanghtml_style="margin-left:.5in;text-align:center"><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial'>The ultimate parent company of the
Atkins Group is WS Atkins plc. Registered in </span></font><font size=2
  face=Arial><span style='font-size:10.0pt;font-family:Arial'>England</span></font><font
size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'> No.
1885586. Registered Office Woodcote Grove, </span></font><font size=2
  face=Arial><span style='font-size:10.0pt;font-family:Arial'>Ashley Road</span></font><font
size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'>, Epsom, </span></font><font
 size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'>Surrey</span></font><font
size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'> KT18 5BW.</span></font>
</p>

<p align=center style='margin-left:.5in;text-align:center'
defanghtml_style="margin-left:.5in;text-align:center"><font size=5 color=green
face=Webdings><span style='font-size:18.0pt;font-family:Webdings;color:green'>P</span></font>
<b><font size=2 color=green face=Arial><span style='font-size:10.0pt;
font-family:Arial;color:green;font-weight:bold'>Consider the environment.
Please don't print this e-mail unless you really need to.</span></font></b> </p>

<div>

<div class=MsoNormal align=center style='margin-left:.5in;text-align:center'><font
size=3 face="Times New Roman"><span style='font-size:12.0pt'>

<hr size=2 width="100%" align=center>

</span></font></div>

<p class=MsoNormal style='margin-left:.5in' defanghtml_style="margin-left:.5in"><font
size=3 face="Times New Roman"><span style='font-size:12.0pt'>E-mails are
automatically scanned for viruses using McAfee. </span></font></p>

</div>

<p class=MsoNormal style='margin-right:0in;margin-bottom:12.0pt;margin-left:
.5in'><font size=3 face="Times New Roman"><span style='font-size:12.0pt;
background:white'>&nbsp;</span></font></p>

<p align=center style='margin-left:.5in;text-align:center'><font size=3
face="Times New Roman"><span style='font-size:12.0pt;background:white'>This
message has been scanned for viruses by <a
href="http://bluepages.wsatkins.co.uk/?6875772"><font color=black><span
style='color:black'>MailControl</span></font></a></span></font></p>

<p class=MsoNormal style='margin-right:0in;margin-bottom:12.0pt;margin-left:
.5in'><font size=3 face="Times New Roman"><span style='font-size:12.0pt'>&nbsp;</span></font></p>

<p class=MsoNormal align=center style='margin-left:.5in;text-align:center'><b><font
size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial;font-weight:
bold'>This email and any attached files are confidential and copyright
protected. If you are not the addressee, any dissemination of this
communication is strictly prohibited. Unless otherwise expressly agreed in
writing, nothing stated in this communication shall be legally binding.</span></font></b>
</p>

<p align=center style='margin-left:.5in;text-align:center'><font size=2
face=Arial><span style='font-size:10.0pt;font-family:Arial'>The ultimate parent
company of the Atkins Group is WS Atkins plc. Registered in </span></font><font
  size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'>England</span></font><font
size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'> No.
1885586. Registered Office Woodcote Grove, </span></font><font size=2
  face=Arial><span style='font-size:10.0pt;font-family:Arial'>Ashley Road</span></font><font
size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'>, Epsom, </span></font><font
 size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'>Surrey</span></font><font
size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'> KT18 5BW.</span></font>
</p>

<p align=center style='margin-left:.5in;text-align:center'><font size=5
color=green face=Webdings><span style='font-size:18.0pt;font-family:Webdings;
color:green'>P</span></font> <b><font size=2 color=green face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:green;font-weight:bold'>Consider
the environment. Please don't print this e-mail unless you really need to.</span></font></b>
</p>

<div>

<div class=MsoNormal align=center style='margin-left:.5in;text-align:center'><font
size=3 face="Times New Roman"><span style='font-size:12.0pt'>

<hr size=2 width="100%" align=center>

</span></font></div>

<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'>E-mails are automatically scanned for viruses using
McAfee. </span></font></p>

</div>

</div>

</body>

</html>