某些PC而非其他PC上发生System.MissingMethodException错误

时间:2018-11-13 15:42:24

标签: c# error-handling

某些用户在尝试运行某些基本软件时遇到以下错误

************** Exception Text **************
System.MissingMethodException: Method not found: 'System.Threading.Tasks.Task System.Threading.Tasks.Task.Delay(Int32)'.
   at SkillControl_Version_Control.Form1.btnInstallProceed_Click(Object sender, EventArgs e)
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1026 (RTMGDR.030319-1000)
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
----------------------------------------
SkillControl Version Control
    Assembly Version: 1.0.0.0
    Win32 Version: 1.0.0.0
    CodeBase: file:///T:/Boots%20The%20Chemists/IS%20%26%20T/Service/Operations/Helpdesk/Team%20Leader/SkillControl/SkillControl%20Version%20Control.exe
----------------------------------------
System.Windows.Forms
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1032 built by: RTMGDR
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1036 built by: RTMGDR
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1026 built by: RTMGDR
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Core
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1 built by: RTMRel
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------

这仅在某些机器上发生,而在其他机器上不发生 令人讨厌的代码如下:

private void btnInstallProceed_Click(object sender, EventArgs e)
        {
            //Proceed with installation
            try
            {
                try
                {
                    //Create SkillControl directory
                    Directory.CreateDirectory(@"C:\ProgramData\SkillControl\");
                    txtInstallOutput.AppendText("\nSkill Control directory created");
                }
                catch (Exception err)
                {
                    txtInstallOutput.AppendText("\n" + err.Message);
                }

                //Copy files to new directory
                File.Copy(string.Format(@"T:\Boots The Chemists\IS & T\Service\Operations\Helpdesk\Team Leader\SkillControl\Versions\V{0}\SkillControl.exe", MaxVer), @"C:\ProgramData\SkillControl\SkillControl.exe", true);
                txtInstallOutput.AppendText("\nSkillControl.exe copied");
                File.Copy(string.Format(@"T:\Boots The Chemists\IS & T\Service\Operations\Helpdesk\Team Leader\SkillControl\Versions\V{0}\SkillControl.exe.config", MaxVer), @"C:\ProgramData\SkillControl\Skillcontrol.exe.config", true);
                txtInstallOutput.AppendText("\nSkillControl config file copied");
                txtInstallOutput.AppendText("\nFiles copied OK, launching SkillControl");
                Process.Start(@"C:\ProgramData\SkillControl\SkillControl.exe");

                try
                {
                    //Create start menu shortcut
                    txtInstallOutput.AppendText("\nCreating start menu shortcut");
                    //Directory.CreateDirectory(@"%appdata%\Microsoft\Windows\Start Menu\SkillControl\");
                    Directory.CreateDirectory(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"Microsoft\Windows\Start Menu\Programs\SkillControl\"));
                    Thread.Sleep(1000);
                    File.Copy(string.Format(@"T:\Boots The Chemists\IS & T\Service\Operations\Helpdesk\Team Leader\SkillControl\Versions\V{0}\SkillControl.exe.lnk", MaxVer), Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"Microsoft\Windows\Start Menu\Programs\SkillControl\SkillControl.exe.lnk"), true);
                    txtInstallOutput.AppendText("\nShortcut created");
                }
                catch (Exception err)
                {
                    txtInstallOutput.AppendText("\n" + err.Message);
                }
            }
            catch(Exception err)
            {
                txtInstallOutput.AppendText("\n" + err.Message);
            }

            txtInstallOutput.AppendText("\nFinished");
        }

这已经在64位和32台台式机和笔记本电脑,Win7和Win10机器上进行了测试,谁得到错误之间没有一致性,这使我认为在获得错误的机器上缺少依赖性,但是我不知道.NET需要安装或升级什么?我故意使用.Net 3.5进行兼容性,因此不应该遇到这种情况

0 个答案:

没有答案