I have an ASP.NET Core application. The application needs to be started by windows service. When the service runs the application, I'm having the following error:
InvalidOperationException: The view 'Index' was not found. The following locations were searched:
/Views/Home/Index.cshtml
/Views/Shared/Index.cshtml
EnsureSuccessful
MoveNext
ThrowForNonSuccess
HandleNonSuccessAndDebuggerNotification
MoveNext
ThrowForNonSuccess
HandleNonSuccessAndDebuggerNotification
MoveNext
MoveNext
ThrowForNonSuccess
HandleNonSuccessAndDebuggerNotification
MoveNext
MoveNext
ThrowForNonSuccess
HandleNonSuccessAndDebuggerNotification
MoveNext
ThrowForNonSuccess
HandleNonSuccessAndDebuggerNotification
MoveNext
ThrowForNonSuccess
HandleNonSuccessAndDebuggerNotification
MoveNext
However, if I run the application by clicking on the exe-file, everything seems to be normal. I double checked, the service had enough permissions, and the views are in the right place.
BUT! I had a situation when the service was looking for another file somewhere in win32 folder, because I had made a mistake and used Directory.GetCurrentDirectory() instead of Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) to find the current folder. Is it possible that the similar mistake had been made?