Giter Site home page Giter Site logo

Comments (8)

oleg-shilo avatar oleg-shilo commented on July 26, 2024

The error means that the assembly that has been compiled for x64 is being loaded on the x86 CLR or vise versa. Ideally you want your assembly to be compiled against "AnyCPU" this way it will adhere to the CLR CPU type of the host/target system.

Note, MSI runtime is always x86 even when it is running on x64 OS.

from wixsharp.

pkzOR avatar pkzOR commented on July 26, 2024

Thanks for the reply. I had looked at exactly that, but all the projects were set to AnyCPU (with Prefer 32 bit un-check). I'll look again.

from wixsharp.

oleg-shilo avatar oleg-shilo commented on July 26, 2024

But what is the target CPU of that third party assembly? May be it is what is causing the discrepancy? You can check the asm CPU type with ILSpy/Reflectpor. And you can also run a hello world msi with Wix# custom action to check what is the actual CLR type during the installation. I recon this is where the problem is.

from wixsharp.

pkzOR avatar pkzOR commented on July 26, 2024

it is an x86 exe. At which version of WixSharp did this get enforced? We were on version 1.0.16.

from wixsharp.

oleg-shilo avatar oleg-shilo commented on July 26, 2024

At which version of WixSharp did this get enforced?

Wix# does not enforce anything. Actually it never did. If you are talking about "MSI runtime is always x86" then it is enforced by the MSI itself.

The fact that your 3rdparty.exe is x86 already indicates that it will have a conflict when loaded on x64.

Yes I expect that MSI runtime to be always x86 but only nased on my experiments not the "promise" from MS. And I cannot exclude that under certain circumstances it can be x64 (e.g. next version of MS Installer). That is why I Wix# is compiled with neutral "AnyCPU" so it fits any OT type.

Anyway, the next step would be to verify the actual runtime on your target system is. This is how you can do it:

Create a hello world project similar to this one:

 var project =
            new ManagedProject("MyProduct",
                new Dir(@"%ProgramFiles%\My Company\My Product",
                    new File(...
...
project.Load += project_Load;
...
static void project_Load(SetupEventArgs e)
{
    MessageBox.Show("Hello World! (CLR: v" + Environment.Version + ")", 
                    "Embedded Managed CA (" + (Is64BitProcess ? "x64" : "x86") + ")");
}

static bool Is64BitProcess
{
    get { return IntPtr.Size == 8; }
}

Run the produced MSI on your target system and you will see if it is in conflict with your 3rdparty.exe CPU type.

from wixsharp.

pkzOR avatar pkzOR commented on July 26, 2024

Results:
Hello World! (CLR: v4.0.30319.42000) Embedded Managed CA (x86)

I think I've found the problem we're running into though:

I'm trying to include an unmanaged exe that's used by a custom action.
In the past (v1.0.16), wixSharp would build the msi, and include the 3rd party exe just fine.
In the newer versions, in ProjectValidator.cs, AsmReflector.OriginalAssemblyFile makes a call to System.Reflection.Assembly.ReflectionOnlyLoadFrom(...), in order to get the full filename.
This call doesn't work on unmanaged exes.
The commit where this changed is c46e2abba9c6b42375a9467f51a79242a1b45c1f .

How would someone go about including an unmanaged utility (like say 7zip.exe) in an install to be used by a custom action?


Just a note in case someone else tries this:
The project needs to be a ManagedProject and since I wasn't using a UI, project_load was changed to:
static void project_Load(SetupEventArgs e)
{
e.Session.Log("Hello World! (CLR: v" + Environment.Version + ") Embedded Managed CA (" + (IntPtr.Size == 8 ? "x64" : "x86") + ")");
}

Thanks for being so responsive!

from wixsharp.

oleg-shilo avatar oleg-shilo commented on July 26, 2024

Great. Of course. It all makes sense now.
You mentioned project.DefaultRefAssemblies meaning that you are adding assembly. This property is for the assemblies but not for unmanaged binaries.

You will need to use Binary or even `BinaryAction:

var project = 
    new Project("My Product",
        new Binary(new Id("EchoBin"), @"Files\Echo.exe"), 
        new Dir(@"%ProgramFiles%\My Company\My Product",
        
            new File(binaries, @"AppFiles\MyApp.exe",
                new WixSharp.Shortcut("MyApp", @"%ProgramMenu%\My Company\My Product"),
                new WixSharp.Shortcut("MyApp", @"%Desktop%")),
            
        new BinaryFileAction("EchoBin", "/i", 
                                Return.check, 
                                When.After, 
                                Step.InstallFinalize, 
                                Condition.NOT_Installed),
                                
        BinaryFileAction("EchoBin", "/u", 
                                Return.check, 
                                When.Before, 
                                Step.InstallFinalize, 
                                Condition.Installed), 
    ...
        
Compiler.BuildMsi(project);

from wixsharp.

pkzOR avatar pkzOR commented on July 26, 2024

Perfect! I had seen the Binary, but not the BinaryAction.
Thanks again.

from wixsharp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.