How do I include System.Windows.Shapes? - c#

I am using Visual Studio 2008 with the .NET Framework (v3.5). I cannot seem to use System.Windows.Shapes, or anything System.Windows.* besides Forms.
Here is the link to the class description:
System.Windows.Shapes (MSDN Library)
Is there some special thing I need to do to use it?
I checked in all of the framework folders, and the only dll/xml files I have for System.Windows is System.Windows.Forms.
What do I need to do to get this to work?

This class is part of WPF, from MSDN:
Shape Class
Assembly: PresentationFramework (in presentationframework.dll)

You need to add a reference to the PresentationFramework library.
In VisualStudio, right click on your project in the "Solution Explorer". Select "Add Reference". The "PresentationFramework" library will be under the ".NET" tab. You may also need to add "PresentationCore" and "WindowsBase".
You can see your project's current library references by going to the "Solution Explorer" and expanding the "References" item.

You may need to add a reference to the library, probably System.Windows.Presentation
Edit: It is in the PresentationFramework library

Add reference to PresentationFramework from .Net tab
write using System.Windows.Shapes
and you are done!

Other solution that works in .Net 4.0:
Go to referenes->add reference and choose PrsentationFramework under .NET tab.

Related

Using System.Web in Xamarin android (xamarin.android.dll)

I am pretty new to android development and using Xamarin for now.
All looks nice, however as soon I try to use HttpUtility.UrlEncode or HttpWebRequest I need the System.Web.
If I add the System.Web to the references its not being accepted.
Some research gives me the idea that xamarin.android.dll should have the System.Web.dll however I have no idea where to find this one.
Does anybody know how to solve this so HttpUtility and HttpWebRequest will be available in my android project?
Any help would be very appreciated!
HttpWebRequest is part of the System.Net assembly while HttpUtility is part of the System.Web.Services assembly.
(Xamarin Studio).
To add those to your project, simply right click the References folder and choose Edit references
In the Edit references dialog you simply make sure the checkbox is checked for System.Net and System.Web.Services.
(Visual Studio)
Right click the References folder and choose Add reference. Next scroll down the list in the Assemblies -> Framework tab and make sure the checkbox is checked for System.Net and System.Web.Services.
HttpWebRequest is included in the System.Net namespace (System dll), and HttpUtility is in the System.Web namespace (requires System.Web.Services dll).
For a reference of which namespaces are available, and which dll they live in, see Assemblies.
Uri.EscapeDataString or Uri.UnescapeDataString may also be an option.

cannot use Microsoft.Office.Interop.Word

I'm trying to use the namespace Microsoft.Office.Interop.Word and implement the code here
But Office is marked with a zig-zag red line as a not identified type
Any one know how should I include this library ?
You can get and include the interop assemblies from here:
http://www.microsoft.com/en-us/download/details.aspx?id=3508
You need to add a reference in your project. Go to Solution Explorer, right-click "References", choose "Add reference..." and pick the appropiate reference, e.g. Microsoft.Office.Interop.Word.
You should have Microsoft office installed on your machine

Why don't I find the System.Windows.Controls namespace in my object browser in Visual Studio?

Why don't I find the System.Windows.Controls namespace in my object browser in Visual Studio?
You have to reference the PresentationFramework assembly from Microsoft because you are trying to use a WPF namespace.
If you set up a WPF project from scratch it should be included. When you start in VS with some other project type you might need to add this reference by hand. Right-click the references node under your project add select Add Reference. Then in the dialog that pops up you go to the tab page called .NET and browse for the right assembly.

Missing System.Web.UI and System.Web.Security

I can't compile a project because the namespaces System.Web.UI and System.Web.Security are missing. I can only see System.Web.ApplicationServices, System.Web.Mvc and System.Web.Services when I do add references. Where do I download the missing namespaces?
Go to menu Project -> Add reference and find out the System.Web.dll in the list
I don't know about System.Web.UI, but System.Web.Security moved to the System.Web.ApplicationServices assembly in .NET 4.0 Framework.
Following Kinderchocolate's suggestion, I switched to ".Net Framework 4" in my project's Properties (VS 2010), and that caused "System.Web" to appear in the assemblies list. From then on I was finally able to use System.Web.UI.
So I'm not sure what failed for kinderchocolate, but his change worked for me.
You can add System.Web.ApplicationServices assembly in .NET 4.5 Framework.
using System.Web.ApplicationServices;
Yes, Kinderchocolate is correct. Once you add the Reference System.Web to your project, then in the code you can add using System.Web.UI and all sub-components of System.Web.UI, e.g. System.Web.UI.HtmlControls.
you can go to : project -> proprieties -> and change the Framework from Client profile to .Net 4, if it doesn't work you can add the reference manually. Good luck
Add references System.Web.Extensions and System.Web.Extensions.Design in 4.6.1
if you miss ListView or LinqDataSource

System.Web.Hosting not found in VS2008

I am trying to make a Cassini-like server for a particular asp.net web application. The Client is not happy with the Cassini interface, so I am just expanding the Cassini code, adding new features, and providing a fresh look to the UI.
Now the problem I am facing is, all the files from Cassini source use the System.Web.Hosting namespace. Visual Studio throws me an error saying:
The type or namespace name 'Hosting' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)
What am I missing here? I have already written
using System.Web.Hosting;
in the first line of the .cs file. I am using .Net FW 3.5 and VS2008.
Any help would be seriously appreciated.
Thanks.
Most likely, your project is targeting the "Client Profile" version of the .NET Framework, which doesn't include the System.Web.Hosting namespace.
You need to change your project to target the full version of the framework, and then add a reference to System.Web. To do this, follow these steps:
Open your project Properties by double-clicking on "Properties" in the Solution Explorer.
From the drop-down box labeled "Target framework," choose ".NET Framework 3.5". Visual Studio will inform you that this requires closing and re-opening your project, so make sure that it is saved first before clicking "Yes".
When your project re-opens, right click on "References" in the Solution Explorer, and select "Add Reference" from the context menu.
Find the item named "System.Web" under the ".NET" tab in the resulting dialog box, and click OK.
You have to add the System.Web reference to the project.

Categories