Не удалось загрузить файл c# - PullRequest
0 голосов
/ 10 апреля 2020

В моем p c (win10) он работает отлично, но если я пытаюсь запустить на своем рабочем месте p c (win7), я получаю эту ошибку: https://imgur.com/a/UfVoths Мой код кнопки this:

    using (PowerShell PowerShellInstance = PowerShell.Create())
    {
        PowerShellInstance.AddScript("cmdkey /list | ForEach-Object{if($_ -like \"*Target:*\"){cmdkey /del:($_ -replace \" \",\"\" -replace \"Target:\",\"\")}}");
        PowerShellInstance.Invoke();
        OutlookMsg om = new OutlookMsg
        {
            StartPosition = FormStartPosition.CenterParent
        };
        om.ShowDialog();
    }
}

Если я укажу подробности, которые показывают исключения, как я могу это исправить?

See the end of this message for details on invoking
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.IO.FileNotFoundException: Could not load file or assembly 'System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
File name: 'System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
   at Helpdesk.Form1.OutlookBtn_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)

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
************** Loaded Assemblies **************

Я удалил эту часть Это был только путь к DLL

************** JIT Debugging ********

******
    To enable just-in-time (JIT) debugging, the .config file for this
    application or computer (machine.config) must have the
    jitDebugging value set in the system.windows.forms section.
    The application must also be compiled with debugging
    enabled.

    For example:

    <configuration>
        <system.windows.forms jitDebugging="true" />
    </configuration>

    When JIT debugging is enabled, any unhandled exception
    will be sent to the JIT debugger registered on the computer
    rather than be handled by this dialog box.

1 Ответ

0 голосов
/ 10 апреля 2020

Компьютер не имеет сборки. Кажется, вам просто нужно установить библиотеку времени выполнения

http://www.microsoft.com/en-us/download/details.aspx?id=34595

Установить эту Windows6.1-KB2506143-***.msu для Windows 7

...