Search code examples
c#.netcompact-frameworkassembliesmanaged

What's the best way to identify a WinCE device and call a correct DLL based on the results?


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!


Solution

  • 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.