HtmlForm.Action and .Net Framework 2.0/3.5 Query - c#

Disappointingly, the members page for HtmlForm 2.0 is missing...
My research seems to indicate that HtmlForm.Action is a property that was added in .Net Framework 3.5. However, I'm using VS2005 and my reference to System.Web (the namespace HtmlForm is under) is to a .Net Framework 2.0 runtime version.
Further, my IIS status information also indicates I am using .Net Framework 2.0, when I force an error on my local IIS and read it. Despite this, I am able to use form1.Action successfully...but only on my local IIS.
When I try it on vms and external servers, I get [MissingMethodException: Method not found: 'System.String System.Web.UI.HtmlControls.HtmlForm.get_Action()'.] errors.
So, my question:
1) Why does it work on my local IIS? Does the fact that I have the 3.5 framework installed make a difference, here?
2) Why does it not work on other IIS? (I think this is because it's not part of .Net 2.0).
I guess I just figure that if something is running on .Net Framework 2.0, the presence of 3.5 should not make a difference. Or maybe there's some other cause for these results.

That's right in IIS you will see .NET Framework 2.0 even when you are using .NET 3.5. It happend because Microsoft .NET Framework 3.5 was built incrementally upon .NET Framework 2.0 and 3.0.
1) It doesn't work on the server because .NET 3.5 is not installed. You have created the .NET 3.5 project in the Visual Studio, so .NET 3.5 must be installed on the server.
2) See 1.

Related

Target.NET framework version vs .NET framework version installed

We have a C# project and in Visual Studio the according "Target framework" is currently set to ".NET Framework 4.5". We have a second client library (written in C++) that calls this C# library to do something. For some new features we want to use the framework 4.6.1+. But we don't worn that C# project directly.
So some question in mind:
Generally, if we upgrade "Target framework" to .NET Framework 4.6.1 and on the machines where our app is running the actual framework is pre 4.6.1 (e.g., 4.5). What will happen? Will it throw some exception when the app is started?
If we stick to .NET Framework 4.5 as the target version, is there an option to automatically use the latest version actually installed on the machine where the app is run?
Thanks.
on the machines where our app is running the actual framework is pre 4.6.1 (e.g., 4.5). What will happen? Will it throw some exception when the app is started?
It will not throw an exception when the app started... The only time it could throw an exception is if (and when) your library calls a method that exists in .NET 4.6.1 but does not exist in .NET 4.5... You will get a MissingMethodException, other than that everything should work fine.
Something you can do is inspect what is the .NET Framework that is being run in the process that loaded your library.
string version = AppDomain.CurrentDomain.SetupInformation.TargetFrameworkName;
You can do that at the very start of the method being called in the library. And if the .NET Framework is < 4.6.1 you can decide what to do... Show an error message, or change the behavior as to not call into some functions (and avoid MissingMethodException).
One more thing you can also do determine which .NET Framework versions are installed on the machine and make some decisions on what to do.
.NET Framework 4.5+ is backward compatible. If app will be 4.6.1, but OS will have 4.5 then application error is possible (no forward compatibility). Documentation about version compatibility says:
By default, an app runs on the version of .NET Framework that it was
built for. If that version isn't present and the app configuration
file doesn't define supported versions, a .NET Framework
initialization error may occur. In this case, the attempt to run the
app will fail.

Deploying a .net 4.0 application

I have an application built with .net 4.0 and uses WPF
My users have Windows 7 with default .net 3.5 installed.
My application cannot be downgraded to .net 3.5 and I want to avoid users from going through the process of downloading and installing .net 4.0 which is about 40MB (Even with silent install).
Since my application is a small one, is there a way to deploy it with only the required .net 4.0 libraries? and thus avoiding the installation of the entire .net 4.0 framework
If this is not possible, is there a way to execute the .net 4.0 app in a .net 3.5 environment?
If this is not possible, is there a way to execute the .net 4.0 app in a .net 3.5 environment?
No. Basically you really need to get the environments aligned. You say your application cannot be downgraded to .NET 3.5 - presumably that's because you're using something which is specific to .NET 4.0. It stands to reason that you can't then execute that in an environment which doesn't have .NET 4.0.
You need to decide which is more painful - changing your app to target .NET 3.5, or asking your users to install .NET 4.0.

Changing framework from 3.5 to 4.0 at Server

I know my Question is little bit basic but have to ask about this:
i have my website build in Visual Studio 2008 with .Net framework 3.5
that site is hosted on my server.
now because of some specific reason i have to install framework 4.0 to the server.
and i just want to know that my site will be okk with it or not.
I mean if i change my framework from 3.5 to 4.0 then is there some changes i should make to my site or that site will run fine as before.
You should also change Framework Version in the application pool of your WebSite.
Basically, remember that Framework version != CLR Version.
In your case, .NET Framework 3.5 = CLR 2.0 + (C# 3.0 | VB9)
.NET Framework 3.5 and 4.0 have different CLR Versions and can be installed side by side on same machine.
That means your site will not see any issues.
There is no problem installing the framework 4 on the server.
Your site should be fine as long as you don't change the target framework on the IIS appPool.
You can have all the frameworks installed on the same machine.

IIS7: Why can't i Choose v3.5 .net Framework?

The only choices for the application pools are .net 2.0 or 4.0, but my machine is running on 3.5.
I am currently getting a
system.platformnotsupportedexeception
in an app that i built, and i think it might be related to this issue.
Keep in mind, there is no 3.5 version of the .NET runtime - only a 3.5 version of the .NET Framework. The CLR itself is either 2.0 or 4.0. Why they have weird versioning is beyond me (I guess there were no runtime modifications to support the 3.5 framework), but the framework versions are different than the runtime versions.
.NET 3.5 has the same base runtime as .NET 2.0. So in your case, selecting 2.0 is correct.
See this similar question.

c# What happens if I use code a .NET 3.5 function on a machine that has .Net 2 installed

Just out of interest, if I built some code using the Enumerable.Distinct function which appeared in .Net 3.5 and then ran it on a machine with .Net 2.0 on it, what would happen?
The program will crash as soon as the assembly that defines Enumerable.Distinct (System.Core) is needed. However, you can make it work if you target .NET 2.0 and use LinqBridge instead of System.Core.
You will be able to compile a 3.5 Framework project and run it on the 2.0 Framework as long as you don't have any 3.5 Framework references. In your case, you are using Enumerable.Distinct which is in the 3.5 Framework references, so your application will fail.
.Net 2.0 won't understand the command because the library isn't there.
.NET 3.5 is essentially .NET 2.0 + some extra assemblies.
If those extra assemblies aren't installed, ie. .NET 3.5 isn't installed, then your program will fail to load those assemblies when needed.
If you have somehow managed to steer clear of using those assemblies, then presumably your program will function just fine, but I'd say that would be the exception to the rule. For your specific example, at the point where your program uses .NET 3.5 code for the first time, you would get an exception.
In short, make sure .NET 3.5 (SP1) is installed on the target machines.
Most probably your code will complain about .net 3.5 being not installed at the startup.
Simple,It will crash at aribitary points at where you used the .net 3.5 specific functionality.
But basic question ... why do you want to do that ?
If you have migrated a project from .net freamework version 2.0 to 3.5 and not using any feature of .net 3.5 does not represent a valid framework migration

Categories

Resources