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

2

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 tried restarting VS and the PC and nothing works.

So the problem is not in code

Could not load file or assembly 'xxx.Data' or one of its dependencies. The process cannot access the file because it is being used by another process. (Exception from HRESULT: 0x80070020)

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IO.FileLoadException: Could not load file or assembly 'xxx.Data' or one of its dependencies. The process cannot access the file because it is being used by another process. (Exception from HRESULT: 0x80070020)

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Assembly Load Trace: The following information can be helpful to determine why the assembly 'xxx.Data' could not be loaded.

=== Pre-bind state information ===
LOG: DisplayName = xxx.Data
 (Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: xxx.Data | Domain ID: 2
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/Proyectos/xxx/xxx/
LOG: Initial PrivatePath = C:\Proyectos\xxx\xxx\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Proyectos\xxx\xzxx\web.config
LOG: Using host configuration file: C:\Users\Esteban\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Users/Esteban/AppData/Local/Temp/Temporary ASP.NET Files/root/8076610e/464a474/xxx.Data.DLL.
LOG: Attempting download of new URL file:///C:/Users/Esteban/AppData/Local/Temp/Temporary ASP.NET Files/root/8076610e/464a474/xxx.Data/xxx.Data.DLL.
LOG: Attempting download of new URL file:///C:/Proyectos/xxx/xxx/bin/xxx.Data.DLL.
LOG: Using application configuration file: C:\Proyectos\xxx\xxx\web.config
LOG: Using host configuration file: C:\Users\Esteban\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
ERR: Failed to complete setup of assembly (hr = 0x80070020). Probing terminated.
c#
asp.net
.net
visual-studio-2015
asked on Stack Overflow Oct 1, 2015 by Luis Valencia • edited Jun 20, 2020 by Community

3 Answers

2

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.

answered on Stack Overflow Oct 1, 2015 by Patrick Hofman
0

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.

answered on Stack Overflow Dec 28, 2016 by veuncent
0

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..

answered on Stack Overflow Sep 10, 2019 by Thameem

User contributions licensed under CC BY-SA 3.0