NT Service, Assembly Security, Permissions
-
Hi @all, i'm realy distressed so i hope someone can help me... What i want ist to call a native function declared in an API dll from a 3rd party application. Ok, it's not hard to do that. The method construction looks like that :
BOOL WINAPI theFunc(SomeNotToDescribeObject *pObject, /*out*/LPTSTR szPath)...
This method gets an object, generate a file from that and put it in the TEMP folder of the current context. The OUT argument gives me the path where the file have been stored in. That's it. My call:[System.Runtime.InteropServices.DllImport("mydll.dll")] static extern unsafe bool theFunc([MarshalAs(UnmanagedType.Interface)] SomeNotToDescribeObject obj, StringBuilder buffer); StringBuilder buffer = new StringBuilder(260); try { bRet = teFunc(obj, buffer); }...
That works... Ok, and where is my problem??? It works just in an windows forms application [with 2003 and 2005]. Not in an C# Windows Service under VS2005. The strange thing with it is that it works on .NET 1.1 service with VS.NET 2003 but not in 2.0 VS2005. I don't understand that yet. The service [2005] i write runs under local system. So, my thought was that the function try to write the filoe into the %userprofile%Temp folder and the service got no rights to write into that folder. So i bending my environment variables for the temp folder [uservariables for the current user] all to c:\windows\temp. The same effect.. It won't work. Then i try to run the service under the local user account, with c:\windows\temp and %userprofile%temp, combined with allow interaction with desktop and so on... Nothing works... The strange thing is that it works in an Windows Forms application under .NET 2.0 on the same machine. I don't think that it is the call that fails. It have to be something with the assembly permissions or whatever... So what is the main difference between an Windows Forms application and an NT service under .NET? I temped to change Service properties like them in the Windows Forms application. Or what is the diffrence between an NT Service written with VS2003 and VS2005? What can i do to call my needed method from my windows service? Regards