locked
[UWP] Unhandled Exception: System.IO.FileNotFoundException RRS feed

  • Question

  • Hi 

    I wrote a method to press the keyboard key automatically in console, so for this I used InputSimulator and I used exe into my UWP app using FullTrust (DesktopBridge)

                    

      private static void SleepDevice()   //made in console
            {
                try
                {
                    var inputSim = new InputSimulator();
                    inputSim.Keyboard.ModifiedKeyStroke(VirtualKeyCode.LWIN, VirtualKeyCode.VK_X);
                    Thread.Sleep(500);
                    inputSim.Keyboard.KeyPress(VirtualKeyCode.VK_U);
                    Thread.Sleep(500);
                    inputSim.Keyboard.KeyPress(VirtualKeyCode.VK_S);
                    Console.Read();
                }
                catch (Exception ex)
                {

                }
            }

    When I am calling it from my UWP app using FullTrust getting below error-

    Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'WindowsInput, Version=1.0.4.0, Culture=neutral, PublicKeyToken=9b287f7dc5073cad' or one of its dependencies. The system cannot find the file specified.
       at ConsoleAppSample.Program.SleepDevice()
       at ConsoleAppSample.Program.Main(String[] args)

    How to resolve this error. Please let me know if anything is not clear. 


    sandeep chauhan


    Tuesday, January 29, 2019 1:33 PM

Answers

  • Hi,

    Glad to hear that you have solved the problem. And it is appreciated to share your solution here.

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, January 31, 2019 2:41 AM

All replies

  • Hi,

    What's the OS version and target version of your UWP app? Is the console app a UWP console app or a normal console app?

    Well, does this problem happen when you try to launch the console? Or it happens when you had launched the console app and run into the SleepDevice method?

    What about run the console app directly? Does the error still happens?

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, January 30, 2019 2:47 AM
  • Hi Roy

    Thanks for response !

    OS - Windows 10

    Target min version - Anniversary update

              max version - latest

    Actually problem was when I call console app's exe from my UWP app.

    But when I direct run the console app by making set as startup project is working fine.

    But good news is that now I solve my problem. Actually I installed "InputSimulator" from package manager into console app to do something and I paste updated exe into my UWP's assets folder. also I needed to paste "InputSimulator" (WindowsInput.dll) into my UWP's assets folder then able to resolve my problem. before this I was only paste updated exe into assets folder not dll.

    Thanks


    sandeep chauhan

    Wednesday, January 30, 2019 8:27 AM
  • Hi,

    Glad to hear that you have solved the problem. And it is appreciated to share your solution here.

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, January 31, 2019 2:41 AM