We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Exception thrown when using spreadsheet - on a subsequent usage

I had encountered the problem [previously with thread 141595 but couldnt get a reliable repro.   After reworking the application to depend less upon the spreadsheet control as I was encountering a number of bugs since starting using it but have got to a stage where I reliably repro this error using the spreadsheet control.

The exception thrown is 
  Message=Exception has been thrown by the target of an invocation.
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Delegate.DynamicInvokeImpl(Object[] args)
   at System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme)
   at System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme)
   at System.Windows.Forms.Control.InvokeMarshaledCallbacks()
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
   at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
   at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
   at CheckinManifest.My.MyApplication.Main(String[] Args) in :line 81

Inner Exception 1:
ArgumentException: Item has already been added. Key in dictionary: '!11!'  Key being added: '!11!'

InnerException {"Item has already been added. Key in dictionary: '!11!'  Key being added: '!11!'"} System.Exception {System.ArgumentException}

   at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add)
   at System.Collections.Hashtable.Add(Object key, Object value)
   at Syncfusion.Windows.Forms.CellGrid.FormulaEngine.RegisterGridAsSheet(String refName, ICalcData grid, Int32 sheetFamilyID)
   at Syncfusion.Windows.Forms.Spreadsheet.Converter.SpreadsheetImportExtension.ImportExcelToGrid(Spreadsheet spreadsheet, IWorkbook workbook, Int32 SheetFamilyId)
   at Syncfusion.Windows.Forms.Spreadsheet.Spreadsheet.LoadTabItems()
   at Syncfusion.Windows.Forms.Spreadsheet.Spreadsheet.OpenFile(Stream file)
   at Syncfusion.Windows.Forms.Spreadsheet.Spreadsheet.<>c__DisplayClass49.<Open>b__44()

I will PM the project source and a video repro.


13 Replies

GM Gangabharathy Murugasen Syncfusion Team April 30, 2019 04:31 AM UTC

Attached in the link is a video repro and the source code for the repro project. 
Please do not publically share the source code. 
The video should show the repro of the bug which is consistent and causes the application to crash.    
Adrian Bowles 

SP Spotty May 1, 2019 02:24 AM UTC


You just publically copy a link despite me asking not to publically share and sending a PM.   Please contact me to get the repro if you havent already downloaded it, I have pulled the link down now.

AR Arulpriya Ramalingam Syncfusion Team May 1, 2019 12:37 PM UTC

Hi Spooty,  
Sorry for the inconvenience caused.  
We will remove the update by tomorrow (2nd May 2019). Please share your repro sample to us through support@syncfusion.com . So that, we would analyze for the issue to provide you a better solution.  

SP Spotty May 3, 2019 04:01 PM UTC

The link was removed and the updated location was sent in a PM.   Any update.

JP Jagadeesan Pichaimuthu Syncfusion Team May 6, 2019 11:24 AM UTC

Hi Spotty, 
Thanks for your update. 
In your shared link, we can only find the video demo only and there is no sample in that provided link. So, can you please attach the issue reproducible sample in that link to check your reported scenario. It will be helpful for us to investigate further. 

SP Spotty May 6, 2019 04:55 PM UTC

I believe that should have zip in containing repro now

SR Sabaridass Ramamoorthy Syncfusion Team May 7, 2019 01:26 PM UTC

Hi Spotty, 

We are unable to find the sample in your provided link. We can only found issue reproducible video alone. Please find the screenshot below, 

Can you please send the valid link again to our support mail id. It will be more helpful for us to provide the solution at the earliest. 

Sabaridass R 

SP Spotty May 7, 2019 03:15 PM UTC

Sent email with updated repro.

Please check email.

SR Sabaridass Ramamoorthy Syncfusion Team May 8, 2019 11:50 AM UTC

Hi Spotty, 

Thanks for your update. 

We have already logged a bug report for this kind of issue “Target invocation exception occurs while loading the spreadsheet again”. Here we have provided private feedback link, we request you to log in to view the link further   https://www.syncfusion.com/feedback/5948/target-invocation-exception-occurs-while-loading-the-xlsm-file 
The fix will be available in our upcoming Volume 2 release which is scheduled to be rolled out at the end of June, 2019. Would waiting for the official release is OK for you? Otherwise, we can provide a patch on May 29 , 2019.    
If you have any more specification replication procedure or a scenario to be tested you can add it as a comment in the portal. 

Sabaridass R 

SP Spotty May 8, 2019 02:33 PM UTC

A patch would be great as this is blocking my project.    

SR Sabaridass Ramamoorthy Syncfusion Team May 9, 2019 07:30 AM UTC

Hi Spooty, 

Thanks for the update.  

As per your request, we will provide the patch for the reported issue on 29th May. 2019. 

Sabaridass R 

SP Spotty May 30, 2019 06:01 PM UTC

Any update on that patch.

MG Mohanraj Gunasekaran Syncfusion Team May 31, 2019 02:09 PM UTC

Hi Spotty,  
Sorry for the delay. 
The issue with "Target invocation exception occurs while loading the .xlsm file" has been fixed and the patch for this fix can be downloaded from the following location. 

Recommended approach - exe will perform automatic configuration
Please find the patch setup from below location:


Advanced approach – use only if you have specific needs and can directly replace existing assemblies for your build environment
Please find the patch assemblies alone from below location:


Assembly Version:
Installation Directions : 
This patch should replace the files “Syncfusion.Spreadsheet.Windows” under the following folder.
$system drive:\ Files\Syncfusion\Essential Studio\$Version # \precompiledassemblies\$Version#\4.0
Eg : $system drive:\Program Files\Syncfusion\Essential Studio\\precompiledassemblies\\4.0

To automatically run the Assembly Manager, please check the Run assembly manager checkbox option while installing the patch. If this option is unchecked, the patch will replace the assemblies in precompiled assemblies’ folder only. Then, you will have to manually copy and paste them to the preferred location or you will have to run the Syncfusion Assembly Manager application (available from the Syncfusion Dashboard, installed as a shortcut in the Application menu) to re-install assemblies.

Note : 
To change how you receive bug fixes, ask your license management portal admin to change your project’s patch delivery mode.


Disclaimer : 
Please note that we have created this patch for version specifically to resolve the following issue(s) reported in this/the forum(s). 144305

If you have received other patches for the same version for other products, please apply all patches in the order received.
This fix will be included in our next main release 2019 Volume2.  

Mohanraj G 

Live Chat Icon For mobile
Up arrow icon