Question

I have a windows form application which is working fine. I created now a windows service with FileSystemWatcher, it went ok.But when I copied the code from the windows form I had before it doesn´t work. (It is working on the windows form)Is there anything I need to take care working with windows services?.The application (windows forms) is to receive a file, make some operations with that information and then using an dll, comms with a scale.

      [DllImport("mydll.dll")]
        public static extern int OPENETHNET();

    [DllImport("mydll.dll")]
    public static extern int ETHWRITE(string in1);

    [DllImport("mydll.dll")]
    public static extern int ETHREAD(StringBuilder in2);

    [DllImport("mydll.dll")]
    public static extern int CLOSEETHNET();  

and then I use it like this:

        string inputStatus = "050";
        StringBuilder resultStatus = new StringBuilder(1024);


        openRest = OPENETHNET();

        if (ETHWRITE(inputStatus) == 1)
        {
            ETHREAD(resultStatus);
        }
        CLOSEETHNET();

It doesn´t even opens the conection..
I tried to change the account to LocalService and the other options but, still the same.. Any ideias?

EDIT: I saw the post Call to native DLL fails from a .NET Windows service ANd It seems to be the same problem
I tried the other solutions but it didn´t worked So I´ll try the last option, that it will be to to "wrap the dll in a web service that will run on start up and then call through to that web service from the web service."
Can anyone explain me how to do that?

No correct solution

OTHER TIPS

After a lot of tests I realised that problem was in the dll file, so I drop the windows services and implement a winform ( where I know that the dll file works) and use the winform like a service, I now this solution is not the best one but, well is working..

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top