Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullReferenceException in parseShortcutLocations #226

Closed
joshuawarner32 opened this issue Feb 11, 2015 · 3 comments · Fixed by #227
Closed

NullReferenceException in parseShortcutLocations #226

joshuawarner32 opened this issue Feb 11, 2015 · 3 comments · Fixed by #227

Comments

@joshuawarner32
Copy link

If I run Update.exe --createShortcuts app/0.5.1/MyApp.exe, I get the following exception:

System.NullReferenceException: Object reference not set to an instance of an object.
   at Squirrel.Update.Program.parseShortcutLocations(String shortcutArgs)
   at Squirrel.Update.Program.Shortcut(String exeName, String shortcutArgs)
   at Squirrel.Update.Program.main(String[] args)
   at Squirrel.Update.Program.Main(String[] args)

I can't be completely confident, since I don't have an environment where I can effectively compile/debug Squirrel.Windows, but I'm going to hazard a guess that the following should fix the problem:

diff --git a/src/Update/Program.cs b/src/Update/Program.cs
index 7a845c9..dc45761 100644
--- a/src/Update/Program.cs
+++ b/src/Update/Program.cs
@@ -629,14 +629,17 @@ static string getAppNameFromDirectory(string path = null)
         static ShortcutLocation? parseShortcutLocations(string shortcutArgs)
         {
             var ret = default(ShortcutLocation?);
-            var args = shortcutArgs.Split(new[] { ',' });
-
-            foreach (var arg in args) {
-                var location = (ShortcutLocation)(Enum.Parse(typeof(ShortcutLocation), arg, false));
-                if (ret.HasValue) {
-                    ret |= location;
-                } else {
-                    ret = location;
+            if(shortcutArgs != null)
+            {
+                var args = shortcutArgs.Split(new[] { ',' });
+
+                foreach (var arg in args) {
+                    var location = (ShortcutLocation)(Enum.Parse(typeof(ShortcutLocation), arg, false));
+                    if (ret.HasValue) {
+                        ret |= location;
+                    } else {
+                        ret = location;
+                    }
                 }
             }
@anaisbetts
Copy link
Contributor

@joshuawarner32 createShortcuts only takes an executable name, not a path:

Update.exe --createShortcuts myApp.exe

@joshuawarner32
Copy link
Author

@paulcbetts - Thanks, but that's not the issue here.

It doesn't matter what argument I pass to --createShortcuts (I've tried the executable name, path, and random strings), I get the same exception.

@anaisbetts anaisbetts reopened this Feb 11, 2015
@anaisbetts
Copy link
Contributor

/cc @CharlieHess

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants