none
How to merge .Net framework with my application RRS feed

  • Question

  • Hi,

    My problem is to install .Net framework when my application setup installed in client machine.

    My requirement is, i've to install my application setup, b'fore installing that my application setup have to check whether the box contain .Net framework, if not it should be install.

    How to do this ? please help to solve this issue.

    S. Ramkumar

    Smiley
    Saturday, November 29, 2008 8:52 AM

Answers

  • This is the code to confirm the frame work is installed or not....by running HTML page
    Hope you can include this in you application on startup or bootstrap .


    <HTML>
      <HEAD>
        <TITLE>Test for the .NET Framework 3.5</TITLE>
        <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8" />
        <SCRIPT LANGUAGE="JavaScript">
        <!--
        var dotNETRuntimeVersion = "3.5.0.0";
       
        function window::onload()
        {
          if (HasRuntimeVersion(dotNETRuntimeVersion))
          {
            result.innerText =
              "This machine has the correct version of the .NET Framework 3.5."
          }
          else
          {
            result.innerText =
              "This machine does not have the correct version of the .NET Framework 3.5." +
              " The required version is v" + dotNETRuntimeVersion + ".";
          }
          result.innerText += "\n\nThis machine's userAgent string is: " +
            navigator.userAgent + ".";
        }
       
        //
        // Retrieve the version from the user agent string and
        // compare with the specified version.
        //
        function HasRuntimeVersion(versionToCheck)
        {
          var userAgentString =
            navigator.userAgent.match(/.NET CLR [0-9.]+/g);

          if (userAgentString != null)
          {
            var i;

            for (i = 0; i < userAgentString.length; ++i)
            {
              if (CompareVersions(GetVersion(versionToCheck),
                GetVersion(userAgentString[i])) <= 0)
                return true;
            }
          }

          return false;
        }

        //
        // Extract the numeric part of the version string.
        //
        function GetVersion(versionString)
        {
          var numericString =
            versionString.match(/([0-9]+)\.([0-9]+)\.([0-9]+)/i);
          return numericString.slice(1);
        }

        //
        // Compare the 2 version strings by converting them to numeric format.
        //
        function CompareVersions(version1, version2)
        {
          for (i = 0; i < version1.length; ++i)
          {
            var number1 = new Number(version1[i]);
            var number2 = new Number(version2[i]);

            if (number1 < number2)
              return -1;

            if (number1 > number2)
              return 1;
          }

          return 0;
        }
       
        -->
        </SCRIPT>
      </HEAD>
     
      <BODY>
        <div id="result" />
      </BODY>
    </HTML>

    --------------------This is to check framework 3.5 change it to required one........................
    aryan
    • Marked as answer by Figo Fei Monday, December 1, 2008 4:41 AM
    Sunday, November 30, 2008 11:29 AM
  • If you're using setup project provided by Visual Studio, please refer to
    How to detect the installed version of the .NET Framework in a Visual Studio Setup and Deployment package
    http://support.microsoft.com/kb/315291

    And the forum is specially for setup project: ClickOnce and Setup & Deployment Projects

    thanks.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. http://forums.msdn.microsoft.com/en-US/vssetup/thread/60424309-bd78-4ca2-b618-03c4a16123b6
    • Marked as answer by Figo Fei Monday, December 1, 2008 4:41 AM
    Monday, December 1, 2008 4:39 AM

All replies

  • This is the code to confirm the frame work is installed or not....by running HTML page
    Hope you can include this in you application on startup or bootstrap .


    <HTML>
      <HEAD>
        <TITLE>Test for the .NET Framework 3.5</TITLE>
        <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8" />
        <SCRIPT LANGUAGE="JavaScript">
        <!--
        var dotNETRuntimeVersion = "3.5.0.0";
       
        function window::onload()
        {
          if (HasRuntimeVersion(dotNETRuntimeVersion))
          {
            result.innerText =
              "This machine has the correct version of the .NET Framework 3.5."
          }
          else
          {
            result.innerText =
              "This machine does not have the correct version of the .NET Framework 3.5." +
              " The required version is v" + dotNETRuntimeVersion + ".";
          }
          result.innerText += "\n\nThis machine's userAgent string is: " +
            navigator.userAgent + ".";
        }
       
        //
        // Retrieve the version from the user agent string and
        // compare with the specified version.
        //
        function HasRuntimeVersion(versionToCheck)
        {
          var userAgentString =
            navigator.userAgent.match(/.NET CLR [0-9.]+/g);

          if (userAgentString != null)
          {
            var i;

            for (i = 0; i < userAgentString.length; ++i)
            {
              if (CompareVersions(GetVersion(versionToCheck),
                GetVersion(userAgentString[i])) <= 0)
                return true;
            }
          }

          return false;
        }

        //
        // Extract the numeric part of the version string.
        //
        function GetVersion(versionString)
        {
          var numericString =
            versionString.match(/([0-9]+)\.([0-9]+)\.([0-9]+)/i);
          return numericString.slice(1);
        }

        //
        // Compare the 2 version strings by converting them to numeric format.
        //
        function CompareVersions(version1, version2)
        {
          for (i = 0; i < version1.length; ++i)
          {
            var number1 = new Number(version1[i]);
            var number2 = new Number(version2[i]);

            if (number1 < number2)
              return -1;

            if (number1 > number2)
              return 1;
          }

          return 0;
        }
       
        -->
        </SCRIPT>
      </HEAD>
     
      <BODY>
        <div id="result" />
      </BODY>
    </HTML>

    --------------------This is to check framework 3.5 change it to required one........................
    aryan
    • Marked as answer by Figo Fei Monday, December 1, 2008 4:41 AM
    Sunday, November 30, 2008 11:29 AM
  • If you're using setup project provided by Visual Studio, please refer to
    How to detect the installed version of the .NET Framework in a Visual Studio Setup and Deployment package
    http://support.microsoft.com/kb/315291

    And the forum is specially for setup project: ClickOnce and Setup & Deployment Projects

    thanks.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. http://forums.msdn.microsoft.com/en-US/vssetup/thread/60424309-bd78-4ca2-b618-03c4a16123b6
    • Marked as answer by Figo Fei Monday, December 1, 2008 4:41 AM
    Monday, December 1, 2008 4:39 AM
  • Hello Ramkumar,

    Best way is to create a batch file which contains 1) .Net framework 3.5 & 2) Your application .exe files,
    when you run your batch file i.e. "Install.bat"  it will install the framework 3.5 and then it will start your application.

    This what i have tried in my previous application while installing setup.

    ----------------------Batch file script "Install.bat"------------------------------

    @ECHO OFF
    ECHO Installing DotNet 3

    start /wait dotNetfx35setup.exe

    start /wait setup.exe
    exit
    --------------------------------------------------------------

    Let me know in case u have different approach, also you can write case in your batch file for instance when box contain .net framwork 3.0 or not etc....

    Ali

    Wednesday, December 3, 2008 8:11 AM