Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / June 2007

Tip: Looking for answers? Try searching our database.

Missing .NET and Exceptions

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John Bowman - 25 Jun 2007 19:11 GMT
Hi All,

I've been reading about Application.ThreadException,
Application.SetUnhandledExceptionMode &
AppDomain,CurrentDomain.UnhandledException. I'm trying to determine if there
is a mechanism where if the .NET framework is missing, is there any way at
all to gracefully catch it in my code and inform the user of what's wrong.
Is this even possible? If so, how can I catch it and nicely inform the user
of the problem - Microsoft's "The application failed to initialize
properly..." message is basically useless to a user. If it's even possible &
anyone has any code to share, I'd be much appreciative.

TIA,

Signature

John C. Bowman
Software Engineer II
Thermo Fisher Scientific
<Remove this before reply> john.bowman@thermofisher.com

WORLDWIDE CONFIDENTIALITY NOTE: Dissemination, distribution or copying of
this e-mail or the information herein by anyone other than the intended
recipient, or an employee or agent of a system responsible for delivering
the message to the intended recipient, is prohibited. If you are not the
intended recipient, please inform the sender and delete all copies.

Ignacio Machin ( .NET/ C# MVP ) - 25 Jun 2007 19:40 GMT
Hi,

Not, unfortunatelly all those events, classes, etc that you mention, well
they are part of the framework in tehr first place :)

You would have to create an unmanaged process to detect the presence of the
framework.

Or convince MS to create another message :D

> Hi All,
>
[quoted text clipped - 9 lines]
>
> TIA,
Nicholas Paldino [.NET/C# MVP] - 25 Jun 2007 19:41 GMT
John,

   It's impossible, since the code you would write is managed code, and
without the framework installed, managed code won't run.

   You would have to create an unmanaged stub to check for the existence of
the framework, and then show the appropriate message if it is not installed.
If it is, then you would just create a new process and run your managed
executable then.

Signature

         - Nicholas Paldino [.NET/C# MVP]
         - mvp@spam.guard.caspershouse.com

> Hi All,
>
[quoted text clipped - 9 lines]
>
> TIA,
John Bowman - 25 Jun 2007 20:42 GMT
Ignacio & Nicholas,

Thanks for the info. That's what I suspected. Unfortunately, the case in
question is a setup/installation like process that already has a stub
written in C++ that does exactly that, once the framework is installed, then
the stub runs the main C# .exe program. Unfortunately, there's no way to
prevent the user from trying to run the main .exe program directly w/o the
stub 1st. If the user does this, then they crash and have no idea why
because the message is "engineerese". What's really needed is the loader's
crash message to be more usfully informative to the average non-engineer
user, or the ability to substitute your own graceful message into the loader
in the event the proper .NET framework is not present.

John

> John,
>
[quoted text clipped - 19 lines]
>>
>> TIA,
Ignacio Machin ( .NET/ C# MVP ) - 25 Jun 2007 21:50 GMT
Hi,

> Ignacio & Nicholas,
>
[quoted text clipped - 8 lines]
> user, or the ability to substitute your own graceful message into the
> loader in the event the proper .NET framework is not present.

What if you rename your managed EXE to some other extension , like _EX. in
this way t will not be executed.

As a step in your install process you can rename it back to the correct
extension.
John Bowman - 28 Jun 2007 12:47 GMT
Ignacio,

Thanks for the idea, but that won't work either because it's distributed on
a CD/DVD - so renaming it as part of hte install process is not an option.
However, this does give me an idea I hadn'tr considered before. I wonder if
the CreateProcess Win32 API method which is used in the stub to launch the
.NET .EXE can handle something that's not named .EXE? I've never
tried/thhought of that. If so, then I could rename the .NET .EXE and the
user could never double click it & try to run it directly. But the stub
could then successfully launch it. I'll have to look into this possibility.
A quick look at the MSDN for CreateProcess doesn't really mention anything
directly, but it does mention the possibility of not having a file
extension.

Thanks!

John

> Hi,
>
[quoted text clipped - 16 lines]
> As a step in your install process you can rename it back to the correct
> extension.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.