drzounds
drzounds

Reputation: 379

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 ?

Upvotes: 0

Views: 2264

Answers (2)

drzounds
drzounds

Reputation: 379

Ok it works now I just added the Dll I wanted to reference to the bin and then added one more import namespace tag. I was confused because I thought I would have to specify a path, but not if the DLL is in the bin.

Upvotes: 2

Jon Skeet
Jon Skeet

Reputation: 1502086

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.

Upvotes: 0

Related Questions