I get an error of
> Application: RfidService.exe Framework Version: v4.0.30319
> Description: The process was terminated due to an unhandled exception.
> Exception Info: System.IO.DirectoryNotFoundException at
> System.IO.__Error.WinIOError(Int32, System.String) at
> System.IO.FileStream.Init(System.String, System.IO.FileMode,
> System.IO.FileAccess, Int32, Boolean, System.IO.FileShare, Int32,
> System.IO.FileOptions, SECURITY_ATTRIBUTES, System.String, Boolean,
> Boolean, Boolean) at System.IO.FileStream..ctor(System.String,
> System.IO.FileMode, System.IO.FileAccess, System.IO.FileShare, Int32,
> System.IO.FileOptions, System.String, Boolean, Boolean, Boolean)
This is in the event viewer when I start my service application. It can be installed and it starts but in the event viewer it gives me the error mentioned above so it doesn't work. The only file that is needed is in the bin already and this is how I invoke it in the code.
using (var streamReader = new StreamReader(Directory.GetCurrentDirectory() + $@"JsonDataApplicationSetting.json"))
{
var jsonString = streamReader.ReadToEnd();
_applicationSetting = JsonConvert.DeserializeObject<ApplicationSetting>(jsonString);
if (_applicationSetting != null)
{
_pcsConnectionString =
$@"Data Source={_applicationSetting.PcsSetting.DataSource};Initial Catalog={_applicationSetting.PcsSetting.InitialCatalog};user={_applicationSetting.PcsSetting.User};Password={_applicationSetting.PcsSetting.Password}";
_lcsConnectionString =
$@"Data Source={_applicationSetting.LaneSetting.DataSource};Initial Catalog={_applicationSetting.LaneSetting.InitialCatalog};user={_applicationSetting.LaneSetting.User};Password={_applicationSetting.LaneSetting.Password}";
_serviceConnectionString =
$@"Data Source={_applicationSetting.ServiceDatabase.DataSource};Initial Catalog={_applicationSetting.ServiceDatabase.InitialCatalog};user={_applicationSetting.ServiceDatabase.User};Password={_applicationSetting.ServiceDatabase.Password}";
_sendingDelay = _applicationSetting.LcsSetting.SendingDelay;
_activeQueueTimeInterval = _applicationSetting.LcsSetting.ActiveQueueTimeInterval;
_messageLoggerEngine = new MessageLoggerEngine(_serviceConnectionString);
}
}
What can I try to resolve this?
Edit
The application exe and the folder where the json file resides in the same directory. See this image: