1

I've been struggling with this for a while. I have to different devices that I need to run a corporate app on. It is written using .NET CF 1.1. Both have their own managed dlls that need to be called to get the serial number off the gun.

I have yet to find a safe way to call one, and if it fails, move on to call the next. The exception always occurs outside of my application and can't be caught, thus crashing my app.

These dlls are copied in with my software, so I can't do a file check on the device.

Is there anything you guys can think of that would allow me to identify one device over the other without hard crashing and let me call the appropriate dll without a problem?

I did this using the referenced dlls directly, as well as through reflection (one dll I need a MethodInfo.invoke, and the other is just a field value).

Any and all help is appreciated. Thank you!

IronicMuffin
  • 4,182
  • 12
  • 47
  • 90
  • What exception are you getting? Can you give us some sample code to show how you're making the calls and attempting to trap the exceptions? – Jim Mischel Dec 02 '10 at 14:56
  • See my other question here: http://stackoverflow.com/questions/4288120/why-cant-my-net-cf-application-find-a-dll-in-the-same-directory-as-the-executab . The exceptions are due to the DLL failing and being unable to catch the exception. – IronicMuffin Dec 02 '10 at 15:00
  • That's interesting, but sample code showing how you're making the call would be very helpful. – Jim Mischel Dec 02 '10 at 15:09

2 Answers2

1

P/Invoke SystemParametersInfo with SPI_GETOEMINFO to see if the OEM has provided some platform-specific string you can look for. Some OEMs also have their own specific registry entries for the platform name, so you might be able to look for that with the Remote Registry Viewer and then switch on that if you find one.

EDIT

There's an example of this, for detecting barcode scanner manufacturer no less, on MSDN.

ctacke
  • 66,480
  • 18
  • 94
  • 155
0

Some more work with reflection showed that I can trap the exceptions correctly and it didn't crash the application. My solution was to use reflection expose properties or methods depending on what object explorer showed me, and to get or set the values using the various methods in the System.Reflection library.

IronicMuffin
  • 4,182
  • 12
  • 47
  • 90