Click here to Skip to main content
15,891,567 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using DLLImport in a C# project for the first time.  I have not found the right way to specify a class method to get data from the DLL.  Here is my code; the public void CallDLL is not correct.  Any help with the right method call would be very appreciated.  

    internal static class NativeMethods
    {
        [DllImport("SMA_03_Process.dll", EntryPoint="S0Process")]
        public static extern int ReturnVal(int a, int b);
    }

        public void CallDLL
        {
            int Value;
            Value = S0Process;
        }
    }


What I have tried:

Other method headers with different constructions, none of which have been correct.
Posted
Updated 10-Jul-17 3:09am

C#
public void CallDLL()
{
    int a = 2; // example
    int b = 3; // example

    int Value = NativeMethods.ReturnVal(a, b);

    // ...
}
 
Share this answer
 
v2
So far so good, but the compiler responds:
A get or set accessor expected
Where does the call for the get accessor go?
 
Share this answer
 
Comments
[no name] 8-Jul-17 17:31pm    
You forgot the () after CallDLL, making it a Property instead of a Method.
So make it a property by adding a Get and/or Set, or add the ()...
Member 13300090 10-Jul-17 9:10am    
Thank you Peter; I will try that.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900