Ho un server ASP.NET a cui non ho accesso diretto. Come posso scrivere un'applicazione .NET che determinerà a livello di programmazione se ASP.NET esegue 32 bit contro 64 bit?Come determinare l'utilizzo di ASP.NET da 32 bit a 64 bit?
5
A
risposta
4
1
È possibile utilizzare PInvoke
Questo è un esempio di codice trovato here.
private enum Platform
{
X86,
X64,
Unknown
}
internal const ushort PROCESSOR_ARCHITECTURE_INTEL = 0;
internal const ushort PROCESSOR_ARCHITECTURE_IA64 = 6;
internal const ushort PROCESSOR_ARCHITECTURE_AMD64 = 9;
internal const ushort PROCESSOR_ARCHITECTURE_UNKNOWN = 0xFFFF;
[StructLayout(LayoutKind.Sequential)]
internal struct SYSTEM_INFO
{
public ushort wProcessorArchitecture;
public ushort wReserved;
public uint dwPageSize;
public IntPtr lpMinimumApplicationAddress;
public IntPtr lpMaximumApplicationAddress;
public UIntPtr dwActiveProcessorMask;
public uint dwNumberOfProcessors;
public uint dwProcessorType;
public uint dwAllocationGranularity;
public ushort wProcessorLevel;
public ushort wProcessorRevision;
};
[DllImport("kernel32.dll")]
internal static extern void GetNativeSystemInfo(ref SYSTEM_INFO lpSystemInfo);
private static Platform GetPlatform()
{
SYSTEM_INFO sysInfo = new SYSTEM_INFO();
GetNativeSystemInfo(ref sysInfo);
switch (sysInfo.wProcessorArchitecture)
{
case PROCESSOR_ARCHITECTURE_AMD64:
return Platform.X64;
case PROCESSOR_ARCHITECTURE_INTEL:
return Platform.X86;
default:
return Platform.Unknown;
}
}
2
Il modo più semplice è quello di fare questo:
Int32 addressWidth = IntPtr.Size * 8;
dal IntPtr.Size
è 4 byte su un'architettura a 32 bit e 8 byte su architettura a 64 bit.
Problemi correlati
- 1. Interop da 64 a 32 bit - come?
- 2. Compilare ASP.NET a 64 BIT
- 3. Determinazione dell'architettura a 32/64 bit nell'assemblaggio
- 4. Compatibilità Java 32-bit vs 64-bit
- 5. 64 bit per divisione 32 bit
- 6. Perché MSBuild a 64 bit carica estensioni a 32 bit?
- 7. iPhone OS 64 bit o 32 bit?
- 8. Compilare binario a 32 bit su sistema a 64 bit
- 9. Port 32 bit driver di Windows a 64 bit Windows
- 10. SQL Server 2012 a 32 bit o 64 bit su computer a 64 bit?
- 11. Come determinare se un'applicazione .NET è 32 o 64 bit?
- 12. Istruzione SSE per sommare interi 32 bit a 64 bit
- 13. Inno Setup installazione dll a 32 bit e 64 bit
- 14. prestazioni a 32 bit vs 64 bit aritmetica
- 15. Accesso a file da 2,3,4 GB in processo a 32 bit su Windows a 64 bit (o 32 bit)
- 16. MapViewOfFile condiviso tra processi a 32 bit e 64 bit
- 17. Build 32-bit con llvm-gcc a 64 bit
- 18. Compilando 32 bit Assembler su ubuntu a 64 bit
- 19. Esegui libreria a 32 bit su iPhone 5s 64 bit
- 20. Come scrivere codice convertibile, 32 bit/64 bit?
- 21. Modo elegante e sicuro per determinare se l'architettura è a 32 bit o 64 bit
- 22. Operatore bit a bit per ottenere byte da 32 bit
- 23. Esegui AnyCPU come 32-bit su sistemi 64-bit
- 24. Come verificare il kernel 32-bit/64-bit per Linux
- 25. Test di Visual Studio Unit 32-bit e 64-bit
- 26. Come ottenere informazioni sul computer? [32 bit o 64 bit]
- 27. Come ENUM moduli in un processo a 64 bit da una a 32 bit WOW elaborare
- 28. Come avviare un processo a 64 bit da un processo a 32 bit
- 29. Come avviare PowerShell a 64 bit da cmd.exe a 32 bit?
- 30. Come posso leggere la chiave del registro a 64 bit da un processo a 32 bit?
Questa è una buona soluzione se il .NET applicazione è in esecuzione con un x86 forzata compilare bandiera per altri motivi, ma è ancora necessario per determinare se il sistema host è di 64 po. – Mike