Quantcast
Channel: Common Language Runtime Internals and Architecture forum
Viewing all articles
Browse latest Browse all 1710

Instance of AggregateException causes TargetInvocationException

$
0
0

I have a problem that an instance of an AggregateException causes a TargetInvocationExceptionafter a couple of accesses to an Icon resource.

I broke down the problem to the following steps to reproduce (.Net 4.0 full or client profile):

  • Create a new WinForms application (a console application will not work)
  • Add an arbitrary icon (.ico file) to the resources
  • Add the following code to the constructor:

new AggregateException();
for (var i = 0; ; ++i)
{
  var icon = Resources.Certificate;
}

You have to change the resource name to the name of your resource.

That's all. Yes I know that this sample doesn't make sense. It's just to illustrate the problem. My working code is much more complex and all of this code is needed.

Without creating this excection the application will work forewer. But if this exception is created the access to the resource will fail with a TargetInvocationException. The InnerException told me that the operation has been finished successfully(?!?!) having a two-line stack trace in System.Drawing.Icon (ctor + Initialize).

What can I do to prevent this problem?

Is that a bug in the .Net-Framework?


Viewing all articles
Browse latest Browse all 1710

Trending Articles



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