Problem about IFeatureReader & IFeatureReaderImp in Managed FDO

song yafeng-Heman yfsong at hslcn.com
Tue Sep 5 21:37:48 EDT 2006


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).

 

[code]

System::Void
NAMESPACE_FDO_XML::XmlFeatureSerializer::XmlSerialize(NAMESPACE_FDO_COMM
ANDS_FEATURE::IFeatureReader* reader,
NAMESPACE_FDO_XML::XmlFeatureWriter* writer,
NAMESPACE_FDO_XML::XmlFeatureFlags* flags)

{

//The original code.

 
//EXCEPTION_HANDLER(FdoXmlFeatureSerializer::XmlSerialize(static_cast<NA
MESPACE_FDO_COMMANDS_FEATURE::IFeatureReaderImp*>(reader)->GetImpObj(),
writer->GetImpObj(), flags->GetImpObj()))               

 

//The full code same as the original code

         NAMESPACE_FDO_COMMANDS_FEATURE::IFeatureReaderImp* readerImp =
static_cast<NAMESPACE_FDO_COMMANDS_FEATURE::IFeatureReaderImp*>(reader);

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

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

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

         try 

         { 

                   FdoXmlFeatureSerializer::XmlSerialize(uReader,
uWriter, uFlags); 

         } 

         catch(GisException* e) 

         { 

                   NAMESPACE_COMMON::Exception* mgE =
NAMESPACE_COMMON::Exception::Create(e); 

                   e->Release(); 

                   throw mgE; 

         }

}

[/code]

 

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.

Thanks

 

Kino

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/fdo_dev/attachments/20060906/6b2e404e/attachment.html


More information about the Fdo_dev mailing list