How to reference a DLL in scripted ASP.NET

So I have a ASPX page that we have been using like classic ASP because we do not have access to the code behind the file. All of the C# code is nested inside the ASPX page between <% %> before the <html> tag begins. I need to reference an external DLL in order to do what I need to do. I noticed at the beginning of the ASPX there are some .NET references made.

<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Web.Script.Serialization" %>

Is there any way I can use a similar type of tag in order to reference a custom DLL ?

Jon Skeet
people
quotationmark

Those are importing namespaces - that's not the same as adding a reference. (Assemblies and namespaces are different.)

You should be able to just add an assembly reference to the project in the normal way, in the "Project References" part of solution explorer. At that point, you should be able to import any namespaces that the assembly provides using the syntax you've already shown.

This is assuming these are .NET assemblies, of course. If you're trying to add a reference to a native DLL, you'd need to use P/Invoke just as with any other native DLL interop.

people

See more on this question at Stackoverflow