nix86
nix86

Reputation: 3047

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.

Upvotes: 0

Views: 85

Answers (1)

nix86
nix86

Reputation: 3047

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
        }

Upvotes: 1

Related Questions