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.

Ron Beyer
  • 11,003
  • 1
  • 19
  • 37
Ace Nanter
  • 21
  • 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. – Ron Beyer Nov 04 '15 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 – Ace Nanter Nov 07 '15 at 23:50

0 Answers0