我在ClickOnce部署的应用程序中依赖于.NET 2.0 SP2(该ApplicationDeployment.CurrentDeployment.CheckForDetailedUpdate(false)方法仅适用于SP2).
我想检查应用启动期间SP2是否存在.我试图通过在调用仅SP2方法后捕获MissingMethodException来检测这一点.
/// <summary>
/// The SP2 bootstrapper does not allow HomeSite installation
/// http://msdn.microsoft.com/en-us/vstudio/bb898654.aspx
/// So we only advice the user to download .NET 2.0 SP2 manually.
/// </summary>
private void CheckDotNet2SP()
{
WaitHandle wh = new AutoResetEvent(true);
try
{
wh.WaitOne(1); //this method is .NET 2.0 SP2 only
}
//NOTE: this catch does not catch the MissingMethodException
catch (Exception) //change to catch(MissingMethodException) does not help
{
//report that .NET 2.0 SP2 is missing
}
finally …Run Code Online (Sandbox Code Playgroud)