<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:SimSun;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:"\@SimSun";
        panose-1:2 1 6 0 3 1 1 1 1 1;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        text-align:justify;
        text-justify:inter-ideograph;
        font-size:10.5pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal;
        font-family:Arial;
        color:windowtext;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:Arial;
        color:navy;}
@page Section1
        {size:595.3pt 841.9pt;
        margin:1.0in 1.25in 1.0in 1.25in;
        layout-grid:15.6pt;}
div.Section1
        {page:Section1;}
-->
</style>

</head>

<body lang=EN-US link=blue vlink=purple style='text-justify-trim:punctuation'>

<div class=Section1 style='layout-grid:15.6pt'>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>In function </span></font><font size=1
face=Arial><span style='font-size:9.0pt;font-family:Arial'>XmlSerialize</span></font><font
size=2 color=navy face=Arial><span style='font-size:10.0pt;font-family:Arial;
color:navy'>, can you pass reader argument that is the instance of IFeatureReaderImpl?
You mentioned that you implemented IFeatureReader called MyFeatureReader. You
must have passed the instance of your own class as the reader argument in this
function. I believe that causes the problem. From the code, we can find out
that this function assumes that IFeatureReaderImpl is the only implementation
for IFeatureReader. Because of this assumption, the original code did the
static_cast from IFeatureReader to IFeatureReaderImpl. This is actually not correct.
Hope this can be corrected soon.<o:p></o:p></span></font></p>

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

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>The workaround might be to pass an
instance of IFeatureReaderImpl for the reader argument.<o:p></o:p></span></font></p>

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

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

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

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

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

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

<div>

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

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

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

<p class=MsoNormal align=left style='text-align:left'><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'> song
yafeng-Heman [mailto:yfsong@hslcn.com] <br>
<b><span style='font-weight:bold'>Sent:</span></b> Tuesday, September 05, 2006
9:38 PM<br>
<b><span style='font-weight:bold'>To:</span></b> dev@fdo.osgeo.org<br>
<b><span style='font-weight:bold'>Cc:</span></b> Xuewei Ren; xue
kai-Constantine<br>
<b><span style='font-weight:bold'>Subject:</span></b> Problem about
IFeatureReader &amp; IFeatureReaderImp in Managed FDO</span></font><font
size=3><span style='font-size:12.0pt'><o:p></o:p></span></font></p>

</div>

<p class=MsoNormal align=left style='text-align:left'><font size=2
face="Times New Roman"><span style='font-size:10.5pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=1 face=Arial><span style='font-size:9.0pt;
font-family:Arial'>Hi everyone.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face=Arial><span style='font-size:9.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=1 face=Arial><span style='font-size:9.0pt;
font-family:Arial'>I met a problem about IFeatureReader when I was writing C#
code.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face=Arial><span style='font-size:9.0pt;
font-family:Arial'>I rewrite the class MyFeatureReader derived from
IFeatureReader in C# which is the same as the class in GmlWriteTest.cpp in unit
test of FDO with the same name.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face=Arial><span style='font-size:9.0pt;
font-family:Arial'>Then I use XmlFeatureSerializer.XmlSerialize(featureReader,
featureWriter, flags), but always meet errors.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face=Arial><span style='font-size:9.0pt;
font-family:Arial'>I debug in the mgFdo, find error occurs here (in the red).<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face=Arial><span style='font-size:9.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=1 face=Arial><span style='font-size:9.0pt;
font-family:Arial'>[code]<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face=Arial><span style='font-size:9.0pt;
font-family:Arial'>System::Void NAMESPACE_FDO_XML::XmlFeatureSerializer::XmlSerialize(NAMESPACE_FDO_COMMANDS_FEATURE::IFeatureReader*
reader, NAMESPACE_FDO_XML::XmlFeatureWriter* writer,
NAMESPACE_FDO_XML::XmlFeatureFlags* flags)<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face=Arial><span style='font-size:9.0pt;
font-family:Arial'>{<o:p></o:p></span></font></p>

