Quantcast
Channel: NetOffice - MS Office in .NET
Viewing all articles
Browse latest Browse all 1741

Commented Issue: "Collection was modified" error when disposing application [21514]

$
0
0
Hi

From time to time, I encounter the following error when calling Application.Dispose().
Please see the stacktrace :
```
System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
at System.Collections.Generic.List`1.Enumerator.MoveNext()
at NetOffice.COMObject.DisposeChildInstances(Boolean disposeEventBinding)
at NetOffice.COMObject.Dispose(Boolean disposeEventBinding)
at NetOffice.ExcelApi.Application.Dispose(Boolean disposeEventBinding)
at NetOffice.ExcelApi.Application.Dispose()
```

After looking the source code, there may be a bug in COMObject.RemoveChildObject(), it misses the block
```
if (Settings.EnableThreadSafe)
{
Monitor.Enter(this._childListLock);
flag = true;
}
```

Hope this helps.
Comments: ** Comment from web user: juflo **

Hi

After many retries, I'm unable to isolate the issue in a sample code.
Feel free to send me a code snippet for generating the data you need to analyse.

Regards.


Viewing all articles
Browse latest Browse all 1741

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>