我怎么能叫从Inno Setup的脚本中的.NET的DLL? [英] How can I call a .NET DLL from an Inno Setup script?

查看:328
本文介绍了我怎么能叫从Inno Setup的脚本中的.NET的DLL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从一个Inno Setup的脚本中调用从.NET的DLL(codeD在C#)的函数。

我有:

  1. 标记中的注册COM互操作的在项目属性选项,
  2. 改的标记有ComVisible特性的在的AssemblyInfo.cs 的文件,
  3. 设置
  4. 添加了这些行向国际空间站运送脚本:
  

[文件]

     

来源: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

我是什么做错了吗?

解决方案

抱歉,是我不好,它已经太长时间,因为我读过帕斯卡!所以,如果你需要得到的值,则有几种可能性:

  1. 将在C / C ++的功能和导出功能,这是绝对支持的。
  2. 使用一个托管C ++ DLL来垫片到您的.NET的DLL,并露出呼叫作为C接口点(这应该工作,但它变得杂乱)
  3. 使用一个.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:

  1. marked the Register for COM interop option in the project properties,
  2. changed the ComVisible setting in the AssemblyInfo.cs file,
  3. 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:

  1. Write the functionality in C/C++ and export the function, that's definitely supported.
  2. 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)
  3. 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).

这篇关于我怎么能叫从Inno Setup的脚本中的.NET的DLL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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