[wix-users] Custom action throwing null pointer exception on fresh machines

Hoover, Jacob Jacob.Hoover at greenheck.com
Wed May 31 07:49:00 PDT 2017


You're not validating the MYPATH environment variable, which in this case has no value. If your expecting your installer to add/update the MYPATH variable, I would pass the value as a property to the CA (environment blocks of processes are assigned at process creation and won't see any updated values).  In addition, immediate CA's will run in the user context so they won't have write access to HKLM.

-----Original Message-----
From: wix-users [mailto:wix-users-bounces at lists.wixtoolset.org] On Behalf Of Mayooran Macilamany
Sent: Wednesday, May 31, 2017 9:27 AM
To: WiX Toolset Users Mailing List <wix-users at lists.wixtoolset.org>
Subject: [wix-users] Custom action throwing null pointer exception on fresh machines

I have the below custom action. When I run this on a fresh Windows 10 machine with .net 4.6 installed, I am getting an exception (Shown at the end of this file with the logs) after the line where I log "inside else part". I can't figure out what it is. I am sure its not related to creating this registry entry I am creating. Because earlier, I tried creating a task scheduler task. That also resulted in the same exception. Below is my custom action.

[CustomAction]
public static ActionResult CreateScheduleTaskForRunningtestapp(Session
session)
{
session.Log("Creating the Scheduled Task for running watch dog");

string myPath = Environment.GetEnvironmentVariable("MYPATH");
session.Log("value of variable is : " + session["USETASKSCHEDULE"]); if (!IsTaskExisting("Runtestapp")) {

if (session["USETASKSCHEDULE"].Equals("someDefaultValue"))
{

session.Log("inside else part");
Microsoft.Win32.RegistryKey key;
key =
Microsoft.Win32.Registry.LocalMachine.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run");
string testappManagerPath = Path.Combine(myPath, "testappManager.exe"); session.Log("testappManagerPAth" + testappManagerPath); key.SetValue("testappManager", testappManagerPath); key.Close(); } } }

Below is how I am calling it.


*<CustomAction Id="CA_scheduleTaskActionFortestapp"
BinaryKey="removeFolderCustomActionDLL"
DllEntry="CreateScheduleTaskForRunningtestapp" Execute="immediate"
Return="ignore" />*


*<InstallExecuteSequence>*
*     Custom Action="CreateScheduleTaskForRunningtestapp"
Before="InstallFinalize">(NOT INSTALLED OR NOT
UPGRADINGPRODUCTCODE)</Custom>*

*</InstallExecuteSequence>*

But its working fine during an update though. What am I doing wrong here?
Any help would be much appreciated.

Below are the logs associated to this.

*Action start 19:46:00: CA_scheduleTaskActionForWatchDog.*
*MSI (s) (5C:A4) [19:46:00:852]: Invoking remote custom action. DLL:
C:\Windows\Installer\MSIBB59.tmp, Entrypoint:
CreateScheduleTaskForRunningWatchdog*
*SFXCA: Extracting custom action to temporary directory:
C:\Windows\Installer\MSIBB59.tmp-\*
*SFXCA: Binding to CLR version v4.0.30319* *Calling custom action
CustomActionRemoveFolder!CustomActionRemoveFolder.CustomActions.CreateScheduleTaskForRunningWatchdog*
*Creating the Scheduled Task for running watch dog* *value of variable is : someDefaultValue* *inside else part* *Exception thrown by custom action:*
*System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentNullException: Value cannot be null.* *Parameter name: path1*
*   at System.IO.Path.Combine(String path1, String path2)*
*   at
CustomActionRemoveFolder.CustomActions.CreateScheduleTaskForRunningWatchdog(Session
session)*
*   --- End of inner exception stack trace ---*
*   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object
arguments, Signature sig, Boolean constructor)*
*   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj,
Object parameters, Object arguments)*
*   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags
invokeAttr, Binder binder, Object parameters, CultureInfo culture)*
*   at
Microsoft.Deployment.WindowsInstaller.CustomActionProxy.InvokeCustomAction(Int32
sessionHandle, String entryPoint, IntPtr remotingDelegatePtr)* *CustomAction CA_scheduleTaskActionForWatchDog returned actual error code
1603 but will be translated to success due to continue marking* *Action ended 19:46:10: CA_scheduleTaskActionForWatchDog. Return value 1.* *MSI (s) (5C:A8) [19:46:10:478]: Doing action: InstallFinalize*

____________________________________________________________________
WiX Toolset Users Mailing List provided by FireGiant http://www.firegiant.com/


More information about the wix-users mailing list