.NET Web Service - Call Unmanaged C dll

I have a requirement to call dll (unmanaged c) from a .NET web service (asmx or WCF).

Calling a DLL from a web service is simple and works as expected.

However, there are problems loading the test web service. (error code 0xC0000374 - "internal error, usually including heap corruption").

I was informed by the owner of the dll that the dll is not reliable in a multi-threaded environment if 2 or more calls are sent at the same time.

In a traditional Windows application, I would deal with this by implementing a singleton class to protect dlls. Is there a recommended approach to achieve this goal in implementing a web service?

+3
source share
2

, DLL, lock:

public static class MyDllCalls
{
    private static object _lockObject = new object();

    public static int SomeCall()
    {
        lock (_lockObject)
        {
            return CallSomeFunctionInYourDll();
        }
    }
}

, .

+3

, .

0

Source: https://habr.com/ru/post/1749202/


All Articles