我在使用Labview中构建的DLL中的参数时遇到了问题。
我的整个代码是:
namespace ConsoleApplication4
{
public class Program
{
//DLL einbinden
[DllImport(@"C:\DLL_Uebergabe\SharedLib.dll")]
public static extern void Unbenannt2(out double Amplitude, out double Reqlength);
public void Main(string[] args)
{
//Einbinden der .Net Interop-Assembly
//double Amp;
//Result Amplitude = new Result();
//Amp = Amplitude.GetResult();
//Console.WriteLine("Amplitude ist demzufolge: {0}", Amp);
double Amplitude;
double Reqlength;
this.Unbenannt2(out Amplitude, out Reqlength);
Console.WriteLine("Amplitude: {0} und Reqlength: {1}", Amplitude,Reqlength);
}
}}
我的编译器总是说:
无法通过实例引用进行访问,请改用类型名称对其进行限定。
此错误在代码行出现:
This.Unbenannt2(输出幅度,输出请求长度);
你能告诉我错误在哪里吗?谢谢你的帮助。
发布于 2011-10-20 18:06:13
您必须在不使用this.指针的情况下调用它,因为它不是实例成员;它是静态成员。
发布于 2011-10-20 18:06:42
啊哈哈!!公共静态外部。只需使用Program.Unbenannt2或Unbenannt2即可。
发布于 2011-10-20 18:08:48
编译器告诉您您的方法是一个static方法,而您正在尝试访问它,就好像它是一个实例方法一样。This means is doesn't belong to an instance of your Program class.
您可以使用类型名来限定它,正如编译器建议的那样:
Program.Unbenannt2(out Amplitude, out Reqlength);或者,因为它属于您的Program类,所以您可以简单地省略类型名称:
Unbenannt2(out Amplitude, out Reqlength);https://stackoverflow.com/questions/7834267
复制相似问题