2

I am not used to asking the community to solve my problems, but I am a newbie in C#/.NET and I am currently stuck.

I want to make a XAML application using LibUsbDotNet to communicate with an program on an Android powered phone using the Android Accessory Protocol through USB.

After a lot of research, I think I have successfully installed LibUsbDotNet (well finally, it's just install the .exe and add the reference to libusbdotnet.dll isn't it?), and now I'm trying to make it work.

Consequently, I have implemented a short program, as simple as the following:

namespace PC_side
{
    /// <summary>
    /// Une page vide peut être utilisée seule ou constituer une page de destination au sein d'un frame.
    /// </summary>
    public sealed partial class MainPage : Page
    {
        public MainPage()
        {
            this.InitializeComponent();
            UsbRegDeviceList allDevices = UsbDevice.AllDevices;
            console.Text += allDevices.Count();
        }         
    }
}

But when I execute it, it doesn't work. Then when I use the debugger, an exception occurs: System.TypeLoadException.

More details :

Could not load type 'Microsoft.Win32.RegistryValueKind' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.

I am using Visual Studio Enterprise 2015 on a Windows 10 Professional 64bit computer.

Can someone help me by saying what I did wrong and pointing me in the right direction please? I'm a bit lost.

Thanks a lot for your help.

P.S. Please don't mind my bad English, I'm not an English native speaker.

2
  • Try running as administrator, and you shouldn't be setting the text of controls in the constructor, do that in the Load event. I'd dumb this down even more and go with a console application and worry about the UI after you get the USB part working. Commented Nov 4, 2015 at 14:29
  • Thank you for your answer. I've already tried running it as admin. I will try to run it with a console application to see what is changing Commented Nov 7, 2015 at 23:50

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.