방법:.NET Framework 3.5 설치 여부 검색How to: Detect Whether the .NET Framework 3.5 Is Installed

관리자를 대상으로 하는 시스템에서 Windows Presentation Foundation (WPF) 응용 프로그램을 배포할 수는 .NET Framework 3.5.NET Framework 3.5, 했는지 먼저 확인 해야 하는 .NET Framework 3.5.NET Framework 3.5 런타임이 있는지 합니다.Before administrators can deploy Windows Presentation Foundation (WPF) applications on a system that targets the .NET Framework 3.5.NET Framework 3.5, they must first confirm that the .NET Framework 3.5.NET Framework 3.5 runtime is present. 이 항목에서는 작성 된 스크립트 관리자가 결정 하는 데 사용할 수 있는 HTML/javascript 여부는 .NET Framework 3.5.NET Framework 3.5 는 시스템에 있습니다.This topic provides a script written in HTML/JavaScript that administrators can use to determine whether the .NET Framework 3.5.NET Framework 3.5 is present on a system.

참고

자세한 내용은 설치, 배포 및 검색에 .NET Framework.NET Framework, 참조 개발자를 위한.NET Framework 설치합니다.For more detailed information on installing, deploying, and detecting the .NET Framework.NET Framework, see Install the .NET Framework for developers.

예제Example

경우는 .NET Framework 3.5.NET Framework 3.5 가 설치 된 MSI ".NET CLR" 및 버전 번호를 추가 UserAgent 문자열입니다.When the .NET Framework 3.5.NET Framework 3.5 is installed, the MSI adds ".NET CLR" and the version number to the UserAgent string. 다음 예제에서는 간단한 HTML 페이지에 포함 된 스크립트를 보여 줍니다.The following example shows a script embedded in a simple HTML page. 스크립트를 확인할 UserAgent 문자열을 검색 여부는 .NET Framework 3.5.NET Framework 3.5 설치 되 고 검색 결과에 상태 메시지를 표시 합니다.The script searches the UserAgent string to determine whether the .NET Framework 3.5.NET Framework 3.5 is installed, and displays a status message on the results of the search.

참고

이 스크립트는 Internet Explorer에 대해 설계 되었습니다.This script is designed for Internet Explorer. 다른 브라우저 UserAgent 문자열에.NET CLR 정보를 포함 하지 않을 수 있습니다.Other browsers may not include .NET CLR information in the UserAgent string.

<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>  

".NET CLR" 버전에 대 한 검색 되 면 다음과 같은 유형의 상태 메시지가 나타납니다.If the search for the ".NET CLR " version is successful, the following type of status message appears:

This machine has the correct version of the .NET Framework 3.5.

This machine's userAgent string is: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 1.1.4322; InfoPath.2; .NET CLR 3.0.590; .NET CLR 3.5.20726; MS-RTC LM 8).

그렇지 않으면 다음과 같은 유형의 상태 메시지가 표시 됩니다.Otherwise, the following type of status message appears:

This machine does not have the correct version of the .NET Framework 3.5. The required version is v3.5.0.0.

This machine's userAgent string is: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 1.1.4322; InfoPath.2; .NET CLR 3.0.590; MS-RTC LM 8).

참고 항목See Also

.NET Framework 3.0 설치 여부 확인Detect Whether the .NET Framework 3.0 Is Installed