0

I use Visual Studio 2019.

enter image description here

This error is appearing again and again while adding an ASP.NET MVC 5 controller with views using Entity Framework, I have tried many ways it doesn't remove.

My code:

namespace SingletoninMVC.logger
{
    public sealed class Log : ILog
    {
        private Log()
        {
        }

        private static readonly Lazy<Log> instance = new Lazy<Log>(() => new Log());

        public static Log GetInstance
        {
            get { return instance.Value; }
        }

        public void LogException(string message)
        {
            string fileName = string.Format("{0}_{1}.log", "Exception", DateTime.Now.ToShortDateString());
            string logFilePath = string.Format(@"{0}\{1}", AppDomain.CurrentDomain.BaseDirectory, fileName);
            StringBuilder sb = new StringBuilder();
            sb.AppendLine("----------------------------------------");
            sb.AppendLine(DateTime.Now.ToString());
            sb.AppendLine(message);

            using (StreamWriter writer = new StreamWriter(logFilePath, true))
            {
                writer.Write(sb.ToString());
                writer.Flush();
            }
        }
    }
}
Jackdaw
  • 7,626
  • 5
  • 15
  • 33

1 Answers1

0

Based on my test, I reproduced the same error with you.

Also, I found the solution. You could try to rebuild your project before you add the controller with views using entityframework.

It works well for me.

Jack J Jun
  • 5,633
  • 1
  • 9
  • 27