0

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?

2 Answers 2

11

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.

Sign up to request clarification or add additional context in comments.

Comments

2

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.