我想从一个Inno Setup的脚本中调用从.NET的DLL(codeD在C#)的函数。
我有:
标记中的注册COM互操作的在项目属性选项, 改的标记有ComVisible特性的在的AssemblyInfo.cs 的文件,设置 添加了这些行向国际空间站运送脚本:[文件]
来源:C:\ TEMP \ 1 \ MYDLL.DLL;标志:dontcopy
[code]
函数MyFunction的():字符串;
外部的MyFunction @文件:MYDLL.DLL STDCALL setuponly';
但我仍然得到以下错误:
运行时错误(在-1:0):
无法导入DLL:C:\ DOCUME〜1 \富\ LOCALS〜1 \ TEMP \是-LRL3E.tmp \ MYDLL.DLL
我是什么做错了吗?
解决方案抱歉,是我不好,它已经太长时间,因为我读过帕斯卡!所以,如果你需要得到的值,则有几种可能性:
将在C / C ++的功能和导出功能,这是绝对支持的。 使用一个托管C ++ DLL来垫片到您的.NET的DLL,并露出呼叫作为C接口点(这应该工作,但它变得杂乱) 使用一个.exe来存储你的code结果在.ini文件或注册表或临时文件和读取结果设置code节(这是现在可以正确讨厌)当我去年曾用InnoSetup它不支持的情况下直接(从调用.NET设置code)。
I want to call a function from a .NET DLL (coded in C#) from an Inno Setup script.
I have:
marked the Register for COM interop option in the project properties, changed the ComVisible setting in the AssemblyInfo.cs file, added these lines to the ISS script:
[Files]
Source: c:\temp\1\MyDLL.dll; Flags: dontcopy
[Code]
function MyFunction(): string;
external 'MyFunction@files:MyDLL.dll stdcall setuponly';
but I still get the following error:
Runtime Error (at -1:0):
Cannot Import dll:C:\DOCUME~1\foo\LOCALS~1\Temp\is-LRL3E.tmp\MyDLL.dll.
What am I doing wrong?
解决方案Oops, my bad, it's been too long since I've read pascal! So, if you need to get the value then there are a couple of possibilities:
Write the functionality in C/C++ and export the function, that's definitely supported. Use a Managed C++ dll to shim to your .NET dll, and expose the call as a C interface point (this should work, but it's getting messy) Use an .exe to store the result of your code in a .INI file or the registry or in a temp file and read the result in the setup code section (this is now properly nasty)When I last worked with InnoSetup it didn't support your scenario directly (calling .NET code from setup).