Change Target Framework from 4.5 to 4.0 - c#

I am trying to change the target framework from 4.5 to 4.0, I have changed the target framework on all of my projects and I have created a testing build with VS2015.
I am trying to run the app in WIN7 with .NET 4.0 installed but the app crashes and the errors are System.IO.FileLoadException for mscorlib.dll and PresentationFramework.dll
Does anyone know how to fix it?
More info
I have tried also:
to build with vs2012 but I cannot use vs2010 because I am using async from BCL package
to create new solution with new projects to target from the start 4.0 framework.

I guess the problem is try to run a .NET 4.5 in WIndows 7, which per default utilizes .NET 4.0.
Choose: or to install .NET 4.5 in WIndows 7 (I don't know if it's possible) or downgrade your project to NET 4.

For anyone out there that may have the same problem, be sure that you have installed the latest update for .NET framework, it worked after I have installed the update kb2468871

Related

Visual Studio mac 2019 (Community) - PresentationCore - Assembly not found for .Net Framework 4

I'm working on an existing solution at work that was written in C# targeting .NET Framework 4 in Visual Studio 2019 for Windows. I'm attempting to open the project on my MacBook Pro (running Catalina 10.15.6 if that's relevant) in Visual Studio Mac 2019 Community (Version 8.7.7 Build 10) so I can keep working on this remotely.
I'm noticing that a usage of System.Windows.Media isn't being found. My understanding is that this relies on PresentationCore, which I believe is included in .NET Framework 4. Sure enough, in the project's References, PresentationCore has a red "x" next, with alt text telling me "Assembly not found for framework .NET Framework 4".
Is there any way to add this? Is this just something not supported in macOS? I'm happy to provide any additional information.
You are trying to run a WPF application, which targets .Net Framework (4), on MacOS.
MacOS doesn't support WPF, or any version of .Net Framework, as .Net Framework is Windows-dependent1.
Image source: https://visualstudio.microsoft.com/vs/mac/
.Net Core is supported - that's the cross-platform version of .Net, which works on Windows, Mac, and Linux.
You'll need to do a migration to make it work with Core. Of course, this still won't allow you use to run WPF on a Mac, you'd need to use another cross-platform supported UI framework.
1 Of course, Mono is the open-source version of .Net Framework that runs on Mac and Linux, so you can also try that as an option if you're feeling adventurous or can't migrate to Core.
See also: Can you install and run apps built on the .NET framework on a Mac?
Gunr2171 is correct; but you could also look at running a virtual box on your Mac for a windows environment then use VS Code.
For a VM I recommend
https://www.virtualbox.org/wiki/Mac%20OS%20X%20build%20instructions
Then Windows 10 OS:
https://www.microsoft.com/en-ca/software-download/windows10ISO
Just an idea if Mono doesn't work for you.

Nant change Target Framework to match project

I upgraded my project from .NET 3.5 to 4.5. It's working locally but not building on the server, and the problem is that Nant is trying to use MSBuild 3.5. I ran Nant locally and although it's succeeding, it says 'Target framework: Microsoft .NET Framework 2.0' and then '[property] Target framework changed to "Microsoft .NET Framework 3.5'. What do I need to change in the nant.exe.config file to make it run the right version?
In case you (or anyone else for that matter) are still looking for an answer, check https://alastaircrabtree.com/how-to-build-a-visual-studio-2013-or-2015-solution-on-a-build-server-using-nant/

Change the .net framework with visual studios 2013 and the xamarin plug in

I am trying to change the .net framework for a android c# app in visual studios 2013. I tried to create a new project with .net framework 4.0 but I still get an error saying that my application is targeting the 4.5 framework. Does anyone know how to force this? The reason I am doing this is that I have a nuget package that uses the 4.0 framework, however if there is a way to get that nuget package to use the 4.5 framework that is an equally valid solution.
You cannot change the .net framework for an Android app. It will always be targeting MonoAndroid.
You cannot use a NuGet package that only assemblies for the .NET framework since they may use parts of the Xamarin Android API that is not supported.
So you are left with finding another NuGet package that supports Android projects or re-compiling the source code in an Android library project so it targets MonoAndroid, which may or may not work depending on what the source code does.

Running Awesomium on .NET 3.5

Does anybody know how I can run Awesomium.NET on .NET 3.5? Seems to only work on 4.0-4.5.1 right now.
According to this question, Awesomium 1.7 should be compatible with 3.5 by adding Awesomium.Mono to the project instead, but it seems like I'm not able to do that. When choosing 3.5 project in Visual Studio the Awesomium.Mono just disappears from the references list.
Well when I started using Awesomium web browser at version 1.7.0 the reference dll are builded using .net 4.0 version. You should try to look for an older version like 1.6.6 or 1.6.5 and check if they are builded using a older .net version. If you target your project to .net 4.0 you should not have any problem because at least windows XP with service pack 3 should have installed .net framework 4.0. But windows XP support has ended.
A quick solution (but not the best) is to target the project to the .net 4.0 and export all dll references to the build path. That should make no problems when deploying the app to your clients machine because the exe will reference to the build path.
Could you give me the reasons of why you are targeting .net 3.5 so I can understand a little more your issue with .net versions and try to think about another solution for you?

New Version Error C#

I've built a windows service code with Framework Verison 4.0, when I sent my service.exe for instllation at different machine which has version 2.0 installed it gave error:
"Exception occurred while initializing installation:
System.BadImageFormatException: couls not load file or assembly '\service.exe' or one of its
dependencies. This assembly is built by a runtime newer than currently loaded runtime and cannot be loaded"
How can I build a service which is backward compatible in visual studio
Change your target framework to 2.0, and make sure you do not use anything that's not part of 2.0 (e.g. TPL, etc), otherwise, install .NET 4 on the target machines
You cannot run .NET v4.0 code in .NET v2.0 runtime. Either install .NET v4.0 on the server or convert your servive to .NET v2.0
When you have a .net framework 4.0 installed then you can run any application which has a target framework value as 2.0 , 3.0 , 3.5 and 4.0
and when you have a .net framework 3.5 installed then you can run any application which has target framework value as 2.0 , 3.0 and 3.5 , like this it goes on.
This is mandatory requirement for .net framework , so it would be better if you ask your client to install .net framework 4.0 or create a service (i hope this is windows service and not wcf service because wcf is supported only from framework version 3.0) project which targets the framework version 2.0.

Categories

Resources