Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System.MissingMethodException thrown from HidDevices.Enumerate #47

Open
AngusMcIntyre opened this issue Oct 6, 2014 · 3 comments
Open

Comments

@AngusMcIntyre
Copy link

Hi Mike and friends,

I recently upgraded my Nuget package from 3.2.23 to 3.2.29 and am receiving a MissingMethodException when enumerating my device,

Exception content

System.MissingMethodException was unhandled
  HResult=-2146233069
  Message=Method not found: 'Int32 System.Runtime.InteropServices.Marshal.SizeOf(!!0)'.
  Source=HidLibrary
  StackTrace:
       at HidLibrary.HidDevices.EnumerateDevices()
       at HidLibrary.HidDevices.Enumerate(Int32 vendorId, Int32[] productIds) in d:\TeamCity\BuildAgent\work\26c2362cad24d4c8\src\HidLibrary\HidDevices.cs:line 35
       at HIDDeviceTest.Program.Main(String[] args) in x:\GitFlow\XP01\HIDDeviceTest\HIDDeviceTest\Program.cs:line 22
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException:

Environment

  • The exception happens with all overloads and is not present in version 3.2.28.
  • I have .NET Framework 4.5 installed but no higher that I can see.
  • Operating System: Windows 7 x64

I imagine the .NET version is the problem but I wanted to let you know. I'm fairly sure Nuget shouldn't have let me add it to me project!

@amullins83
Copy link
Collaborator

I'm not sure how to fix this, but it seems like the system is failing to create a new instance of NativeMethods.SP_DEVICE_INTERFACE_DATA, so the call to SizeOf is passed a null pointer (or something else that evaluates to !!0). Why it would throw this exception instead of the ArgumentNullException expected from the docs is anyone's guess. What OS and architecture are you targeting?

@AngusMcIntyre
Copy link
Author

@amullins83 I've edited in the OS an architecture. A silly omission in the first place!

@Yitzchok
Copy link

Installing the latest version of .NET help me with this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants