locked
check .net framework installed or not? RRS feed

  • Question

  • Hi,

     

    I am creating windows application in want to check as .net framework

    is installed on client machine while running setup , Please

    provide me the code or logic to make this possible.

     

    Note :wihout using installsheald, only c# code.

     

    Thanks,

    PK

    Thursday, September 27, 2007 12:02 PM

Answers

  • Puru,

    Create a setup project, so that you don't have to do things the complicated and non-standard way.

    That is the preferred way to do things, John was telling you what you had to do if you didn't want to do the above, and instead wanted to use C#, which you can't really do, because of the catch-22 situation.

    Go the project, John mentioned that that was his first choice too!

    Good luck,

    Martin Platt.
    Tuesday, October 9, 2007 11:34 PM

All replies

  • pk,

     

    You need to set up a precondition for the setup project that specifies the .NET framework you want to be installed before your code installs.  This doesn't require code, as it is quite a common task as you might imagine.

     

    Good luck,

     

    Martin Platt.

     

    Tuesday, October 2, 2007 4:33 AM
  • Hi Martin,

    Thanks for response.

    I have to do coding for that in c#.

    Please help me.

    Thanks in advance.

    Puru

     

    Monday, October 8, 2007 9:22 AM
  • Hello Puru,

    You have a circular problem which cannot be solved the way you want to. You see, if you write C# code to check if the .NET Framework is installed, it would require the .NET Framework to be installed to run that code in the first place.

    A crude solution is to write a batch file that checks if the folder for the .NET Framework is present or not:

    @ECHO OFF
    SET FileName=%windir%\Microsoft.NET\Framework\v1.1.4322
    IF EXIST %FileName% GOTO Skip
    ECHO.You currently do not have the Microsoft® .NET Framework 1.1 installed.
    ECHO.This is required by the setup program for MyApplication.
    ECHO.
    ECHO.The Microsoft® .NET Framework 1.1 will now be installed on you system.
    ECHO.After completion setup will continue to install MyApplication on your system.
    ECHO.
    Pause
    SET FileName=
    Start /WAIT .\dotnetfx.exe
    Start .\Setup.exe
    ECHO ON
    Exit
    Tongue Tiedkip
    SET FileName=
    Start .\Setup.exe
    ECHO ON
    Exit

    This batch file would check for the 1.1 version, but you can change it to check for any other version. It required the installation for the .NET Framework to be present in the same directory (dotnetfx.exe). Also note that this only checks whether or not the folder is there, it does not actually check if the framework is installed correctly.

    However, I would choose to create a ClickOnce or C# Setup Project for a smoother, more professional solution.

    Regards,
    John Willemse
    • Proposed as answer by ramin1981 Saturday, August 29, 2009 11:57 AM
    Tuesday, October 9, 2007 6:01 AM
  • It uses windows installer, so shouldn't require .NET to work.  You can have the framework installed by your install program without any troubles.

    The installer will then go on, after the framework is installed, and install your application, which then does require the framework.

    It's not an uncommon thing to do, and is fairly straight forward.

    I hope that helps,

    Martin Platt.
    Tuesday, October 9, 2007 6:06 AM
  •  Martin Platt wrote:
    It uses windows installer, so shouldn't require .NET to work.  You can have the framework installed by your install program without any troubles.

    The installer will then go on, after the framework is installed, and install your application, which then does require the framework.

    It's not an uncommon thing to do, and is fairly straight forward.

    I hope that helps,

    Martin Platt.


    I agree Martin, but he insist on doing it in C# code and not a setup project, that's why I said he would require the framework.

    Regards,
    John Willemse
    Tuesday, October 9, 2007 6:10 AM
  • sorry John, didn't read properly.  That would be incredibly lame, would it not?

    The way I read it, he assumed that he'd have to use C#, but you may well be right.

    I wasn't correcting you either, merely trying to point out the workings and how easy creating such a project really is.

    Thanks,

    Martin Platt.
    Tuesday, October 9, 2007 6:13 AM
  • Hi Martin and John,

     

    I am confused now. What to do.

    Please advice.

    Thanks,

    Puru

    Tuesday, October 9, 2007 1:41 PM
  • Puru,

    Create a setup project, so that you don't have to do things the complicated and non-standard way.

    That is the preferred way to do things, John was telling you what you had to do if you didn't want to do the above, and instead wanted to use C#, which you can't really do, because of the catch-22 situation.

    Go the project, John mentioned that that was his first choice too!

    Good luck,

    Martin Platt.
    Tuesday, October 9, 2007 11:34 PM
  • Thanks A Lot Martin.

     

    Wednesday, October 10, 2007 11:36 AM
  • My users and testers unanimously feel that downloading the .Net framework as an extra step is not so simple
    and is time consuming. I've had advice to only target VIsta with my app, but very few people in my world are using it.

    When I use the windows install option, the user is sent to a complicated site recommending a
    197meg download of the .Net 3.5 package. Is that possible? My product is only 1.5 meg if you have .Net 2.0 already.

    I've opted to redirect users to do this:

    1) have the user download a few hundred kbyte file to check for .Net 2.0 or greater presence.
    2) then redirect them to the appropriate download of my software. a) 1.5 meg because
    .Net already present, or: b) a silent install of whatever I can find to make the download
    as small as possible. They can use this on their XP machine until they upgrade to Vista.

    The current route called standard and simple is not friendly to any of my users so far.
    Monday, December 24, 2007 7:58 AM
  • PK,

     

    Don't worry about it, just install it. If it is already installed it will fail and tell you that it cannot install the file because it is already installed. - click ok

     

    It will roll back the install attempt and continue with the rest of your install as it should be. I don't know just yet of a check procedure from MS to verify. This is the best I have found. On machines that have it installed already there is a 5 or so minute extra check that is worth it.

     

    Machiavelli

     

    Friday, February 29, 2008 6:51 AM
  • Thanks Machiavelli.

    I will try using this.

    Puru

     

     

    Friday, February 29, 2008 1:12 PM
  • Machiavelli,

     

    You're kidding, right?  Unless I'm misunderstanding, you're saying that you install the .NET framework, and if it is already installed the whole application installation will fail?  Is that what you mean?

     

    This isn't the best way at all, you're going through the time and effort to install the software, only to be told after some minutes that it failed, instead the setup project would check the precondition for .NET, and if it doesn't exist, install it.  If it does exist, it wouldn't fail, in fact it wouldn't do anything.

     

    I hope this helps, and clears some bad and evil thoughts up!!

     

    Martin Platt.

     

     

    Monday, March 17, 2008 2:41 AM
  • This script does not work
    Saturday, August 29, 2009 11:57 AM
    • Proposed as answer by Dhruv Joshi Thursday, January 12, 2012 8:57 AM
    Thursday, January 12, 2012 7:51 AM