【发布时间】:2019-12-12 06:23:38
【问题描述】:
我的 WPF 应用程序有问题。运行它时,它会因 System.Windows.Markup.XamlParseException 而中断:
Additional information: 'The invocation of the constructor on type 'myproject_csharp.MainWindow'
that matches the specified binding constraints threw an exception.' Line number '7' and line
position '9'.
在这个位置,我从外部 DLL 中调用一个函数,该函数需要一个变量参数列表:
int pos = 0;
res = myfunc_init(ref pos,__arglist(several parameters here));
这个函数本身定义为
[DllImportAttribute("my.dll", EntryPoint = "myfunc_init_api", CharSet = CharSet.Ansi, CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)]
public static extern uint myfunc_init(ref int var, __arglist);
据我所知,一切都是正确的。那么这个异常是从哪里来的呢?变量参数列表有什么问题吗?
需要注意的一点:在 IDE 中,该函数被标记为错误的“方法没有重载需要 2 个参数”,但随后 int 编译没有错误。
谢谢!
【问题讨论】:
-
由于没有minimal reproducible example,因此很难弄清楚该异常是如何引发的......但是帖子中显示的代码可能不应该工作(假设您尝试将数组作为单独的参数(stackoverflow.com/questions/32175822/…)...