473,320 Members | 2,146 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Downlevel .NET question

MC
What happens if a .NET 3.5 .exe file is executed on a computer that only has
..NET 2.0? Does the user get a meaningful error message?

Jul 25 '08 #1
11 1482
On Jul 25, 7:15*am, "MC" <for.address.l...@www.ai.uga.edu.slash.mc>
wrote:
What happens if a .NET 3.5 .exe file is executed on a computer that only has
.NET 2.0? *Does the user get a meaningful error message?
To my surprise, one .exe created with express edition using 3.5, ran
successfully on a machine having framework 2.0. I was expecting an
error....

-Cnu
Jul 25 '08 #2
On Jul 25, 6:15*am, "MC" <for.address.l...@www.ai.uga.edu.slash.mc>
wrote:
What happens if a .NET 3.5 .exe file is executed on a computer that only has
.NET 2.0? *Does the user get a meaningful error message?
There is no such thing as a ".NET 3.5 .exe file" - any assembly you
build targeting .NET 3.5 is binary compatible with .NET 2.0 (because
both use the same 2.0 runtime). The only difference may be that .NET
3.5 assembly can reference some of the new assemblies from 3.5. In
this case, and if you actually try to use anything from those
referenced assemblies, you'll get the exact same error as for a
missing library. If you do not use any 3.5 assemblies, it will just
run.

Note that you can register your own handler for
AppDomain.AssemblyResolve event to detect missing assemblies and
provide your own error message if the assembly is a 3.5 one.
Jul 25 '08 #3
MC
"Pavel Minaev" <in****@gmail.comwrote in message
news:a3**********************************@r35g2000 prm.googlegroups.com...
wrote:
--------------
What happens if a .NET 3.5 .exe file is executed on a computer that only
has
.NET 2.0? Does the user get a meaningful error message?
There is no such thing as a ".NET 3.5 .exe file" - any assembly you
build targeting .NET 3.5 is binary compatible with .NET 2.0 (because
both use the same 2.0 runtime). The only difference may be that .NET
3.5 assembly can reference some of the new assemblies from 3.5. In
this case, and if you actually try to use anything from those
referenced assemblies, you'll get the exact same error as for a
missing library. If you do not use any 3.5 assemblies, it will just
run.
-------------

Thanks. What are the new assemblies?

Jul 25 '08 #4
On Jul 25, 3:00*pm, "MC" <for.address.l...@www.ai.uga.edu.slash.mc>
wrote:

<snip>
There is no such thing as a ".NET 3.5 .exe file" - any assembly you
build targeting .NET 3.5 is binary compatible with .NET 2.0 (because
both use the same 2.0 runtime). The only difference may be that .NET
3.5 assembly can reference some of the new assemblies from 3.5. In
this case, and if you actually try to use anything from those
referenced assemblies, you'll get the exact same error as for a
missing library. If you do not use any 3.5 assemblies, it will just
run.
Not quite. The other possibility is that you might have referenced one
of the .NET 2.0 SP1 classes in existing assemblies - things like
DateTimeOffset. Those will exist on a .NET 2.0SP1 installation, but
not vanilla .NET 2.0.

Jon
Jul 25 '08 #5
On Jul 25, 6:33*pm, "Jon Skeet [C# MVP]" <sk...@pobox.comwrote:
Not quite. The other possibility is that you might have referenced one
of the .NET 2.0 SP1 classes in existing assemblies - things like
DateTimeOffset. Those will exist on a .NET 2.0SP1 installation, but
not vanilla .NET 2.0.
I stand corrected - got bitten by that myself another day, only in my
case it was INotifyPropertyChanging.

But then again, 2.0SP1 is technically still 2.0, and it's available as
a separate download (and installs on all platforms vanilla 2.0 worked
on).

On a side note, I wonder why VS2008 Setup Project uses plain 2.0 and
not 2.0SP1 redistributable if you ask to include the dependencies with
the installer...

Jul 25 '08 #6
MC
What happens if a .NET 3.5 .exe file is executed on a computer that only
has .NET 2.0? Does the user get a meaningful error message?
Here's an answer.

An .EXE targeted for .NET 3.5 will not run on a freshly installed Vista
machine (which I thought would have .NET 3.0). Nor does it give a
meaningful error message to the user. All you get is "So-and-so has stopped
working" and, in the log, an Event 1001, event name CLR20r3, P4=mscorlib,
P5=2.0.0.0.

Not convenient.
Jul 28 '08 #7
MC <fo**************@www.ai.uga.edu.slash.mcwrote:
What happens if a .NET 3.5 .exe file is executed on a computer that only
has .NET 2.0? Does the user get a meaningful error message?

Here's an answer.

An .EXE targeted for .NET 3.5 will not run on a freshly installed Vista
machine (which I thought would have .NET 3.0). Nor does it give a
meaningful error message to the user. All you get is "So-and-so has stopped
working" and, in the log, an Event 1001, event name CLR20r3, P4=mscorlib,
P5=2.0.0.0.

Not convenient.
Well, it will do that in some cases - like if you use a type declared
in .NET 2.0 SP1 or .NET 3.0 SP1, or reference a .NET 3.5 assembly.

If you don't use anything that's not in .NET 2.0 (or 3.0 for Vista) is
should work fine.

--
Jon Skeet - <sk***@pobox.com>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com
Jul 28 '08 #8
MC
>An .EXE targeted for .NET 3.5 will not run on a freshly installed Vista
>machine (which I thought would have .NET 3.0). Nor does it give a
meaningful error message to the user. All you get is "So-and-so has
stopped
working" and, in the log, an Event 1001, event name CLR20r3, P4=mscorlib,
P5=2.0.0.0.

