简体   繁体   中英

How can I detect, programmatically, whether a DLL is compiled 32bit or 64bit in .NET?

So far I have been able to load the dll using the following code:

Assembly^ assembly = Assembly::LoadFrom(pathDll);

But I don't know how to detect whether it's 32 or 64 bits.

I think that I've found the answer. Off course, first of all you must get the assembly associated with the dll though the following line of code:

Assembly^ assembly = Assembly::LoadFrom(pathDll);

Then you can get the information about the platform through the following code:

ProcessorArchitecture processor_architecture = assembly->GetName()->ProcessorArchitecture;
        if (ProcessorArchitecture::Amd64 == processor_architecture)
        {
            // 64bits
        }
        if (ProcessorArchitecture::X86 == processor_architecture)
        {
            //32 bits
        }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM