WiX自定义操作项目 - BadImageFormatException [英] WiX Custom Action Project - BadImageFormatException

查看:213
本文介绍了WiX自定义操作项目 - BadImageFormatException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发我的第一个自定义操作,但是我无法得到生成的.CA.dll文件加载。以最简单的方式处理流程,结果如下:

I'm developing my first custom action but I can't get the resulting .CA.dll file to load. Heres the process at its simplest, and the result:

我创建一个自定义操作项目并保留所有默认值。该类看起来像这样:

I create a custom action project and keep all the defaults. The class looks like this:

using Microsoft.Deployment.WindowsInstaller;
namespace CustomAction
{
public class CustomActions
{
[CustomAction]
    public static ActionResult CustomAction1(Session session)
    {
        session.Log("Begin CustomAction1");

        return ActionResult.Success;
    }
}
}

然后我构建程序集在调试或释放),这创建了一个CustomAction.CA.dll文件。然后尝试运行此测试:

I then build the assembly (either in debug or release) which creates me a CustomAction.CA.dll file. I then try to run this test:

[TestMethod]
    public void LoadAssembly()
    {
        Assembly.LoadFrom(@"D:\CustomAction\bin\Debug\CustomAction.CA.dll");
    }

并得到错误:
System.BadImageFormatException:无法加载文件或程序集file:/// D:\CustomAction\bin\Debug\CustomAction.CA.dll或其依赖关系之一。该模块预计包含一个程序集清单。

And get the error: System.BadImageFormatException: Could not load file or assembly 'file:///D:\CustomAction\bin\Debug\CustomAction.CA.dll' or one of its dependencies. The module was expected to contain an assembly manifest.

我也无法从WiX项目引用自定义操作。真的很沮丧!

Neither can I reference the custom action from my WiX project. Getting really frustrated!

编辑:
看了一下,当我运行VS测试管理器时,我在应用程序事件日志中得到以下内容:

TmiDataManager.TryConvertPropertyValueToDisplayText:使用属性描述符的类型转换器无法转换属性值。 System.FormatException:输入字符串格式不正确。

在System.Number.StringToNumber(String str,NumberStyles options,NumberBuffer& number,NumberFormatInfo info,Boolean parseDecimal)

在System.Number.ParseInt32(String s,NumberStyles样式,NumberFormatInfo信息)

在System.String.System.IConvertible.ToInt32(IFormatProvider提供程序)

在System.Convert.DefaultToType (IConvertible value,Type targetType,IFormatProvider Provider)

在System.String.System.IConvertible.ToType(Type type,IFormatProvider provider)

在System.ComponentModel.EnumConverter.ConvertTo( ITypeDescriptorContext context,CultureInfo culture,Object value,Type destinationType)

在System.ComponentModel.TypeConverter.ConvertToString(Object value)

Had a look and when I run through VS test manager I'm getting the following in the application event log:
TmiDataManager.TryConvertPropertyValueToDisplayText: Failed to convert property value using the property descriptor's type converter. System.FormatException: Input string was not in a correct format.
at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
at System.String.System.IConvertible.ToInt32(IFormatProvider provider)
at System.Convert.DefaultToType(IConvertible value, Type targetType, IFormatProvider Provider)
at System.String.System.IConvertible.ToType(Type type, IFormatProvider provider)
at System.ComponentModel.EnumConverter.ConvertTo(ITypeDescriptorContext context, CultureInfo culture, Object value, Type destinationType)
at System.ComponentModel.TypeConverter.ConvertToString(Object value)"

进一步编辑:我可以通过Assembly.LoadFrom加载正常的CustomAction.dll,所以可能这是BadImageFormat的一个不同的问题?有没有rea儿子没有进一步依赖的空白动作不会加载到我的WiX项目中?

Further edit: I can load the normal CustomAction.dll via Assembly.LoadFrom, so maybe this is a different issue to the BadImageFormat thing? Could there be any reason a blank action with no further dependencies wouldn't load into my WiX project?

推荐答案

CustomAction.CA.dll是一个本机-code DLL包含托管代码程序集,并知道如何作为MSI中的自定义操作运行。托管代码程序集为CustomAction.dll。

CustomAction.CA.dll is a native-code DLL that contains the managed-code assembly and knows how to run as a custom action inside MSI. The managed-code assembly is "CustomAction.dll."

这篇关于WiX自定义操作项目 - BadImageFormatException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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