[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2009-04-27
23
Medium Priority
?
328 Views
Last Modified: 2013-11-26
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?  
0
Comment
Question by:mrcoulson
  • 12
  • 6
  • 5
23 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 24244011
Are you saying that Project->Add Reference->Browse Tab does not allow you to add reference?
0
 
LVL 12

Expert Comment

by:williamcampbell
ID: 24244035
If you have a makefile

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


0
 

Author Comment

by:mrcoulson
ID: 24244070
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 12

Expert Comment

by:williamcampbell
ID: 24244089
<%@ Assembly Name="AssemblyName" %>

Not sure if that works in the aspx give it a try
0
 
LVL 12

Expert Comment

by:williamcampbell
ID: 24244095
How do you build the project? Or does it just sit on a web site?
0
 

Author Comment

by:mrcoulson
ID: 24244137
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
 

Author Comment

by:mrcoulson
ID: 24244143
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
 
LVL 12

Accepted Solution

by:
williamcampbell earned 1000 total points
ID: 24244163
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
 

Author Comment

by:mrcoulson
ID: 24244331
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
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 24244435
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
 
LVL 12

Expert Comment

by:williamcampbell
ID: 24244497
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
 

Author Comment

by:mrcoulson
ID: 24244529
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
 

Author Comment

by:mrcoulson
ID: 24244915
Okay, rad.  This will work, except that there are lots of files called Default.aspx.  Darn me and my poor choices!

Jeremy
0
 
LVL 12

Expert Comment

by:williamcampbell
ID: 24245127
They must be in different folders... You can create folders in the project to emulate the file layout
0
 

Author Comment

by:mrcoulson
ID: 24250581
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
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 24255071
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
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 24255073
Previous should say "open up your projectName.csproj file in a text editor".
0
 

Author Comment

by:mrcoulson
ID: 24259860
For realz?  Checking it out.
0
 

Author Comment

by:mrcoulson
ID: 24260195
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
 

Author Comment

by:mrcoulson
ID: 24260365
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
 

Author Comment

by:mrcoulson
ID: 24260741
Sorry for the double-post!
0
 
LVL 75

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 1000 total points
ID: 24261329
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
 

Author Comment

by:mrcoulson
ID: 24264541
Great!  This clarification helps a lot.  Thanks!

Jeremy
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month19 days, 15 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question