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

Mayooran Macilamany mayooran99 at gmail.com
Wed May 31 07:26:58 PDT 2017

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.

public static ActionResult CreateScheduleTaskForRunningtestapp(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 =
string testappManagerPath = Path.Combine(myPath, "testappManager.exe");
session.Log("testappManagerPAth" + testappManagerPath);
key.SetValue("testappManager", testappManagerPath);

Below is how I am calling it.

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

*     Custom Action="CreateScheduleTaskForRunningtestapp"
Before="InstallFinalize">(NOT INSTALLED OR NOT


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:
*SFXCA: Extracting custom action to temporary directory:
*SFXCA: Binding to CLR version v4.0.30319*
*Calling custom action
*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
*   --- 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
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*

More information about the wix-users mailing list