views:

238

answers:

2

I need to use some classes inside the app_code folder of a website project in visual studio 2008. I need to access this code from a class library project in the same solution. I cannot add a reference to the website, and I'm not sure of the easiest way to use the classes that already exist here. Do I need to move it to a class library?

What other options do I have?

+11  A: 

Yes, create a class library and move any types you need into that library. This library can be referenced in as many places as you would like.

Andrew Hare
+1  A: 

The best way to do this is to put those classes in their own library.


However, if you really don't want to do that, you could add a link to the files in the library project. To do that, right-click the Class Library project or a folder within it, Add, Existing Item, navigate to the code files, click the down arrow near the Add button, Add As Link. This will add the same file to both projects. You can even use the #if preprocessor directive to limit portions of the file to specific projects.

However, it is vastly preferable to put the code in a library and reference it in the web project.

SLaks