Correct way to reference a DLL from a web service RRS feed

  • Question

  • Firstly, I am calling a web service which forms a wrapper for a DLL. The dll exposes just one class which you log onto (with a hash) and then request data by calls to a "command" method. Between calls the dll class called by the web service seems to lose its class level variables. The DLL has to be in the GAC because its COM enabled.

    for example a typical use of the dll would be:

    dim x as new mydllclass

    This is how the dll is called from .net apps, asp pages, aspx pages and vb6 apps.

    from the web service, we do the same kind of thing, except that acceptuser and command are now exposed as web methods

    dim x as new mywebservice

    Now between webacceptuser and webcommand, the DLL class somehow lost its class level variables.

    1. Is this normal for a web service due to iis architecture ? I.e. do I need to do all the work in a single invoke or...
    2. is it because the web service has stuck its own copy of the DLL in the webservice/bin directory? ...

    I would like to get the DLL referenced properly so it doesn't do a copy local anyway, and I would like to know if its possible to maintain state in the DLL between webmethod calls.

    thanks in advance 


    Tuesday, May 30, 2006 6:37 PM


  • Yes, it's the normal behaviour of stateless Web Services. Instead of trying to make them statefull (like storing web service's state between call in persistent storage) it is strongly encouraged (by principles of the Service Oriented Architecture) to redesign interface of web service.

    E.g. create a method which accepts username (as in webacceptuser) and the array of commands (as in webcommand method) you want to execute on behalf of that user. This way you will not be required to save web services state between calls because there would be no need to another call.

    If it's not feasible to redesign a web service and underlying COM objects (internally used by web service) - consider migrating code from web service to .NET remoting singleton object.

    Wednesday, May 31, 2006 3:34 AM