Results 1 to 5 of 5

Thread: [RESOLVED] check framework before run

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2012
    Posts
    193

    Resolved [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 ?

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,350

    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.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Oct 2012
    Posts
    193

    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.

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,930

    Re: check framework before run

    Quote Originally Posted by genlight View Post
    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.

  5. #5
    You don't want to know.
    Join Date
    Aug 2010
    Posts
    4,578

    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
  •  



Click Here to Expand Forum to Full Width