DllImport and Windows Services

T

Tushar

(Note follow-up set to microsoft.public.dotnet.myservices only)

We have a client-server environment where clients request services from the
server via a C/C++ DLL (it is *not* COM based). The DLL has been used by
many application including C++ and VB over many years.

I tried to make use of this DLL in a .Net C# application by making use of
DllImport as follows:

[ DllImport("CodaLink.dll", EntryPoint="LinkEncrypt",
CharSet=CharSet.Ansi) ]
private static extern int LinkEncrypt([Out] StringBuilder Output, string
Input, string UserID);

I encapsulated these types of calls in a .Net DLL assembly, created a sample
..Net Console application that uses the DLL, and that ran fine.

I then tried to create a .Net Windows Services and installed it using the
same security context as the Console application but it is failing. I think
it if failing to establish a connection to the server. I have made sure that
both the Windows Service EXE and the .Net DLL Assembly are in the same
directory and I've also included the containing directory into the system
PATH. From the service I write the PATH to the EventLog and it does contain
the containing folder as expected.

The Windows Service appears to be making some calls to the DLL but I do not
understand why the DLL works from a Console app but not in a Windows
Service.

Please help?
 
Joined
Aug 8, 2017
Messages
1
Reaction score
0
Hello
Were you able to find the solution ?
I know your post is very old, but I am right now stuck in the same problem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top