I can't add a using reference on my C# application - c#

I'm using Visual Studio 2010 Beta2 and I can't add a reference to:
system.drawing
I've tried right click on the solution explorer but I can't find it there.
What gives?

Here is all you need to do in VS 2010:
In Solution Explorer right click on the References folder of your project
Select Add Reference.
Under the Assemblies category there is a sub category of Framework. If that is selected you should see a list of all of the Microsoft .NET Framework libraries
Find System.Drawing and double click it.
Then your project will have the reference added to it!

In VS2010 Beta 2 the references list may not be automatically sorted because it loads asynchronously. You may need to wait for it to finish loading then click the column header to sort.

Solution explorer is for adding references to external libraries.
It sounds like you just want to add the line
using System.Drawing;
to the top of one particular file.

Related

References c# visual Studio

I have been working on this project in Visual Studio 2010 using C# a few days before Windows 10 update and it worked fine but now when I try to run the program and it tells me the following :
The type or name of the 'Drawing' namespace does not exist in the
'Tekla.Structures' namespace (missing an assembly reference?)
and the same for Tekla.Structures.Model, Tekla.Structures.Model.Operations ... as you can see in the following image:
What I am doing is removing the references and adding them again and in this way the program recognizes it well, but if I clean the solution and try to generate the solution again, the problem arises again ...
What could be the problem?
It seems that you want to use Tekla reference correctly.
I suggest that you can use NugetPackage.
First, right click->References->choose Manage Nuget packages.
Second, choose the Browse->input 'TeklaOpenAPI' in textbox and choose the first.
Third, click install.
Finally after it has been installed, you will see the following correct using code without warning.
first you remove tekla references, select and right click, then remove
remove reference
after right click on References and add reference
add references
after you need add dll corresponding the version you want execute
select references
pay attention when building the app, it only runs in the version you chose the dlls.

"Peek/Go to definition" jumps to partial declaration in a tab named as "xxx[from metadata][Read only]" [duplicate]

I have a C# project which contains references to assemblies in DLL format. I have the PDB information for these DLL files, contained in the same folder. When I press F12 on a referenced member, I want to go to the definition of the member. Instead, it gives me the metadata, which of course I don't want.
When VS is debugging, it does go to the source code if I single step into that method. But if I press F12 on that method, it still brings me to the metadata.
There is a similar question here, but it only applies to project references, and the accepted solution has nothing to do with my issue.
"Go To Definition" in Visual Studio only brings up the Metadata
To summarize:
Referenced project is a DLL
I have the PDB information
Single-stepping in debug-mode brings me to the source code
F12 brings me to metadata
I want F12 to bring me to the source code as debug does.
EDIT: Adding as a "Project" is not an option as it creates additional complexity as our solution file references about five other projects which are all under separate source control repositories.
In Visual Studio expand the References section, select the reference to your related project (the one that contains the source code you want to F12 into) right click on it and select "Remove".
Then add the reference back to the project by right clicking on References and selecting Add Reference, under the Projects tab (if your using VS 2012) select (or browse for) the project you want to add a reference to and then click the OK button.
This will rebuild the reference and you will be able to F12 into the referenced projects source code. You will need to do this with all the projects in your solutions that are having this issue.
I don't know why this happens but at least the solution to the problem is rather simple
If you have ReSharper installed, you should bring up ReSharper options, and look for External Sources. There you can specify the relevant options:
It appears that this issue has been solved in Visual Studio 2013. Having the PDB information in the same folder as the DLL is showing me the source code when I use Go To Definition. I do not have the Reflector extension installed.
Is the referenced DLL a project in your solution? I find that when I have the source code for the project, and it's in my solution, Visual Studio is able to link to this code much more easily. (without showing me meta data).
Also, be sure to add the reference by "Project" in the References popup.
This is generally what I do anyways when I have this problem
Hope this helps!
PS. PDB files are usually just for debugging (both locally and remote) and are not used for source code reading in the way you are attempting to use it. ("Go To Definition")
One solution to this issue is to use .NET Reflector, VS or VSPro edition. This program will modify Visual Studio to provide the required functionality.
http://www.reflector.net/
Unfortunately, it costs $135 to $195, which isn't an option for everybody.
Add the reference as a project instead of ..\bin\Debug\referenceFile.dll
That solved my issue
I also used add reference as a project and my problem has been resolved and it's working great. Actually I was stuck at this point from very long time and finally i resolved this issue.
References -> Add References -> Solution -> Projects -> Select reference

Adding Microsoft.DirectX.DirectInput To Visual Studio 2013 Express for Windows Desktop

