WiX Custom Action Project - BadImageFormatException
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;
}
}
}
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");
}
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.
Neither can I reference the custom action from my WiX project. Getting really frustrated!
Edit: 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)"Further edit: I can load the normal CustomAction.dl开发者_运维技巧l 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 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."
精彩评论