Not convenient.

Well, it will do that in some cases - like if you use a type declared
in .NET 2.0 SP1 or .NET 3.0 SP1, or reference a .NET 3.5 assembly.

If you don't use anything that's not in .NET 2.0 (or 3.0 for Vista) is
should work fine.
Is there anything I can put in my program to trap this condition and give a
more useful error message? Or is the failure occurring as the program
loads, before it tries to execute?

In my case, the program uses an extension method, and that seems to be what
trips it.
Jul 28 '08 #9
MC <fo**************@www.ai.uga.edu.slash.mcwrote:
Well, it will do that in some cases - like if you use a type declared
in .NET 2.0 SP1 or .NET 3.0 SP1, or reference a .NET 3.5 assembly.

If you don't use anything that's not in .NET 2.0 (or 3.0 for Vista) is
should work fine.

Is there anything I can put in my program to trap this condition and give a
more useful error message?
Not easily, as far as I know.
Or is the failure occurring as the program loads, before it tries to execute?
I don't know, to be honest. I suggest you try it and see - try to write
code that calls a method in .NET 3.5, and see if you can get it to
execute at all.

My *guess* is that when the class that refers to a .NET 3.5 class is
first initialized, that's when it'll first go bang - but it could be at
the method level, or the whole assembly level...
In my case, the program uses an extension method, and that seems to be what
trips it.
Yes, there weren't any extension methods (or even the attribute) in
..NET 3.0.

--
Jon Skeet - <sk***@pobox.com>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com
Jul 28 '08 #10
On Jul 28, 8:22*pm, "MC" <for.address.l...@www.ai.uga.edu.slash.mc>
wrote:
Is there anything I can put in my program to trap this condition and givea
more useful error message? *Or is the failure occurring as the program
loads, before it tries to execute?

In my case, the program uses an extension method, and that seems to be what
trips it.
Since an extension method translates to an instance of
ExtensionAttribute, and since attributes are (so far as I know)
instantiated when assembly is loaded, it would seem that you can't
catch this particular case no matter what.

Anyway, even if you could trap it, what were you going to do? If your
program needs 3.5, then the most appropriate thing is to create an
installer which checks whether 3.5 is installed, and if not, installs
it, or prompts the user to install it. A simple VS Setup project
should do it.
Jul 29 '08 #11


"Jon Skeet [C# MVP]" <sk***@pobox.comwrote in message
news:MP*********************@msnews.microsoft.com. ..
MC <fo**************@www.ai.uga.edu.slash.mcwrote:
Well, it will do that in some cases - like if you use a type declared
in .NET 2.0 SP1 or .NET 3.0 SP1, or reference a .NET 3.5 assembly.

If you don't use anything that's not in .NET 2.0 (or 3.0 for Vista) is
should work fine.

Is there anything I can put in my program to trap this condition and give
a
more useful error message?

Not easily, as far as I know.
>Or is the failure occurring as the program loads, before it tries to
execute?

I don't know, to be honest. I suggest you try it and see - try to write
code that calls a method in .NET 3.5, and see if you can get it to
execute at all.

My *guess* is that when the class that refers to a .NET 3.5 class is
first initialized, that's when it'll first go bang - but it could be at
the method level, or the whole assembly level...
Then have the exe not use any .NET 3.5, but invoke the "real" main method in
a library assembly and catch any exceptions?

i.e. change the current application to a class library project, and invoke
its Main method from a brand new shim.
>
>In my case, the program uses an extension method, and that seems to be
what
trips it.

Yes, there weren't any extension methods (or even the attribute) in
.NET 3.0.

--
Jon Skeet - <sk***@pobox.com>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com
Aug 2 '08 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Stevey | last post by:
I have the following XML file... <?xml version="1.0"?> <animals> <animal> <name>Tiger</name> <questions> <question index="0">true</question> <question index="1">true</question> </questions>
7
by: nospam | last post by:
Ok, 3rd or is it the 4th time I have asked this question on Partial Types, so, since it seems to me that Partial Types is still in the design or development stages at Microsoft, I am going to ask...
3
by: Ekqvist Marko | last post by:
Hi, I have one Access database table including questions and answers. Now I need to give answer id automatically to questionID column. But I don't know how it is best (fastest) to do? table...
10
by: glenn | last post by:
I am use to programming in php and the way session and post vars are past from fields on one page through to the post page automatically where I can get to their values easily to write to a...
10
by: Rider | last post by:
Hi, simple(?) question about asp.net configuration.. I've installed ASP.NET 2.0 QuickStart Sample successfully. But, When I'm first start application the follow message shown. ========= Server...
53
by: Jeff | last post by:
In the function below, can size ever be 0 (zero)? char *clc_strdup(const char * CLC_RESTRICT s) { size_t size; char *p; clc_assert_not_null(clc_strdup, s); size = strlen(s) + 1;
2
by: Jeremy S. | last post by:
In an ASP.NET 1.1 Web application, how can I detect - with *reasonable* accuracy - whether any particular browser is a downlevel browser? My objective is to insert a different menu (different...
56
by: spibou | last post by:
In the statement "a *= expression" is expression assumed to be parenthesized ? For example if I write "a *= b+c" is this the same as "a = a * (b+c)" or "a = a * b+c" ?
2
by: Allan Ebdrup | last post by:
Hi, I'm trying to render a Matrix question in my ASP.Net 2.0 page, A matrix question is a question where you have several options that can all be rated according to several possible ratings (from...
3
by: Zhang Weiwu | last post by:
Hello! I wrote this: ..required-question p:after { content: "*"; } Corresponding HTML: <div class="required-question"><p>Question Text</p><input /></div> <div...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.