I am trying to use some classes from the Microsoft.DirectX.DirectInput namespace, in the past if there was a namespace I couldn't use in my project I would just go to references and add the file with that name to my project, except that I cannot find the file in the list.
How can I use this namespace?
Found the answer at https://social.msdn.microsoft.com/Forums/en-US/2a08e16f-e05b-412e-b533-4b91f11db864/erorr-in-loading-directx-reference?forum=gametechnologiesdirectx101 Following the C:\Windows\Microsoft.NET\DirectX for Managed Code\1.0.2902.0 path, I was able to find the DLL I needed. Then just went to references > add reference > browse (the one at the bottom next to OK) then found the DLL.

Visual Studio Does not recognize System.Linq

I created this program and C# and it worked correctly a few weeks ago.
Now, I copied all of this code to a another project I am working on. I added it to a brand new C# Class inside of the project I am working on. Visual Studio didn't recognize the assembly references that say "not found" in the comments.
This is just bizarre since they were found in the previous program. Does anyone know why Visual Studio can't find these assembly references.
using System;
using System.Collections.Generic;
using System.Linq; //not found
using System.Text;
using XML_Creator; //not found
using System.Xml.Linq; //not found
using System.IO;
An educated guess: It's probably the .NET framework target version of the new project.
System.Linq was introduced on .NET Framework 3.5.
Go to Project -> Properties -> Application and check the Target Framework property. It's probably a target framework prior to 3.5
You need to add refrence to system.Core.
Step 1) Go to your Project Solution Explorer and Select
References
Step 2) Right click it on References and Select Add Reference... a form will appear
Step 3) Search linq on Search bar
Step 4) Now Select/tick the System.XML.Linq checkbox
Step 5) Click Ok
If your file is in App_Code folder, try moving it to another folder. For me its solved the problem.
You need to right click on the solution in Solution Explorer and add a reference to System.Xml.Linq and/or System.Linq in Project Properties.
This has hit me several times - I see it a lot with System.Configuration as well. (For some reason those two references seem to be particularly picky)
For me I tried this and worked:
PROJECT==>Add Reference ==> Browse ==>
C:\Windows\winsxs\x86_netfx35linq-system.core_31bf3856ad364e35_6.1.7601.17514_none_6161fc35ed136622\System.core.dll
Or
you can simply find the System.core.dll using windows search on Os System Drive
I had a similar issue. I upgraded my asp.net project to .NET Framework 4.5.x and it worked. I did tried 4.5.1 first and then later 4.5.0 and both seem to be helping.

what namespaces are needed for this piece of code? (c#)

Image Dummy = Image.FromFile("image.png");
Dummy.Save("image.bmp", ImageFormat.Bmp);
what the question says
i have these
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
but i get an error saying that the namespace drawing does not exist in the namespace system :/
Add a reference to System.Drawing
When you use using statements, this lets the compiler know that when you say Image you really mean System.Drawing.Image for example.
However, now the compiler needs to know where System.Drawing is. By default, in Visual Studio, you will probably already reference System, System.Data, and System.Xml.
Now you are writing for System.Drawing. Right-click the project in the project browser, and select "Add reference...". This will present you with a tabbed interface that lets you select one of:
A .NET Reference. Any assembly in the GAC will be listed here. Scroll down and select System.Drawing for example.
COM Reference. For interfacing with non-.NET, yet very Windows components.
Projects. A Visual Studio nicety. Reference a DLL that has not been built yet. Select a project within the same solution. Intellisense before you compile.
Browse (for a file). If a .NET component or other type with exported definitions has already been built, you can reference the DLL from here.
Adding the "using" is only part of the equation. You also have to reference the DLL which contains the code you want to use.
For example, if you write a cool library under the namespace com.shuttleu.awesomelib, I could have the following at the top of my C# file:
using com.shuttleu.awesomelib;
On its own, that won't do me any good, I have to reference the DLL (referred to as an "assembly") in my project. You do that by right-clicking the project and selecting "Add Reference..."
In addition to the using statement, you also need to add the System.Drawing DLL (called an 'assembly') as a reference in your Visual Studio project. To do that, in the Solution Explorer pane usually at the right (if it's not open, go to View --> Solution Explorer), right click References and click Add Reference. In the .NET tab (open by default), scroll down until you see System.Drawing, select it, and click OK. After doing that, System.Drawing should appear under References in the Solution Explorer, and the using statement will now point to the correct DLL, therefore your code will work. :)
"Adding the "using" is only part of the equation. You also have to reference the DLL which contains the code you want to use"
Just curious--why do we have to do both for a console app, while in an VB.Net web app, the text "Imports System.Drawing" is sufficient?

Categories