locked
ASP.NET 2.0 and COM Port Communication RRS feed

  • Question

  • User-1910029751 posted


    ASP.NET 2.0 and COM Port Communication

    Hello Guys,

    I have a managed DLL which communicates with the devices attached on COM/Serial ports. The desktop Winforms application sends requests on ports and receives/stores data in memory. In Winforms app I have added a reference to DLL and I am using the methods. This works well. Now, there is a situation where I need to show this data from serial/com port on a web-page. And also users should be able to send requests to the ports using this DLL.

    I have made a web app in ASP.NET (2.0). Added a reference to the DLL. I am able to use this DLL, the DLL communicates on the COM upon button click on web-page and also the response is shown on web page.

    However I am not happy with the approach and strongly feel that this is a bad approach. Also the development server crashes after 3 -4 requests.

    What is the best approach in this scenario. If I use a windows service then how would my ASP.net app will communicate with the Weindows service.

    Or can this be easily done using WCF. I have not used WCF any time nor any of .net remoting technique.

    Please suggest me the best architecture in this scenario.

    Thank you


    Saturday, February 20, 2010 12:15 PM

Answers

  • User2089561920 posted

    YES, this scenario will definitely crash. reason being, IIS is multi-threaded and the com port libraries are not thread safe.


    you will need to work out some way of querying the com port in sequence, you can either use locking techniques (search for asp.net locking) or else create a window service/executable and pass messages to and from that and your web app, to do so you can use any .net remoting techniques, e.g msmq, wcf


    performance wise, its generally safer to use .net remoting and queue the requests rather than using lock techniques

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, February 20, 2010 2:35 PM

All replies

  • User2089561920 posted

    YES, this scenario will definitely crash. reason being, IIS is multi-threaded and the com port libraries are not thread safe.


    you will need to work out some way of querying the com port in sequence, you can either use locking techniques (search for asp.net locking) or else create a window service/executable and pass messages to and from that and your web app, to do so you can use any .net remoting techniques, e.g msmq, wcf


    performance wise, its generally safer to use .net remoting and queue the requests rather than using lock techniques

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, February 20, 2010 2:35 PM
  • User-1910029751 posted

    Thank you Kwanann for your reply.

    YES, this scenario will definitely crash. reason being, IIS is multi-threaded and the com port libraries are not thread safe.

    you will need to work out some way of querying the com port in sequence, you can either use locking techniques

    I have taken care of this in the DLL itself. The logic in DLL queue's up all the requests it gets.

    or else create a window service/executable and pass messages to and from that and your web app, to do so you can use any .net remoting techniques, e.g msmq, wcf

    performance wise, its generally safer to use .net remoting and queue the requests rather than using lock techniques


    Windows service option seems more promising. I will try this one.


    Saturday, February 20, 2010 10:07 PM