0

Im using wix at the moment and have developed an installer. This installer calls a C++ custom action DLL. Both the DLL and the setup are building successfully but when i go to install it the installation ends with "The Installer Wizard ended Prematurely because of an error" Anyone know a possible answer?

This is the C++ Dll function:

extern "C" UINT __stdcall StopOrcService(MSIHANDLE hInstall)

Then i continue in under it with the code for the function. I then exported it using the def file.

<CustomAction Id='StopOrcService' BinaryKey='StopOrcService' DllEntry='StopOrcService' Execute='immediate' Return='check'/>

<InstallExecuteSequence>
  <Custom Action='StopOrcService' After='ProcessComponents' />
</InstallExecuteSequence>

<Binary Id='StopOrcService' SourceFile='SetupDLL.dll' />

That is my wix code.

Ajay
  • 18,086
  • 12
  • 59
  • 105
Natalie Carr
  • 3,707
  • 3
  • 34
  • 68

2 Answers2

1

There are dozens of possible answers and it's hard to say without seeing your C++ and your WiX code.

Things to consider:

Was the C++ dll purposefully built as a custom action? ( Does it export a Type1 stdcall MsiCustom Action? ) What's the name of that function? Is that function name correct in your WiX code? Have you put any logging in your function to see if it got executed?

Update: You shouldn't be using a custom action to do something that the installer can do natively. Also when creating CA's that require elevation and/or change the state of the machine, they should always be scheduled as deferred with no impersonation not immediate. You have a bunch of reading to do on installer best practices to fix your strategic problems rather than bandied your tactical problem.

Ajay
  • 18,086
  • 12
  • 59
  • 105
Christopher Painter
  • 54,556
  • 6
  • 63
  • 100
  • First thing I wonder is why have a custom action to stop a service. Your export statements could be messed up. Take a look at the DLL in Depends and see if you see the function exported. – Christopher Painter Jul 26 '12 at 16:08
  • Another thing is your CA is scheduled for immeadiate execution. This will frequently fail on machines that require elevation (such as UAC enabled ) as the person doing the installer likely won't have permissions to perform the needed operation. – Christopher Painter Jul 26 '12 at 16:09
  • It is yes, it has to be though as i need to find the registry value as to where my application is going to install. I ran a log file and it is saying Error 0x80070715: Failed to get file version of custom action dll although i have added a version number to my DLL – Natalie Carr Jul 26 '12 at 16:19
  • How did you make this DLL? If you are using Visual Studio, WiX has a nice C++ project template that sets this all up for you including creating te version resource record. – Christopher Painter Jul 26 '12 at 16:27
  • This installer is an add on for another program, so i have to stop the service of the program and then find the registry the first program is installed to and add the new add on to that location. I made the DLL in the wix C++ and have added the .rc file and it is still given me errors – Natalie Carr Jul 26 '12 at 16:28
  • If you need to pass data to a custom action that requires elevation then you should be using CustomActionData to marshel the data over. A custom action that changes machine state should never be scheduled as immediate. – Christopher Painter Jul 26 '12 at 16:28
  • An installer can be configured to stop a service that was not installed by the installer. Take a look at the ServiceControl element. – Christopher Painter Jul 26 '12 at 16:30
-1

I have realized that i forgot to add the following line which made my code work perfectly. Hopefully this helps others.:)

#pragma comment(linker, "/EXPORT:StopOrcService=_StopOrcService@4")
Natalie Carr
  • 3,707
  • 3
  • 34
  • 68