0

there,

a piece of code is like this:

try
{
   ClassA a = new ClassA();
}
catch(Exception e)
{
   ......
}

that class A is in another assembly, however, in some environment, that assembly got corrupted, so I expect I will receive the invalidPrgramExecption. However, when the above code is running in w3wp process, it just got crashed without even if I want to catch the base Exception class.

Do you know what's the reason why InvalidProgramException won't be captured? (because of the multi thread environment?) Is there any way that I can handle this exception gracefully without crash?

Thanks!

cao lei
  • 891
  • 1
  • 9
  • 19
  • 1
    An InvalidProgramException indicates that the MSIL or metadata is invalid. I don't find it surprising that exception handling won't work if the assembly isn't valid MSIL code. – BJ Myers Nov 20 '17 at 06:59
  • 1
    Why not just replace the corrupted assembly? Do you actually expect this to happen on a regular basis? – EJoshuaS - Stand with Ukraine Nov 20 '17 at 06:59
  • @BJMyers why not surprising? I assume InvalidProgramException is designed to handle this case – cao lei Nov 20 '17 at 07:17
  • @EJoshuaS I don't have the permission to replace the corrupted assembly. this case is expected but we have to handle this case gracefully without crash – cao lei Nov 20 '17 at 07:18

0 Answers0