Home     Products      Support      Corporate     Sign In 

Support Knowledge Base, Article 1201

Product
WordWriter
Version
3.5.1
Title
Backwards Compatibility issue with SetRepeatBlock when passing a DataReader as an Argument in version 3.5.1
Problem

This issue applies only to the 3.5.1 version of Wordwriter.

The IEnumerable overload of SetRepeatBlock causes a compilation error when passed a DataReader because DataReader inherits from both IDataReader and IEnumerable. This causes the compiler to not know which overloaded method to link.

The following code will produces a backwards compatibility issue when built against WordWriter v3.5.1.

C#
WordTemplate doc = new WordTemplate(); 
SqlDataReader dr = /* Get Data Reader */
doc.SetRepeatBlock( dr, "TableRow" );

VB.NET
Dim doc as new WordTemplate()
Dim dr as SqlDataReader = ' Get Data Reader
doc.SetRepeatBlock( dr, "TableRow" )

This code will produce the compilation error:

The call is ambiguous between the following methods or properties: 'SoftArtisans.OfficeWriter.WordWriter.WordTemplate.SetRepeatBlock(System.Data.IDataReader, string)' and 'SoftArtisans.OfficeWriter.WordWriter.WordTemplate.SetRepeatBlock(System.Collections.IEnumerable, string)'
Solution

To workaround this issue cast the DataReader to an IDataReader before passing it into SetRepeatBlock.

C#
WordTemplate doc = new WordTemplate(); 
System.Data.SqlClient.SqlDataReader dr = /* Get Data Reader */
doc.SetRepeatBlock( (IDataReader)dr, "TableRow" ); 

VB.NET
Dim doc as new WordTemplate()
Dim dr as SqlDataReader = ' Get Data Reader
doc.SetRepeatBlock( CType(dr, IDataReader), "TableRow" )

*** Note ***
This issue was resolved in version 3.5.2 by removing the IEnumerable overload and replacing it with an ICollection overload.

Created : 10/17/2007 2:01:58 PM (last modified : 10/17/2007 2:01:58 PM)

Rate this article!

 
Comments



Copyright 2006 © SoftArtisans, Inc. All Rights Reserved.

Site Map     |     Privacy Policy     |     Contact Us