I am reading all installed software from the registry. It is working fine on all computers tested except for one which is giving me the following problem.
It reads the data from the registry correctly and puts the proper data into the proper fields of a class. I put a lot of MessageBox.Show() commands in to see what is returned and it all seems correct.
The Display Name of the regKey = Foxit Reader
the uninstallstring = C:\Program Files (x86)\Foxit Software\Foxit Reader\Uninstall.exe
I get this when I message box the values (in C#) but when I do the JsonConvert.SerializeObject into object
public int ID { get; set; }
public int AssetID { get; set; }
public string DisplayName { get; set; }
public string DisplayVersion { get; set; }
public string Publisher { get; set; }
public string RegKey { get; set; }
public string UninstallString { get; set; }
public string InstallDate { get; set; }
public bool IsActive { get; set; }
it ends up looking like this :
{"ID":0,"AssetID":7,"DisplayName":"Foxit Reader\u0000\u0000\u0000\u0000\\Microso","DisplayVersion":"0.0.0.0","Publisher":null,"RegKey":"Foxit Reader","UninstallString":"C:\\Program Files (x86)\\Foxit Software\\Foxit Reader\\Uninstall.exe\u0000Fox-Ä~vÊ\u0000\u000f¦\u0000\u0000\u0010\u0000üú\u0018\u0000¼þ\u0018\u0000\u0010«¯v\u0001\u0000\u0000\u0000¬ž|vÎ|vÄû\u0018\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000€\u001a\u0000\u0000","InstallDate":"Jan 1 1980","IsActive":true}
I have put the following :
// Encrypt the class
var serializerSettings = new JsonSerializerSettings();
serializerSettings.StringEscapeHandling = StringEscapeHandling.EscapeNonAscii;
string serializedClass = JsonConvert.SerializeObject(this, serializerSettings);
code in place (before it was just:
string serializedClass = JsonConvert.SerializeObject(this);
What can I do to get away from all of the junk? When I pass this to my API to insert into the database I am getting invalid format errors.
Any help would be appreciated. Thanks in advance.