<p class=MsoNormal style='text-indent:21.0pt'><font size=1 face=Arial><span
style='font-size:9.0pt;font-family:Arial'>//The original code.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face=Arial><span style='font-size:9.0pt;
font-family:Arial'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
//EXCEPTION_HANDLER(FdoXmlFeatureSerializer::XmlSerialize(static_cast&lt;NAMESPACE_FDO_COMMANDS_FEATURE::IFeatureReaderImp*&gt;(reader)-&gt;GetImpObj(),
writer-&gt;GetImpObj(), flags-&gt;GetImpObj()))&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face=Arial><span style='font-size:9.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal style='text-indent:21.0pt'><font size=1 face=Arial><span
style='font-size:9.0pt;font-family:Arial'>//The full code same as the original
code<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 color=red face=Arial><span style='font-size:
9.0pt;font-family:Arial;color:red'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
NAMESPACE_FDO_COMMANDS_FEATURE::IFeatureReaderImp* readerImp = static_cast&lt;NAMESPACE_FDO_COMMANDS_FEATURE::IFeatureReaderImp*&gt;(reader);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 color=red face=Arial><span style='font-size:
9.0pt;font-family:Arial;color:red'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
GisPtr&lt;FdoIFeatureReader&gt; uReader = readerImp-&gt;GetImpObj();<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face=Arial><span style='font-size:9.0pt;
font-family:Arial'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
GisPtr&lt;FdoXmlFeatureWriter&gt; uWriter = writer-&gt;GetImpObj();<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face=Arial><span style='font-size:9.0pt;
font-family:Arial'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
GisPtr&lt;FdoXmlFeatureFlags&gt; uFlags = flags-&gt;GetImpObj();<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face=Arial><span style='font-size:9.0pt;
font-family:Arial'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try <o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face=Arial><span style='font-size:9.0pt;
font-family:Arial'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face=Arial><span style='font-size:9.0pt;
font-family:Arial'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
FdoXmlFeatureSerializer::XmlSerialize(uReader, uWriter, uFlags); <o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face=Arial><span style='font-size:9.0pt;
font-family:Arial'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face=Arial><span style='font-size:9.0pt;
font-family:Arial'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
catch(GisException* e) <o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face=Arial><span style='font-size:9.0pt;
font-family:Arial'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face=Arial><span style='font-size:9.0pt;
font-family:Arial'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
NAMESPACE_COMMON::Exception* mgE = NAMESPACE_COMMON::Exception::Create(e); <o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face=Arial><span style='font-size:9.0pt;
font-family:Arial'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
e-&gt;Release(); <o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face=Arial><span style='font-size:9.0pt;
font-family:Arial'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
throw mgE; <o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face=Arial><span style='font-size:9.0pt;
font-family:Arial'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face=Arial><span style='font-size:9.0pt;
font-family:Arial'>}<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face=Arial><span style='font-size:9.0pt;
font-family:Arial'>[/code]<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face=Arial><span style='font-size:9.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=1 face=Arial><span style='font-size:9.0pt;
font-family:Arial'>Because the reader is derived from IFearureReader, cast it
to a IFeatureReaderImp is not a right operation. Then use GetImpObj() will get
wrong pointer. This wrong point cause the error later. &nbsp;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face=Arial><span style='font-size:9.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=1 face=Arial><span style='font-size:9.0pt;
font-family:Arial'>Is this a bug or I make some mistakes in my code?<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face=Arial><span style='font-size:9.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=1 face=Arial><span style='font-size:9.0pt;
font-family:Arial'>A bit of help would be greatly appreciated.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face=Arial><span style='font-size:9.0pt;
font-family:Arial'>Thanks<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=1 face=Arial><span style='font-size:9.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=1 face=Arial><span style='font-size:9.0pt;
font-family:Arial'>Kino<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face="Times New Roman"><span style='font-size:
10.0pt'><o:p>&nbsp;</o:p></span></font></p>

</div>

</body>

</html>