{"action":"created","issue":{"url":"https://api.github.com/repos/scriptcs/scriptcs/issues/1095","labels_url":"https://api.github.com/repos/scriptcs/scriptcs/issues/1095/labels{/name}","comments_url":"https://api.github.com/repos/scriptcs/scriptcs/issues/1095/comments","events_url":"https://api.github.com/repos/scriptcs/scriptcs/issues/1095/events","html_url":"https://github.com/scriptcs/scriptcs/issues/1095","id":107397316,"number":1095,"title":"NullReferenceException running script (Win10, .NET 4.6)","user":{"login":"aikeru","id":1163405,"avatar_url":"https://avatars.githubusercontent.com/u/1163405?v=3","gravatar_id":"","url":"https://api.github.com/users/aikeru","html_url":"https://github.com/aikeru","followers_url":"https://api.github.com/users/aikeru/followers","following_url":"https://api.github.com/users/aikeru/following{/other_user}","gists_url":"https://api.github.com/users/aikeru/gists{/gist_id}","starred_url":"https://api.github.com/users/aikeru/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aikeru/subscriptions","organizations_url":"https://api.github.com/users/aikeru/orgs","repos_url":"https://api.github.com/users/aikeru/repos","events_url":"https://api.github.com/users/aikeru/events{/privacy}","received_events_url":"https://api.github.com/users/aikeru/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/scriptcs/scriptcs/labels/question","name":"question","color":"f7c6c7"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-09-20T15:09:17Z","updated_at":"2015-09-22T13:29:38Z","closed_at":null,"body":"I love ScriptCS! :)\r\n\r\nThis code, when run within a much larger script, seems to run fine on a Windows 8.1 64-bit system with .NET 4.5.2 and Visual Studio 2015 installed.\r\n\r\nIt throws a NullReferenceException when run on a Windows 10, 32-bit system with what seems to be .NET 4.6. Visual Studio is not installed.\r\n\r\nPlease let me know if I can supply any additional details for troubleshooting.\r\n\r\n```c#\r\nusing System;\r\nusing System.Collections.Generic;\r\nusing System.Linq;\r\nusing System.Text;\r\nusing System.Reflection;\r\nusing System.Collections;\r\n\r\n    public class JSONObjectBase\r\n    {\r\n        private System.Collections.Generic.Dictionary<string, JSONObjectBase> _JSONProperties = new System.Collections.Generic.Dictionary<string, JSONObjectBase>();\r\n\r\n        public System.Collections.Generic.Dictionary<string, JSONObjectBase> JSONProperties\r\n        {\r\n            get { return _JSONProperties; }\r\n            set { _JSONProperties = value; }\r\n        }\r\n\r\n        /// <summary>\r\n        /// Will not be used if JSONProperties.Count > 0\r\n        /// </summary>\r\n        public object Value { get; set; }\r\n\r\n        public JSONObjectBase Attr(string name)\r\n        {\r\n            return JSONProperties[name];\r\n        }\r\n\r\n        public override string ToString()\r\n        {\r\n            return Render();\r\n        }\r\n\r\n        public virtual string RenderJSONValue(object val)\r\n        {\r\n            StringBuilder sb = new StringBuilder();\r\n            if (val == null) { return \"null\"; }\r\n            if (val.GetType() == typeof(bool))\r\n            {\r\n                if (Convert.ToBoolean(val)) { return \"true\"; }\r\n                return \"false\";\r\n            }\r\n            Type[] numberArrays = new Type[] {\r\n                    typeof(int[]), typeof(long[]),typeof(double[]),typeof(float[]),typeof(byte[]),typeof(short[]),typeof(decimal[])\r\n                };\r\n            Type[] numbers = new Type[] {\r\n                   typeof(int), typeof(long), typeof(double), typeof(float), typeof(byte),typeof(short),typeof(decimal)\r\n                };\r\n            if (numberArrays.Contains(val.GetType()))\r\n            {\r\n                sb.Append(\"[\");\r\n                bool firstNum = true;\r\n                foreach (object x in (IEnumerable)val)\r\n                {\r\n                    if (firstNum) { sb.Append(x.ToString()); }\r\n                    if (!firstNum) { sb.Append(\",\" + x.ToString()); }\r\n                    firstNum = false;\r\n\r\n                }\r\n                sb.Append(\"]\");\r\n            }\r\n            else if (val.GetType() == typeof(string))\r\n            {\r\n                return \"\\\"\" + val.ToString() + \"\\\"\";\r\n            }\r\n            else if (val as IEnumerable != null)\r\n            {\r\n                sb.Append(\"[\");\r\n                bool firstArr = true;\r\n                foreach (object x in (IEnumerable)val)\r\n                {\r\n                    if (firstArr) { sb.Append(RenderJSONValue(x)); }\r\n                    if (!firstArr) { sb.Append(\",\" + RenderJSONValue(x)); }\r\n                    firstArr = false;\r\n                }\r\n                sb.Append(\"]\");\r\n            }\r\n            else if (val.GetType().IsSubclassOf(typeof(JSONObjectBase)))\r\n            {\r\n                sb.Append(((JSONObjectBase)val).Render());\r\n            }\r\n            else if (numbers.Contains(val.GetType()))\r\n            {\r\n                sb.Append(val.ToString());\r\n            }\r\n            else\r\n            {\r\n                sb.Append(\"\\\"\" + val.ToString() + \"\\\"\");\r\n            }\r\n            return sb.ToString();\r\n        }\r\n\r\n        public virtual string Render()\r\n        {\r\n            StringBuilder sb = new StringBuilder();\r\n            bool firstProp = true;\r\n            if (JSONProperties.Count > 0)\r\n            {\r\n                sb.Append(\"{\");\r\n                foreach (KeyValuePair<string, JSONObjectBase> kvp in JSONProperties)\r\n                {\r\n                    if (firstProp)\r\n                    {\r\n                        sb.Append(\"\\\"\" + kvp.Key + \"\\\":\");\r\n                        firstProp = false;\r\n                    }\r\n                    else\r\n                    {\r\n                        sb.Append(\",\\\"\" + kvp.Key + \"\\\":\");\r\n                    }\r\n                    sb.Append(kvp.Value.Render());\r\n                }\r\n                sb.Append(\"}\");\r\n            }\r\n            else\r\n            {\r\n                return RenderJSONValue(Value);\r\n            }\r\n\r\n            var output = sb.ToString();\r\n            output = output.Replace(\"\\r\\n\", \"\\\\r\\\\n\")\r\n            .Replace(\"\\r\", \"\\\\r\")\r\n            .Replace(\"\\n\", \"\\\\n\");\r\n            //if (sb.ToString().Contains(\"\\r\") || sb.ToString().Contains(\"\\n\"))\r\n            //{ throw new Exception(\"JSON cannot contain return characters \\\\r \\\\n.\"); }\r\n\r\n            return output;\r\n        }\r\n\r\n        public virtual JSONObjectBase MergeObjectProperties<T>(System.Collections.Generic.Dictionary<string, T> jsonProperties) {\r\n            if (jsonProperties == null) { return this; }\r\n            if (jsonProperties.Count < 1) { return this; }\r\n            foreach (KeyValuePair<string, T> kvp in jsonProperties) {\r\n                if (JSONProperties.ContainsKey(kvp.Key.ToLower())) {\r\n                    JSONProperties[kvp.Key.ToLower()] = new JSONObject(jsonProperties[kvp.Key]);\r\n                } else {\r\n                    JSONProperties.Add(kvp.Key.ToLower(), new JSONObject(jsonProperties[kvp.Key]));\r\n                }\r\n            }\r\n            return this;\r\n        }\r\n    }\r\n```"},"comment":{"url":"https://api.github.com/repos/scriptcs/scriptcs/issues/comments/142289806","html_url":"https://github.com/scriptcs/scriptcs/issues/1095#issuecomment-142289806","issue_url":"https://api.github.com/repos/scriptcs/scriptcs/issues/1095","id":142289806,"user":{"login":"adamralph","id":677704,"avatar_url":"https://avatars.githubusercontent.com/u/677704?v=3","gravatar_id":"","url":"https://api.github.com/users/adamralph","html_url":"https://github.com/adamralph","followers_url":"https://api.github.com/users/adamralph/followers","following_url":"https://api.github.com/users/adamralph/following{/other_user}","gists_url":"https://api.github.com/users/adamralph/gists{/gist_id}","starred_url":"https://api.github.com/users/adamralph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamralph/subscriptions","organizations_url":"https://api.github.com/users/adamralph/orgs","repos_url":"https://api.github.com/users/adamralph/repos","events_url":"https://api.github.com/users/adamralph/events{/privacy}","received_events_url":"https://api.github.com/users/adamralph/received_events","type":"User","site_admin":false},"created_at":"2015-09-22T13:29:38Z","updated_at":"2015-09-22T13:29:38Z","body":"Thanks @aikeru \r\n\r\n@scriptcs/core this looks like a Roslyn bug to me...."}}