Including system.windows.shapes, can't find presentationframework.dll - c#

I am using Visual Studio 2010 and trying to use the Line class in System.Windows.Shapes.
Via this link I found out how it should be done (using the presentationframework.dll), but I can't find it anywhere. When I click References > add reference > .NET, it says
Filtered to .NET Framework 2.0
So I thought that I didn't have the up to date framework, but even after installing .NET framework 4.5, it still says that it is somehow filtered...
There must be a really simple solution that I'm not seeing, right?

You need to change the target framework of your project. Just because you install the framework doesn't mean your project is automatically using it.

Try to delete the references and add it again, check whether your project is using the same framework version.
You can download from Microsoft .NET Framework 4

Related

Cannot target .Net 2.0 in Visual Studio 2015

I have a project that targets both .Net 2.0 and .Net 4.5. I built+published it successfully in Visual Studio 2013. The .Net configuration in the .csproj file still says
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
Yet, when I open the project in VS 2015, it targets .Net 4.5.
I have 2.0 available in the Target Framework dropdown:
when I click ".Net Framework 2.0" it gives me a popup saying
Changing the target framework requires that the current project be closed and then reopened.
Any unsaved changes within the project will be automatically saved.
Changing Target Framework my require manual modification of project files in order to build.
Are you sure you want to change the Target Framework for this project?
When I click yes, the target framework goes back to 4.5 and nothing else happens.
I've tried reopening the project and VS, with no luck.
I've tried running the .Net 3.5 installer (which apparently includes 2.0), but it says I need to use "Turn Windows Features on/off"
I've ensured the .Net 3.5 Windows Feature is enabled.
And now I'm out of ideas. Has anyone else encountered this?
Running Windows 7.
In case, the .NET Framework 2.0 is corrupted, use the .NET Framework setup verification tool: https://blogs.msdn.microsoft.com/astebner/2013/11/06/net-framework-setup-verification-tool-and-cleanup-tool-now-support-net-framework-4-5-1/ to verify and once it found any corrupted, you can use the .NET Framework Repair Tool: https://www.microsoft.com/en-us/download/details.aspx?id=30135 to repair it.
Or under ‘Turn Windows Features on or off’, uncheck .NET Framework 3.5 (includes .NET 2.0 and 3.0), then check it.
As Hans Passant mentions in the comments, I apparently(?) edited the .csproj to use different frameworks for different configurations. I swear this didn't cause any issues in VS 2013.
But in any case, I verified using ILSpy that the .dll being generated is .Net 2.0, even though the dropdown says 4.5. So I guess all's well that ends well?

Trying to add a project targeting .NET 3.5 to an existing project targeting .NET 4.0

I'm trying to integrate SharpVoice, which is targeting .NET 3.5 into an existing project targeting 4.0 Client Profile and I'm getting an error where it cannot find the namespace of SharpVoice.
The type or namespace name 'SharpVoice' could not be found
I read online that it could be because they are targeting different .NET versions, but when I try to change the SharpVoice target to .NET 4.0 Client Profile, I get a bunch of errors.
I also read that it is possible to integrate older versions of .NET in the newer ones, but it's not working.
Has anyone come across this problem and how did you fix it?
Found it.
SharpVoice references System.Web (here, line 7) which is only available in the full framework. Client Profile doesn't allow that.
So, you have two choices. Either rework SharpVoice to no longer have a dependency on System.Web OR retarget your main application from Client Profile to instead use the full framework.
I think the second option is going to be far easier to do as removing System.Web appears to require a complete rewrite of that code. Note that changing your main app to use the full framework means you can leave the original google code in .net 3.5.

easiest way to convert .NET project from 4.5 to 4.0?

