正确的C#类方法使用dllimport从DLL获取数据 [英] Correct C# class method to get data from DLL using dllimport

查看:91
本文介绍了正确的C#类方法使用dllimport从DLL获取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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.

推荐答案

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

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

    // ...
}


到目前为止一切顺利,但编译器回复:

So far so good, but the compiler responds:
A get or set accessor expected

get访问者的调用在哪里?

Where does the call for the get accessor go?


这篇关于正确的C#类方法使用dllimport从DLL获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