George2

Hello everyone,


I am using C# to develop DLL using Visual Studio 2005 and .Net 2.0, and I have no idea of how to make my DLL work with applications on 64-bit platform. Above all, I do not utilize any new features in my DLL of 64-bit. So, I want to check the general rules,

1. For C#, is there a need to make two separate builds (32-bit and 64-bit) according to the application (32-bit or 64-bit) which uses the DLL i.e. provide 64-bit application my 64-bit C# DLL, and provide 32-bit application runs on 64-bit platform my 32-bit DLL

2. If we have to make two separate builds, how to do it in Visual Studio 2005 I only find a setting names for Any CPU in project --> properties.


thanks in advance,
George



Re: Visual C# General C# 64-bit DLL?

stygen

Hi george ,

Microsoft provides a cross compiler targeting 64 bit Machines from 32 bit machines

1) Yes there is a need to make seperate builds for a 64-bit application use a 64-bit C# DLL and for a 32 bit application use a 32 bit dll

2) in visual studio 2005 go to Project --> Properties --> Build Tab in that select the target platform from the Platform Combo Box

Hope this helped

Regards,

stygen





Re: Visual C# General C# 64-bit DLL?

Peter Ritchie

If your solution platform is set to "Any CPU", you don't have to do anything. When the assembly is deployed/installed and is access for the first time the JIT compiler on that platform will compile the code in 64-bit (assuming the processor is 64-bit).

You can target specific processors, if you want; and deploy two different assemblies (DLLs). But, unless there is a specific need to, I would just create processor-agnostic DLLs.






Re: Visual C# General C# 64-bit DLL?

George2

Thanks stygen,

I am wondering why people need to make separate 32-bit or 64-bit builds, since Any CPU can fit into 32-bit/64-bit on demand. Could you give an example why we need to make separate 32-bit and 64-bit builds please

regards,

George

stygen wrote:

Hi george ,

Microsoft provides a cross compiler targeting 64 bit Machines from 32 bit machines

1) Yes there is a need to make seperate builds for a 64-bit application use a 64-bit C# DLL and for a 32 bit application use a 32 bit dll

2) in visual studio 2005 go to Project --> Properties --> Build Tab in that select the target platform from the Platform Combo Box

Hope this helped

Regards,

stygen





Re: Visual C# General C# 64-bit DLL?

George2

Thanks Peter,

Peter Ritchie wrote:

If your solution platform is set to "Any CPU", you don't have to do anything. When the assembly is deployed/installed and is access for the first time the JIT compiler on that platform will compile the code in 64-bit (assuming the processor is 64-bit).

You can target specific processors, if you want; and deploy two different assemblies (DLLs). But, unless there is a specific need to, I would just create processor-agnostic DLLs.

I think if Any CPU settings can fit into both 32-bit and 64-bit on demand, why do we still need to make separate builds for 32-bit and 64-bit Could you give an example please

regards,

George





Re: Visual C# General C# 64-bit DLL?

Peter Ritchie

One reason may be that you're dependant on a DLL that has a 32-bit version and a 64-bit version; in which case you may need to create specific 32-bit and 64-bit versions of your assembly.






Re: Visual C# General C# 64-bit DLL?

George2

Thanks Peter,

Peter Ritchie wrote:
One reason may be that you're dependant on a DLL that has a 32-bit version and a 64-bit version; in which case you may need to create specific 32-bit and 64-bit versions of your assembly.

You mean I build 32-bit application and it works with the dependent 32-bit DLL And I also build a 64-bit application and it works with the dependent 64-bit DLL, right

But I think if I make the application as Any CPU, it could also work with 64-bit and 32-bit, right

regards,

George





Re: Visual C# General C# 64-bit DLL?

Peter Ritchie

George2 wrote:

Thanks Peter,

Peter Ritchie wrote:
One reason may be that you're dependant on a DLL that has a 32-bit version and a 64-bit version; in which case you may need to create specific 32-bit and 64-bit versions of your assembly.

You mean I build 32-bit application and it works with the dependent 32-bit DLL And I also build a 64-bit application and it works with the dependent 64-bit DLL, right

Right.

George2 wrote:
But I think if I make the application as Any CPU, it could also work with 64-bit and 32-bit, right

The application code will work on both 32-bit and 64-bit; but if you're dependant on a 64-bit DLL that can't be loaded (i.e. you can have a DllImport to it) on a 32-bit system. Which likely will generate some sort of "unable to load" exception when you try to run your application...






Re: Visual C# General C# 64-bit DLL?

George2

Thanks Peter,

DllImport you mean linker --> input --> add import library (.lib) From the discussion, I feel 64-bit support is too complicated to make decision, especially we have legacy 32-bit to support at the same time. :-)

regards,

George

Peter Ritchie wrote:

George2 wrote:

Thanks Peter,

Peter Ritchie wrote:
One reason may be that you're dependant on a DLL that has a 32-bit version and a 64-bit version; in which case you may need to create specific 32-bit and 64-bit versions of your assembly.

You mean I build 32-bit application and it works with the dependent 32-bit DLL And I also build a 64-bit application and it works with the dependent 64-bit DLL, right

Right.

George2 wrote:
But I think if I make the application as Any CPU, it could also work with 64-bit and 32-bit, right

The application code will work on both 32-bit and 64-bit; but if you're dependant on a 64-bit DLL that can't be loaded (i.e. you can have a DllImport to it) on a 32-bit system. Which likely will generate some sort of "unable to load" exception when you try to run your application...