我想从C#ASP.NET代码调用Delphi函数。该函数的声明如下:从C#代码调用delphi DLL方法
function SomeFunction(const someString, SomeOtherString: string): OleVariant;
从我的C#代码,我有这样的代码:
[DLLImport(MyDLL.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
public static extern object SomeFunction(string someString, string SomeOtherString);
我每次调用此方法并将其存储为一个对象,我得到的P/Invoke错误。我从来没有从我的C#中调用过非托管代码,所以我有点不知所措。
您收到的P/Invoke错误是什么? =) – Rob 2010-02-04 14:53:32
您需要将您的函数标记为“export”和“stdcall”作为最小值。显示你的单位代码在哪里定义这个函数被导出。 – 2010-02-04 14:54:08
[请参考我前几天在Tek-Tips论坛上发布的FAQ(Click Me)](http://tek-tips.com/faqs.cfm?fid=7416) – 2010-12-17 01:37:30