Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.net Bin directory - dll loading

Tags:

asp.net

dll

I need to use a dll in my asp.net application. How do I load a dll not from a bin directory?

Perhaps I should mention that the application is a mixture of asp code and asp.net code. so, when I develop it on my machine, I place a dll in the bin directory, but after I move the code to the live environment, I don't want to have a separate bin directory for every piece that's using asp.net.

All I am moving is .aspx and .aspx.cs files. Is there a way to load a dll NOT FROM /bin (specify it with "using" statement)? Looks like it automatically looks in the /bin....

like image 258
sarsnake Avatar asked Jan 22 '09 17:01

sarsnake


4 Answers

You can either place the DLL in the bin folder of the root of your application, or install it to the Global Assembly Cache (GAC) using gacutil (which requires the assembly to be strong-named and signed).

I would just keep it in the bin.

like image 65
John Sheehan Avatar answered Nov 12 '22 08:11

John Sheehan


.net app looks in the /bin of the project, and the GAC (Global Assembly Cache) where you put system shared DLL-s.

If your app is one .net app (configured in IIS as one app), but you have aspx files in subfolders, they should see the root /bin folder. i'd stick with keeping dlls in /bin, if that isn't several tenths of bins (which would mean that you have a problem with your app organization).

like image 35
zappan Avatar answered Nov 12 '22 09:11

zappan


GAC and bin are the only usual options.

You might also be able to configure your other folder as an additional bin folder, but I wouldn't hold my breath — this is from 1.1 and you still need to be within the same vdir as the main application.

like image 1
Joel Coehoorn Avatar answered Nov 12 '22 08:11

Joel Coehoorn


Simply add the other dll's directories to your path environment variable. Must restart asp.net process / visual studio for the change to take effect. Worked for me.

like image 1
Matt H Avatar answered Nov 12 '22 08:11

Matt H