在通过WiX的使用C#自定义操作失败,错误1154 [英] Custom Action in C# used via WiX fails with error 1154

查看:319
本文介绍了在通过WiX的使用C#自定义操作失败,错误1154的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用WiX的1930年3月5日在Visual Studio 2010中,针对.NET Framework 3.5的。 (后来周建维克斯似乎相对于他们的自定义操作模板,至少现在可以很破,1930年是最近的版本,这似乎让有工作的引用可建C#CA)。



我已经写在C#两个自定义操作组件。其中一个工作正常。其他失败,出现以下错误:

  CustomActionnNameHere返回实际的错误代码第1154(注意,这可能不是100%准确如果翻译发生沙盒里面)

我比较了的.csproj文件和文件.wixproj,并尽我可以告诉差异是适当的(包括的.cs文件的如表)。我已经改变了非工作.wxs调用工作自定义操作,而不是非工作自定义操作和它的作品为epxected。



我可以看看还有什么在?得到这个工作。



编辑:只是要完成1154指的是一个无效的DLL - NET HELPMSG其翻译(英文)需要一个库文件运行此应用程序已损坏



第二个编辑:peverify跑对DLL(抢下一个副本出\windows\installer,而安装程序正在运行),它说一切都在DLL罚款。该DLL只具有自定义操作方法与回归成功所以没有很多关于它来验证,但它确实确认DLL是未损坏。



第三编辑:在破碎的自定义操作的代码如下:

 使用Microsoft.Deployment.WindowsInstaller; 

命名空间Framework.Installer.Database {
公共类CustomActions {

[CustomAction]
公共静态的ActionResult RunMigration(会话的会话){

返回ActionResult.Success;
}

}
}



很多不给它。是.wxs的相关部分如下:

 < InstallExecuteSequence> 
<自定义操作=DotNetMigratorCustomActionPreviousUp后=SetMigrationPropertiesPreviousUp><![CDATA [(安培;数据库= 3)]]>< /自定义>
< / InstallExecuteSequence>

<二进制n =DotNetMigratorCustomActionDll
的SourceFile =$(var.Framework.Installer.Database.CustomActions.TargetDir)\SoftwareAnswers.Framework.Installer.Database.CustomActions.dll />

< CustomAction n =DotNetMigratorCustomActionPreviousUp
返回=检查
BinaryKey =DotNetMigratorCustomActionDll
DllEntry =RunMigration
执行=递延/>


解决方案

这听起来像你正在使用DTF。如果您看到:

 使用Microsoft.Deployment.WindowsInstaller; 



那么你肯定是。请务必阅读它是如何工作的以下内容:



部署工具基金会(DTF)管理的自定义操作



此外,你会发现在开始菜单中DTF帮助CHM下WiX的。



基本上它听起来像我你是布线.NET程序集进入安装程序,而不是unmanged包装DLL。阅读如何看待它在所依赖的概述上面的文章,并知道会发生什么。该维克斯| C#自定义操作项目应该输出Foo.dll和Foo.CA.dll。你想在安装程序的更新版本。



有关谁在未来的(答案是原来的海报)有事情的完整列表在此页面上陆地上的人检查:




  1. 您引用的二进制表正确的DLL

  2. 您是否引用了?纠正导出函数的名字吗?

  3. 是您​​的班公?

  4. 使用的是正确的签名你的方法?即它是:

  5. 用正确的CustomAction属性

  6. 标记为公共标记

  7. 标记为静态的?

  8. 返回的ActionResult?

  9. 以会话作为参数?

  10. 确保您使用的WiX的C#自定义操作项目类型,以确保postbuild事件被调用来创建本地DLL包装。 (见1)



其中任何一个可能会导致1154错误。这是我写的关于这一主题的综合性博客文章,并链接到它在这个答案的原因。重要的是要充分了解托管代码是如何呈现给非托管Windows Installer服务,并知道如何使用在很大程度上取决于验证的公共静态方法导出为在产生.CA.dll的维克斯/ DTF产生STDCALL功能。


I am using WiX 3.5.1930 in Visual Studio 2010, targeting the .NET Framework 3.5. (Later weekly builds of WiX seem to be very broken with respect to their custom action template, at least for now. 1930 is the most recent build that seems to make a buildable C# CA with working references.)

I have two custom action assemblies written in C#. One of them works fine. The other fails with the following error:

CustomActionnNameHere returned actual error code 1154 (note this may not be 100% accurate if translation happened inside sandbox)

I have compared the .csproj files and .wixproj files, and as best I can tell the differences are appropriate (e. g. list of included .cs files). I have changed the non-working .wxs to call the working custom action instead of the non-working custom action and it works as epxected.

What else can I look at to get this working?

Edit: Just to be complete 1154 refers to an invalid DLL - net helpmsg translates it (in English) to "One of the library files needed to run this application is damaged."

Second edit: ran peverify against the dll (grabbed a copy out of \windows\installer while the installer was running) and it says everything is fine in the dll. The DLL only has the custom action method with a "return success" so there's not a lot for it to verify, but it does confirm the DLL is not corrupt.

Third edit: The code in the broken custom action follows:

using Microsoft.Deployment.WindowsInstaller;

namespace Framework.Installer.Database {
    public class CustomActions {

        [CustomAction]
        public static ActionResult RunMigration(Session session) {

            return ActionResult.Success;
        }

    }
}

Not much to it. The relevant parts of the .wxs are as follows:

<InstallExecuteSequence>
  <Custom Action="DotNetMigratorCustomActionPreviousUp" After="SetMigrationPropertiesPreviousUp"><![CDATA[(&Database = 3)]]></Custom>
</InstallExecuteSequence>

<Binary Id="DotNetMigratorCustomActionDll"
        SourceFile="$(var.Framework.Installer.Database.CustomActions.TargetDir)\SoftwareAnswers.Framework.Installer.Database.CustomActions.dll" />

<CustomAction Id="DotNetMigratorCustomActionPreviousUp"
              Return="check"
              BinaryKey="DotNetMigratorCustomActionDll"
              DllEntry="RunMigration"
              Execute="deferred" />

解决方案

It sounds like you are using DTF. If you see:

using Microsoft.Deployment.WindowsInstaller;

then you certainly are. Be sure to read the following for how it all works:

Deployment Tools Foundation (DTF) Managed Custom Actions

Also you'll find a DTF help chm in the start menu under WiX.

Basically it sounds like to me you are wiring the .NET assembly into the installer instead of the unmanged wrapper dll. Read the above article for an overview of how to look at it in Depends and to know what to expect. The WiX | C# Custom Action project should output Foo.dll and Foo.CA.dll. You want the later in your installer.

For people who land on this page in the future (the answer was originally for the poster ) there is a whole list of things to check:

  1. Are you referencing the correct DLL in the Binary table?
  2. Are you referencing the correct exported function name?
  3. Is your class public?
  4. Is your method using the correct signature? I.e. is it:
  5. Marked with the correct CustomAction attribute
  6. Marked as public?
  7. Marked as static?
  8. Return ActionResult?
  9. Take Session as an Argument?
  10. Make sure you are using the WiX C# Custom Action Project type to ensure the postbuild event is called to create the native DLL wrapper. (See #1)

Any one of these can cause an 1154 error. This is the reason I wrote a comprehensive blog article on the subject and linked to it in this answer. It's important to fully understand how managed code is presented to the unmanaged Windows Installer service and to know how to use Depends to validate that the public static method is exported as a stdcall function in the resulting .CA.dll that WiX/DTF produces.

这篇关于在通过WiX的使用C#自定义操作失败,错误1154的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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