Unable to load referenced library

10,076

The error occurs after I compile the solution and copy all the projects' dlls to the /bin with a script. Visual Studio does not let me recompile, but if I restart it, everything works ok.

I would suggest setting the output directory of each of your projects to be the bin directory of the DotNetNuke website. This will help you to avoid the manual step of copying files altogether.

To set the output directory of your project: Right click on your project in Solution Explorer and select properties. Select the build tab, select All Configurations (at the top) and set Output Path to "..\..\bin" (near the bottom). This assumes your project file is in it's typical spot within the module's home directory (e.g. DesktopModules/YourModule/YourProject.csproj) otherwise you can navigate to your web site's bin directory with the adjacent browse button.

Share:
10,076
mika
Author by

mika

An experienced developer and a business person. I'm currently working as a COO in a small SaaS company. My day job includes pretty much everything in running the tech side of the business: development management infrastructure management product development occasional consulting, mostly integrations to our app digital marketing (yes, this is mostly tech)

Updated on July 13, 2022

Comments

  • mika
    mika almost 2 years

    I get this error in Visual Studio 2008 when developing a ASP.NET Web Application Project.

    Unable to load referenced library 'Path-to-DotNetNuke\bin\file.dll': The process cannot access the file because it is being used by another process.

    This is a DotNetNuke project with multiple modules. IIS loads all assemblies from /bin folder under the application root.

    The projects in the solution are in their respective /DesktopModules/ProjectName folders and compile to a bin folder under the project.

    The error occurs after I compile the solution and copy all the projects' dlls to the /bin with a script. Visual Studio does not let me recompile, but if I restart it, everything works ok. This is really annoying when recompiling and testing the whole solution. You have to restart Visual Studio between every recompile.

    I couldn't find any file locks with Process Explorer when Visual Studio shows this error.


    [UPDATE] There is an old MSDN document that tells you not to build all DLLs to a single folder if you reference any over 64KB DLL there. Particulartly, the document says:

    It causes the build process to fail with file lock errors when a referenced assembly exceeds 64 KB in size.

    We do have references to over 64KB DLLs in /bin folder and copying recompiled DLLs there seems to trigger this, at least with VB IDE's background compiler.