-
Jan 18th, 2018, 12:03 AM
#1
Thread Starter
Addicted Member
[RESOLVED] check framework before run
So I need to verify first if a certain version of .net framework is installed, say version 4.
Is there a way for the application to check this requisite before it actually runs and popup message to install this version of .net framework first ?
-
Jan 18th, 2018, 12:25 AM
#2
Re: check framework before run
You're asking if there's a way for an application to do something before the application is running? The answer to that would be know, because if it was doing something then it would already be running.
If you're concerned about the user not having a particular version of the Framework installed then create an installer and make it a prerequisite. Otherwise, the system will throw up an error dialogue when an app runs that requires a version of .NET that isn't available. Those errors used to be rather cryptic but they have become more informative lately. I can't recall what any of them say though, as I haven't seen one in a while.
-
Jan 18th, 2018, 12:38 AM
#3
Thread Starter
Addicted Member
Re: check framework before run
I have disable the enable application framework so that I can use sa Sub Main as startup object. That way I can check first the requisite.
on the other hand, I was thinking how I can still make use of enable application framework and use application events to execute my checking.
can you kindly provide me sample with this.
UPDATE:
got it.
Private Sub MyApplication_Startup() Handles Me.Startup
End Sub
Last edited by genlight; Jan 18th, 2018 at 12:42 AM.
-
Jan 18th, 2018, 06:26 AM
#4
Re: check framework before run
Originally Posted by genlight
I have disable the enable application framework so that I can use sa Sub Main as startup object. That way I can check first the requisite.
While that allows you to use Sub Main, it does not allow you to avoid using the .Net framework.
The application framework just makes some things easier (such as shutdown options), more info:
https://visualstudiomagazine.com/art...ork-in-vb.aspx
Any code you write is still a .Net application, so requires the .Net framework.
Any attempt to write code (no matter what language) will end up being a variation of the options in jmcilhinney's post (show a message saying the framework isn't installed, or install the framework), but will take more work than using the standard options that he mentioned.
-
Jan 18th, 2018, 08:06 AM
#5
Re: [RESOLVED] check framework before run
The "Application Framework" checkbox just controls whether you get the features that make VB confusing for newbies.
When you build a .NET exectuable, it makes a Windows PE file. In an API app, that file has a special location where it tells Windows what the first instructions it should execute are, and it's the compiler's job to make sure that corresponds to your first line of code. In a .NET app, the .NET compiler hijacks that process and replaces it with code that loads the .NET Framework, builds an AppDomain, then starts executing your IL within that AppDomain.
So in order to check for the framework, you'd have to modify the PE file. .NET doesn't give you a way to do that. However, somewhere along the line, it started doing the check itself. I'm pretty sure at 2010 and beyond, (really, the difference is "starting in Windows Vista") if you start the app on a Windows without the right framework it shows a dialog that describes how to get it.
Maybe it was VS 2012 instead of VS 2010, but I think it was a feature of the CLR that came with .NET 4.0 or so.
This answer is wrong. You should be using TableAdapter and Dictionaries instead.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|