0

I have been using Windows APIs for NFC communication. I am successful in getting and sending NFC messages from Windows PC, using a local console app. However, I want the communication to be done using a Windows service. Here is what I have:

  1. A C# plugin (DLL), which makes the API calls.
  2. C++/CLI Wrapper that allows unmanaged C++ code, to use the above plugin.
  3. A C++ plugin, that the service will load (this is a requirement, it has to be a plugin)

If I load the C++ plugin into a local console app, and run, it can catch all NFC events (NFC device arrives in proximity, departs from proximity, can read and write to it). But, when I use the same plugin with a service, it is not able to catch those events. I can clearly hear the ping sound that comes when an NFC device comes close to Windows PC, however, none of the event handlers are called (For device arrival, device departure, read or write).

I also tried impersonation thinking that perhaps the context of who calls the method might result in blocking of the events. I could impersonate local user on the service, but the results were the same, no events could be identified.

Is there a reason why I cannot see any NFC events from a service, where as a local console app can get all of them? Again, I am able to hear the ping sound signifying that NFC device is close to Windows PC, but there is no handler getting called for it, suggesting there is blockage of something. Any ideas of what is going on?

Appreciate your time guys!

Michael Roland
  • 39,663
  • 10
  • 99
  • 206
  • Could it be that [Message pump in .NET Windows service](http://stackoverflow.com/a/2457470/1115360) is of use to you? – Andrew Morton May 05 '15 at 17:36
  • Thanks @AndrewMorton! Well, in my case, the service is not .NET, and I am trying to make the least possible changes to the service itself. Do you know of any reason why any event in general, might get blocked when in context of a service? Or is it just over here that I am running into such problem? – user3222280 May 06 '15 at 18:13
  • My thought was that if the supplied NFC software uses the Windows message pump system to raise the events, then you need to have a "message only window" to receive those events in the service. Beyond that, I know nothing. – Andrew Morton May 06 '15 at 19:00

0 Answers0