0

We are using the SoftArtisans ExcelWriter to open and process data from various excel files. One file has recently begun giving us the following error: An item with the same key has already been added.

I've attempted the Excel repair options for repairing the file and extracting the data, but both the repaired files and the original file continue to return the same error.

Stack Trace, as promised:

System.ArgumentException was unhandled by user code
HResult=-2147024809
Message=An item with the same key has already been added.
Source=mscorlib
StackTrace:
   at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
   at SoftArtisans.OfficeWriter.ExcelWriter.XMLModel.᝜.ᜀ()
   at SoftArtisans.OfficeWriter.ExcelWriter.XMLModel.᝜..ctor(᜴ A_0, ᝉ A_1)
   at SoftArtisans.OfficeWriter.ExcelWriter.XMLModel.ᝂ.ᜀ()
   at SoftArtisans.OfficeWriter.ExcelWriter.Model.ᜉ..ctor(ល A_0, រ A_1, ᝣ A_2, ᡆ A_3)
   at SoftArtisans.OfficeWriter.ExcelWriter.Model.ល..ctor(ᝣ A_0, ᠐ A_1)
   at SoftArtisans.OfficeWriter.ExcelWriter.Model.ោ..ctor(ᝣ A_0, IEnumerable`1 A_1)
   at SoftArtisans.OfficeWriter.ExcelWriter.XMLModel.᝚..ctor(᜔ A_0, ᝘ A_1, ᝂ A_2, ឤ A_3)
   at SoftArtisans.OfficeWriter.ExcelWriter.XMLModel.᝘.ᜄ()
   at SoftArtisans.OfficeWriter.ExcelWriter.XMLModel.᜔.ᜀ()
   at SoftArtisans.OfficeWriter.ExcelWriter.XMLModel.᜔..ctor(Stream A_0, String A_1, ᝻ A_2)
   at SoftArtisans.OfficeWriter.ExcelWriter.ᜊ.ᜀ(Stream A_0, String A_1, Boolean A_2)
   at SoftArtisans.OfficeWriter.ExcelWriter.ᜊ.ᜀ(Stream A_0, Boolean A_1)
   at SoftArtisans.OfficeWriter.ExcelWriter.ExcelApplication.Open(Stream stream)
sohjsolwin
  • 271
  • 1
  • 6
  • What version of ExcelWriter are you using? Does it happen with the latest version? – Sam Plus Plus Jun 15 '15 at 18:50
  • SoftArtisans has several known bugs. This is one of them and has many ways to be reproduced, i will comment one of them: If you have a worksheet with a namedRange (Sometimes it has an internal namedRange like PrintArea so check it out) If you delete that worksheet the namedRange would be "passed" to the next worksheet instead of being deleted When you try to create a new worksheet with the same name than the deleted one the system would complain cause the "next" worksheet has already a similar namedRange – Jorge Laines Feb 07 '19 at 18:18

1 Answers1

0

It sounds like somewhere in your or SoftArtisan's code there is a System.Collections.Generic.Dictionary, where two objects with the same key are being added.

user8128167
  • 6,929
  • 6
  • 66
  • 79