어떻게 응용 프로그램에서 사용중인 dotnet의 버전을 C# 응용 프로그램 자체에서 확인할 수 있습니까?내 dotnet 버전 확인
6
A
답변
12
Environment.Version
을 사용하십시오. 응용 프로그램을 실행하는 .NET의 정확한 버전을 제공합니다.
공용 언어 런타임의 주 버전, 부 버전, 빌드 버전 및 수정 버전 번호를 설명하는 Version 개체를 가져옵니다.
는 프레임 워크의 버전이 설치되어 알아 this SO 질문과 답변을 참조하십시오. 너트 쉘에서 레지스트리를 파헤쳐 야합니다.
6
당신은을 사용할 수 있습니다
Environment.Version
는 .NET 런타임의 버전 번호를 얻을 수 있습니다.
0
콘솔 응용 프로그램이 클래스를 추가 만들고이를
은 Visual Studio에서using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication2
{
public class GetDotNetVersion
{
public static void Get45PlusFromRegistry()
{
const string subkey = @"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\";
using (RegistryKey ndpKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32).OpenSubKey(subkey))
{
if (ndpKey != null && ndpKey.GetValue("Release") != null)
{
Console.WriteLine(".NET Framework Version: " + CheckFor45PlusVersion((int)ndpKey.GetValue("Release")));
}
else
{
Console.WriteLine(".NET Framework Version 4.5 or later is not detected.");
}
}
}
// Checking the version using >= will enable forward compatibility.
private static string CheckFor45PlusVersion(int releaseKey)
{
if (releaseKey >= 394802)
return "4.6.2 or later";
if (releaseKey >= 394254)
{
return "4.6.1";
}
if (releaseKey >= 393295)
{
return "4.6";
}
if ((releaseKey >= 379893))
{
return "4.5.2";
}
if ((releaseKey >= 378675))
{
return "4.5.1";
}
if ((releaseKey >= 378389))
{
return "4.5";
}
// This code should never execute.
// that 4.5 or later is installed.
return "No 4.5 or later version detected";
}
}
// Calling the GetDotNetVersion.Get45PlusFromRegistry method produces
// output like the following:
// .NET Framework Version: 4.6.1
}
+0
이 답변으로 현재 문제 해결에 OP가 도움이되는 방법에 대한 설명과 함께 몇 가지 설명을 추가하십시오. –
0
, 이> Nutget 패키지 관리 -> 패키지 관리자 콘솔 유형 DOTNET 에 --version 을 도구 -로 이동 실행 그리고 여기에 간다!
관련 문제
- 1. 버전 관리에서 최신 버전 확인
- 2. gem 버전 번호 확인
- 3. 연결된 DLL 버전 확인
- 4. 사용한 DAO 버전 확인
- 5. iPhone 펌웨어 버전 확인
- 6. easy_install/setuptools의 버전 확인
- 7. 응용 프로그램 버전 확인
- 8. dotnet fuscator
- 9. 모바일 인터넷 익스플로러 버전 확인
- 10. Perl에서 버전 번호 유효성 확인
- 11. 런타임시 파이썬 모듈 버전 확인
- 12. C# FtpWebRequest 파일 버전 확인
- 13. 레지스트리에서 설치된 프로그램 버전 확인
- 14. Inno Setup에서 Windows 버전 확인
- 15. Oracle Warehouse Builder 버전 확인
- 16. Windows : 실행중인 프로세스의 버전 확인
- 17. PHP - 스크립트 버전 확인 방법
- 18. 설치하지 않고 MSI의 버전 확인
- 19. asp.net mvc 3 버전 확인
- 20. 레이크 전략, DotNet 구현
- 21. dotNET framework가 php로 설치되었습니다
- 22. Silverlight 4 내 박스 확인
- 23. dotnet 핵무기 오류
- 24. 프로그래밍 방식 DOTNET
- 25. dotnet nuke error
- 26. 연결된 서버의 SQL Server 버전 확인
- 27. 설치된 Excel 버전 확인 및 실행
- 28. dotnet System.Web.Caching.Cache 대 System.Runtime.Caching.MemoryCache
- 29. DotNet - int * 란 무엇입니까?
- 30. DotNet Oracle ORM
응용 프로그램에서 요구하는 최소 버전을 의미합니까? (프로젝트 파일의 TargetFrameworkVersion attr) –
사실 현재 응용 프로그램 프레임 워크의 경로가 필요합니다. 내 응용 프로그램은 현재 실행중인 버전에서 일부 exe를 실행해야합니다. 즉, 내 응용 프로그램이 2.0을 사용하는 경우 .net 2.0 폴더에서 exe를 선택하고 4를 사용하는 경우 .net 4.0 폴더에서 exe를 선택합니다. – hungryMind