I have a .NET application that I built in 4.5, which has references to a bunch of libraries that were built in 4.5, which themselves have references to 4.5, etc. A user group that I'm trying to distribute the application to is having problems running the executable because they have 4.0 installed; in particular, they're getting a MissingMethodException:
Method not found: 'System.Type System.Runtime.InteropServices.Marshal.GetTypeFromCLSID(System.Guid)'.
Because we may have trouble getting each user upgraded to 4.5 (as none of them have admin permissions on their machines and this would require a separate upgrade request for each user), I'm looking at finding an easy way to rebuild the project as 4.0. This seems to require that I rebuild every library and its referenced libraries in 4.0; is there an easier way to do this than going through each library one by one and building a 4.0 version? I'm thinking maybe like a one-click option for "Rebuild all referenced libraries in target framework" or something like that.
If you have dependencies on .Net 4.5 DLLs then you will need to also get .Net 4.0 versions of those if you want to successfully downgrade your project. A .Net project can only reference .Net DLLs up to the same version of .Net as the referencing assembly.
The easiest way to do this is to use something like NuGet to manage your dependencies. Note that when you change the target framework version of your project in VS you will need to uninstall and re-install dependencies with NuGet as NuGet does not automatically do this for you when you change the target framework version.
Of course if all the dependencies are to your own code and you aren't publishing this through a dependency management system like NuGet you will need to downgrade all your other code to .Net 4.0 as well
When I use Visual Studio, I right click on the project, change the framework, fix the References and recompile. Usually straight forward.
Please, have a look at this MSDN page to correctly switch your project to a lower target framework without problems! It is a little bit outdated for what concerns versions, but the process is the same described!
This is based on my experience. I had an application initially created in .net framework 4.5 but I wanted to convert it in .net framework 4.0. I created new project initially created 4.0 and then I did copy and paste of all the forms and controls of my previous application and it works. Framework 4.5 is using Aero2 and 4.0 is Aero... Good Luck :)

C# Referencing Quartz.DLL. Error on Debug losing Reference

I'm trying to build a simple scheduler using Quartz.NET, but when I try to run my program it "loses" the reference and gives me 8 errors. If I re-add the reference, which never actually disappeared, the errors go away, but the program just does the same thing. I'm working on the project on a Team Server Foundation which is completely new to me. I committed the changes, but I simply can't get the third-party references to stick.
I saved the Quartz.DLL in my project in a lib folder.
Here's a screenshot of the errors I'm receiving.
I should also note that I'm not really super familiar with C# or Visual Studios. Any advice on how to add and manage a third-party library would be great.
check if your project's properties is running under .net 4.0 and not client profile.
I think your issue is the using System.DateTime; above using Quartz;. Try removing that to see if it fixes the issues.
Also, if you are running Quartz 2.0, you need to be sure that you are targetting at least the .Net 3.5 framework, not 2.0. See the breaking changes information here.
Right click on Home_Control project. Select properties >> Select Application tab >> Look for the Target framework: >> Change it to .Net Framework 4 (Note: Please select the appropriate version depending on your project. Please Don't Select .Net Framework 4 Client Profile or .Net Framework 3.5 Client Profile).
Try Building the project now.
remove the Qurtz reference and add new reference manually . Use reference from netXX-client folder in package folder.

How to create .NET2 compatible app in VS2010?

I'm using Microsoft Visual Studio 2010 and .NET4, but I would like to create application(Windows Form Application) that can be also run in .NET2. The reason is that I want it to be very easy to use and portable across many machines and not everybody has .NET4 installed.
Can I do it or do I need to install older version of Visual Studio? Is so what version is the best for most portable .NET app.
You can modify the target framework in the properties of the project:
You can select which .NET Framework version you want to target when you create a new project. If you want to change the framework of an existing project, do what Darin has illustrated.
Just modify the target framework by looking at the propeties of the solution you are working on.
I would highly advise you to target .NET 3.5 just based on the age of .NET 2.0.
.NET Framework 2.0 was attached to Visual Studio 2005.
By modifying the target framework is the way, but if you are thinking of portable maybe what you need is some kind of native code that works in every and/or most windows version.
Don't forget to delete redundant namespaces from your namespace list. For example LINQ...

Categories