Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to load referenced library

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.

like image 744
mika Avatar asked Dec 21 '25 09:12

mika


1 Answers

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.

like image 137
Ian Robinson Avatar answered Dec 24 '25 01:12

Ian Robinson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!