Could not load file or assembly 'xxx.Data' The process cannot access the file because it is being used by another process

后端 未结 3 1293
渐次进展
渐次进展 2021-01-22 14:37

I have this error since today in a project which I have worked for months and has always worked.

I tried cleaning the solution and rebuild, and building works perfect. I

相关标签:
3条回答
  • 2021-01-22 14:55

    I wanted to share my scenario here if it helps someone. I set an interval in javascript for two different functions calling the same function on the server side each differentiated with a just one parameter. Then OS threw the above error

    The process cannot access the file because it is being used by another process

        [WebMethod]
        public List<Notifications> GetNotifications()
        {
            return objCommonModels.GetNotificationsData(1);
        }
    
        [WebMethod]
        public List<Notifications> GetOTPNotifications()
        {
            return objCommonModels.GetNotificationsData(2);
        }
    
            //Javascript
            setInterval(LoadNotifications, 3000);
    
            setInterval(LoadOTPNotifications, 3000);
    

    Then i seperated the two functions to make them unique... I didn't have faith in differentiating the timer seconds in JS... HOPE IT HELPS SOMEONE..

    0 讨论(0)
  • 2021-01-22 15:10

    As the message says, the file is in use. This isn't a Visual Studio or .NET thing, it is an operating system thing.

    Another program is using the file, that can be a virus scanner, another application that is running, or even Visual Studio (sometimes the debugger keeps a file locked).

    Windows tells you what program is responsible for the lock when you try to delete or rename the file. I would recommend to do that to see what program is locking your file.

    0 讨论(0)
  • 2021-01-22 15:17

    Another scenario where you will see the 'in use by another program' error is when you try to enable or create Entity Framework migrations, while you did not build your project after you made changes to models or a database context.

    Just build the solution and the error goes away.

    0 讨论(0)
提交回复
热议问题