Why is it not possible to catch MissingMethodException?

后端 未结 4 569
深忆病人
深忆病人 2020-12-31 10:38

I have a dependency on .NET 2.0 SP2 in my ClickOnce deployed application (the ApplicationDeployment.CurrentDeployment.CheckForDetailedUpdate(false) method is SP

4条回答
  •  庸人自扰
    2020-12-31 10:49

    I suspect it's happening at JIT time, before the method is even properly entered - i.e. before your catch block is hit. It's possible that if you catch MissingMethodException in the calling method, that will sort it out... particularly if you decorate CheckDotNet2SP with MethodImpl[MethodImplOptions.NoInlining]. It still sounds like it would be pretty dicey though.

    You could always check for the presence of the method with reflection rather than by trying to call it though.

提交回复
热议问题