Problem about IFeatureReader & IFeatureReaderImp in Managed FDO

Xuewei Ren xren at
Wed Sep 6 03:58:12 EDT 2006

In function XmlSerialize, 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.


The workaround might be to pass an instance of IFeatureReaderImpl for
the reader argument.








From: song yafeng-Heman [mailto:yfsong at] 
Sent: Tuesday, September 05, 2006 9:38 PM
To: dev at
Cc: Xuewei Ren; xue kai-Constantine
Subject: Problem about IFeatureReader & IFeatureReaderImp in Managed FDO


Hi everyone.


I met a problem about IFeatureReader when I was writing C# code.

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.

Then I use XmlFeatureSerializer.XmlSerialize(featureReader,
featureWriter, flags), but always meet errors.

I debug in the mgFdo, find error occurs here (in the red).



ANDS_FEATURE::IFeatureReader* reader,
NAMESPACE_FDO_XML::XmlFeatureWriter* writer,
NAMESPACE_FDO_XML::XmlFeatureFlags* flags)


//The original code.

writer->GetImpObj(), flags->GetImpObj()))               


//The full code same as the original code

         NAMESPACE_FDO_COMMANDS_FEATURE::IFeatureReaderImp* readerImp =

         GisPtr<FdoIFeatureReader> uReader = readerImp->GetImpObj();

         GisPtr<FdoXmlFeatureWriter> uWriter = writer->GetImpObj();

         GisPtr<FdoXmlFeatureFlags> uFlags = flags->GetImpObj();



uWriter, uFlags); 


         catch(GisException* e) 


                   NAMESPACE_COMMON::Exception* mgE =


                   throw mgE; 





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.  


Is this a bug or I make some mistakes in my code?


A bit of help would be greatly appreciated.





-------------- next part --------------
An HTML attachment was scrubbed...

More information about the Fdo-internals mailing list