0

I am developing a web application in C# with VS 2012.

I have a fingerprint sensor with his dll in Windows Forms format. I am developing a web application, so I need to communicate the two projects.

But the fingerprint sensor needs an STAThread environment, as the windows forms one. How can I set the STAThread to a WebForm? I try this

    [STAThread]
    protected void Page_Load(object sender, EventArgs e)
    {
        //code of fingerprint
    }

but didn't work, I've got the exception ThreadStateException which says that the subprocess is not in a container of single-threaded. Help me! Thanks!

  • I don't think that you can do that on the client (Web) simple way. I think that you can not do except webservice communicate with your device. I have made something like this but was for printer and i had use asmx service. – kostas ch. Apr 25 '14 at 13:16
  • Ok, thanks, but how I run a web service in STAThread? – José Persichini Apr 25 '14 at 13:30
  • On my case i used asmx service in order to send a print to the selected printer. In your case things might be different. You might create an activex control which will do that for you or silverlight component. – kostas ch. Apr 25 '14 at 13:32
  • Actrivex or silverlight installed in client's machine. So i think you can access your device. – kostas ch. Apr 25 '14 at 13:35
  • But if I can set the web service to STAThread, can I do the communication? – José Persichini Apr 25 '14 at 13:47
  • I am sorry but i don't know. For the printer works like harm. Try it. – kostas ch. Apr 25 '14 at 13:48

1 Answers1

1

You shouldn't use STAThread in a web app.

You better create a service, which stands between the fingerprint sensor and your web app. The service will operate in STA, and expose methods for the webapp to use.

Nick
  • 4,787
  • 2
  • 18
  • 24