PDA

View Full Version : adding class library reference to ASP.NET web site project


chump2877
08-26-2007, 06:43 AM
I can't figure out how to add a reference to a class library inside of an ASP.NET web site project in Visual Studio 2005.

I tried building the class library project, and then referencing the resulting .dll file in my new ASP.NET web site (this put a .dll and .pbd file into a folder called Bin in my new project)....but that isn't working. When I try to add C# code to the Global.asax file, it says I'm missing a using statement or assembly reference, and Intellisense doesn;t recognize any of the class library types...I tried adding a using statement in the Global.asax file, and that didn;t work either...

Can anyone help? Thanks.

ess
08-26-2007, 11:02 AM
1- From the project menu, select "Add Reference"
you will be prompted with the add reference dialog
2- Click on the browse button to locate your Class library (usually, a DLL file)

once you have done that, you should see a reference to your class library in Solution Explorer window.

cheers,
Ess

chump2877
08-26-2007, 07:46 PM
once you have done that, you should see a reference to your class library in Solution Explorer window.

I already tried that previously... What will this reference look like in Solution Explorer (Or, what does it look like for you)? Is it supposed to look something like this:

and then referencing the resulting .dll file in my new ASP.NET web site (this put a .dll and .pbd file into a folder called Bin in my new project)....


And is there a certain kind of .dll file that you need to create for inclusion in an ASP.NET web site project (my new web site was created by selecting File->New Web Site from VS2005's main menu)? All I did was build the project containing my class library files, and then reference the resulting .dll in the add reference dialog box (in my new ASP.NET web site project)...If I hadn't of done that (build the class library project), I would not have had a .dll file at all...

Also, after doing this, I was not able to access the resulting, questionable class library (assembly) reference using C# code inside my new ASP.NET web site project (the .dll is now sitting in the project's Bin folder):

When I try to add C# code to the Global.asax file, it says I'm missing a using statement or assembly reference, and Intellisense doesn;t recognize any of the class library types...I tried adding a using statement in the Global.asax file, and that didn;t work either...

I'm sorry if I was not clear enough in my first post. Thanks.

chump2877
08-26-2007, 08:06 PM
I even tried embedding the needed class files directly into the ASP.NET web site project (using Solution Explorer in VS2005), but this did not work either...

I just can't seem to reference the types at all in my web site project's Global.asax file, no matter what I do...

Brandoe85
08-28-2007, 07:58 PM
Once you click on the website menu item -> add reference you should be able to browse to your dll and click add. The solution explorer should then update to show your dll.

I know this was stated by ess and you did try it but just making sure.
Maybe you want to send off your dll and I can give it a shot.

chump2877
09-02-2007, 03:44 AM
The problem is that VS2005's ASP.NET web site projects are bogus....

This problem is eliminated if you create an ASP.NET web application project instead, and add a reference to the class library in there....Also, if I remember correctly, the global.asax file in a web application project is a C# file, whereas it is an .aspx file with <script> tags in a web site project...So you can add assembly references in your global.asax file for a web application project (with a using statement), but not for a web site project.

I think I got that right. Anyway, I've learned my lesson. After all of the angst that I went through trying to figure this out, I doubt I will ever create a VS2005 Web Site project again. Creating a new Web Application project is the same thing, minus the headaches.

Thanks for try to help.