views:

315

answers:

2

Normally when you add a new assembly you have to go into Visual Studio and add a reference (the .dll is stored in the /bin directory).

Since this website compiles on the fly, is it possible for me to just add the .dll to the live website, and then use that .dll in an .aspx page?

Currently in Visual Studio I can't see the .dll unless I go to 'add reference'.

+1  A: 

Yes, it's perfectly possible to change the DLL on the live Web site. Just swapping the DLL in the /bin directory will make the application bind to the new one. However, Visual Studio needs the DLL to exist at development time to provide IntelliSense and validate the Web site.

Mehrdad Afshari
+4  A: 

You can indeed reference an assembly without going through Visual Studio. Steps:

  • Drop the desired assembly (DLL) into the bin folder
  • Add <%@ Assembly Src="pathToDll" %> or <%@ Assembly Name="assemblyName" %> to the top of your ASPX page.
  • (Optionally) import the namespaces in the new assembly using <%@ Import Namespace="Foo.Bar" %> at the top of the page.

Then reference away!

Adding the reference in Visual Studio is only for compile-time support. Any static references to types in your non-ASPX code (e.g. codebehinds) must be resolved by the compiler, so all DLLs obviously need to be present. Since ASPXs are usually compiled on the server at request time, as long as the referenced DLLs are available then, everything will come together.

Rex M