Closed apalomba closed 6 years ago
What do you mean as "parsing as a service"? Could you provide a sample code and a sample ini file to run some tests?
"parsing as a service" means I am calling the ini-parser from a windows service. When I load the INI file from the service, it encounters this error. When I run the same code as a console app, it does not encounter this error. It is a mystery to me why the behavior is different. I have attached the INI file... DataParserSystem.txt
My code...
FileIniDataParser fileIniData = new FileIniDataParser(); fileIniData.Parser.Configuration.CommentString = "#"; fileIniData.Parser.Configuration.ThrowExceptionsOnError = true; string appPath = AppDomain.CurrentDomain.BaseDirectory; IniData iniData = fileIniData.ReadFile(appPath + "DataParserUser.ini", System.Text.Encoding.UTF8);
I got it to work. I had to load the file into memory and escape special characters manually before giving it to ini-parser. Ideally I should not have to do this. It would be nice if ini-parser worked the same in both cases.
I have no access to a windows machine right now so I can't test the code under a windows service, however this is a really strange bug. Which special characters did you removed for this to work?
I escaped all the ones I was using "(", ")", and "+".
This is working fine, I can confirm as I tested it on a service. You may have an issue with the default Regex Parser for the section name in IniParser as it's designed to not accept special characters.
@rboy1 did you manage to reproduce the bug? Could you provide the project for a windows service so I can try to troubleshoot the issue?
Hello there, I seem to be encountering the same problem. I have an INI file that loads okay when running as an application. But when I run my app as a service, ini-parser can not parse the same INI file. I get the following error....
IniParser.Exceptions.ParsingException[br]Could not parse file DataParserSystem.ini while parsing line number 0 with value '' - IniParser version: 2.4.0.0[br] at IniParser.FileIniDataParser.ReadFile(String filePath, Encoding fileEncoding)
I am specifying Encoding.UTF8. Why would there be a difference in reading the file as a service?
Thanks, Anthony