How can I add reference to a DLL in Visual Studio if there's no Solution?

I have recently begun securing some of our applications here and there with Microsoft's Anti-XSS library.  When I have a Solution in VisualStudio, I just choose "Add Reference..." and put it in the Solution.  Easy.

But before I really knew how to use VisualStudio (like I really know it now?), I never made Solutions; I just went in and created ASPX files and CS files and so on.  Now I need to use the Anti-XSS classes in some of these non-Solution ASPX and CS files.  How can I add reference to a DLL when there's no Solution?  
mrcoulsonAsked:
Who is Participating?
 
williamcampbellCommented:
NO. Why don't you just bite the bullet and create a solution for these lonely files

New Project. Add Existing Item. Save Done.
0
 
käµfm³d 👽Commented:
Are you saying that Project->Add Reference->Browse Tab does not allow you to add reference?
0
 
williamcampbellCommented:
If you have a makefile

csc.exe /reference:System.Drawing.dll MyStuff.cs


0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
mrcoulsonAuthor Commented:
kaufmed: Correct.  Well, there's nothing available under Project because there is no project.  It's just Default.aspx and Default.aspx.cs without a project.

williamcampbell: I don't know what that is.  Can you illuminate further?

Jeremy
0
 
williamcampbellCommented:
<%@ Assembly Name="AssemblyName" %>

Not sure if that works in the aspx give it a try
0
 
williamcampbellCommented:
How do you build the project? Or does it just sit on a web site?
0
 
mrcoulsonAuthor Commented:
I'll give that a shot.  

These files just hang out and aren't built.  When I first got VisualStudio, I didn't know anything about working in projects.  All of the stuff I do now is in projects, but I have old stuff that remains in plain ol' files and it's probably something I'll never get to fix.

Jeremy
0
 
mrcoulsonAuthor Commented:
Actually, the solution seems to have been just putting it in a bin folder in the same folder as the aspx and cs files.  

Any reason why that's bad?

Jeremy
0
 
mrcoulsonAuthor Commented:
Because I've always assumed that would involve moving them and then telling everyone to update some links.  Can I really just build a solution called "Orphans" and add all of these lonely files to it without moving them???  That'd be great.

Jeremy
0
 
käµfm³d 👽Commented:
Just for clarification (because I was confused at the beginning of the thread), loosely:

A project is an application, dll, website/app
A solution is a group of one or more projects.
0
 
williamcampbellCommented:
So I assume all the ASPX and cs files belong to the same web site?

If this is correct then you can create a new "Web Site Project"
Then you can Click "Add Existing..." and all the orphans to the project
You then Right Click References and add your security DLL

No need to move them.



0
 
mrcoulsonAuthor Commented:
kaufmed: Thanks.  I have always erroneously interchanged the terms.

williamcampbell: Right, they're all on the same website.  I will definitely try this after a meeting I'm about to attend.  It would be nice to be able to handle these old orphans without actually moving them.  Thanks for the awesome tip!  Stand by for about 45 minutes or an hour and I will probably have some success!

Jeremy
0
 
mrcoulsonAuthor Commented:
Okay, rad.  This will work, except that there are lots of files called Default.aspx.  Darn me and my poor choices!

Jeremy
0
 
williamcampbellCommented:
They must be in different folders... You can create folders in the project to emulate the file layout
0
 
mrcoulsonAuthor Commented:
Okay, I've tried this.  When I create the new folder under the solution and then add an existing item, it copies the file into a folder.  For example, I have a page called /comment_card.aspx.  When I add it to the project, it copies to /apps/orphans/Comment_Card/comment_card.aspx.  And then when I edit that file in VS, I'm changing the second one, but not the live one that's linked on other pages.

Jeremy
0
 
käµfm³d 👽Commented:
You could open up your projectName.csproj file in a text and manually change the locations of the files. Then the next time you open the project in VS, the originals will be used.
0
 
käµfm³d 👽Commented:
Previous should say "open up your projectName.csproj file in a text editor".
0
 
mrcoulsonAuthor Commented:
For realz?  Checking it out.
0
 
mrcoulsonAuthor Commented:
Okay, I've tried it.  When I change

<ItemGroup>
    <Content Include="Comment_Card\commentCard.aspx" />

to

<ItemGroup>
    <Content Include="..\..\commentCard.aspx" />

and then try to do any work, VS hangs up.  Clearly, I need to change more stuff in that XML.  I have verified that it's pointing to the right file.  The full path in the properties box is correct: X:\commentCard.aspx.


Jeremy
0
 
mrcoulsonAuthor Commented:
Okay, I've tried it.  When I change

<ItemGroup>
    <Content Include="Comment_Card\commentCard.aspx" />

to

<ItemGroup>
    <Content Include="..\..\commentCard.aspx" />

and then try to do any work, VS hangs up.  Clearly, I need to change more stuff in that XML.  I have verified that it's pointing to the right file.  The full path in the properties box is correct: X:\commentCard.aspx.


Jeremy
0
 
mrcoulsonAuthor Commented:
Sorry for the double-post!
0
 
käµfm³d 👽Commented:
Yeah, you have to check for all files related to a given object. For example, I have a LoginBox.cs form in one of my projects. Forms have 3 files associated with them: .cs, .designer.cs, .resx. I would need to find those 3 files in .csproj file and modify their paths:


(Below is an example demonstrating a forms project)
From:
    <Compile Include="LoginBox.cs">
      <SubType>Form</SubType>
    </Compile>
    <Compile Include="LoginBox.Designer.cs">
      <DependentUpon>LoginBox.cs</DependentUpon>
    </Compile>
//Elsewhere
    <Compile Include="Properties\AssemblyInfo.cs" />
    <EmbeddedResource Include="LoginBox.resx">
      <DependentUpon>LoginBox.cs</DependentUpon>
    </EmbeddedResource>
 
 
To:
    <Compile Include="..\LoginBox.cs">
      <SubType>Form</SubType>
    </Compile>
    <Compile Include="..\LoginBox.Designer.cs">
      <DependentUpon>LoginBox.cs</DependentUpon>
    </Compile>
// Elsewhere
    <Compile Include="Properties\AssemblyInfo.cs" />
    <EmbeddedResource Include="..\LoginBox.resx">
      <DependentUpon>LoginBox.cs</DependentUpon>
    </EmbeddedResource>

Open in new window

0
 
mrcoulsonAuthor Commented:
Great!  This clarification helps a lot.  Thanks!

Jeremy
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.