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: SebastianDotNet **

wich NO version? (the missing lock is fixed in NO 1.7.2)

give me a sample and i want execute this > 1 million times in a virtual machine to pin point the problem :)

*Sebastian


Viewing all articles
Browse latest Browse all 1741

Trending Articles



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