Custom Controls on x64

Discussion in 'ASP .Net Building Controls' started by Leslie, Oct 23, 2007.

  1. Leslie

    Leslie Guest

    I have developed a Windows Forms Control (WFC) which is used in a web page.
    The control is developed in C# using the 2.0 framework and the control
    invokes a dll that is written in C++. I reference the WFC using the following
    syntax:
    <object id="SmsInfo" height="1" width="1"
    classid="http:SmsInfo.dll#SmsInfo.GetSmsInfo" >
    The control then makes calls to C++ dll. Everything works great in 32 bit.
    However, I would like to provide 64 bit support.
    If the user browses to my web site using the x64 version of IE do I need a
    different version of my custom WFC or will the C# WFC work correctly using
    the x64 version of the 2.0 framework?

    Secondly, I will need to compile an x64 version of my C++ dll. How will the
    browser (and my WFC) know which version of the dll to use? Will I need to
    build two seperate versions of the WFC and reference the x64 or x32 version
    specifically in each version of the WFC? Other than the x64 or x32
    reference, the WFC should be identical in both versions.

    thanks,

    Leslie
    Leslie
    Leslie, Oct 23, 2007
    #1
    1. Advertising

  2. Hi Leslie,

    Based on my understanding, you should be able to compile your C# Windows
    Forms control library using targetd platform "AnyCPU". This is the also
    default platform type, assemblied compiled in this way is process
    independent. If it's executed or loaded by 32-bit os or host process, it
    will be JIT(just-in-time) compiled as 32-bit native code; and the same for
    64-bit.

    For your C++ DLL, you have to compile two versions, one for 32-bit, will be
    installed to %windir%\syswow64 on 64-bit os, installed to %windir%\system32
    on 32-bit os. For 64-bit version, install to %windir%\system32.

    Hope this helps.


    Regards,
    Walter Wang (, remove 'online.')
    Microsoft Online Community Support

    ==================================================
    When responding to posts, please "Reply to Group" via your newsreader so
    that others may learn and benefit from your issue.
    ==================================================

    This posting is provided "AS IS" with no warranties, and confers no rights.
    Walter Wang [MSFT], Oct 25, 2007
    #2
    1. Advertising

  3. Leslie

    Leslie Guest

    Walter,

    Thanks for your help. I believe I understand the approach for the C# code,
    and that should work well. Currently the C++ DLL is downloaded from the web
    site as needed. Is there no way to make that approach continue to work in the
    mixed 32 bit and 64 bit environments?

    Thanks,

    Leslie

    ""Walter Wang [MSFT]"" wrote:

    > Hi Leslie,
    >
    > Based on my understanding, you should be able to compile your C# Windows
    > Forms control library using targetd platform "AnyCPU". This is the also
    > default platform type, assemblied compiled in this way is process
    > independent. If it's executed or loaded by 32-bit os or host process, it
    > will be JIT(just-in-time) compiled as 32-bit native code; and the same for
    > 64-bit.
    >
    > For your C++ DLL, you have to compile two versions, one for 32-bit, will be
    > installed to %windir%\syswow64 on 64-bit os, installed to %windir%\system32
    > on 32-bit os. For 64-bit version, install to %windir%\system32.
    >
    > Hope this helps.
    >
    >
    > Regards,
    > Walter Wang (, remove 'online.')
    > Microsoft Online Community Support
    >
    > ==================================================
    > When responding to posts, please "Reply to Group" via your newsreader so
    > that others may learn and benefit from your issue.
    > ==================================================
    >
    > This posting is provided "AS IS" with no warranties, and confers no rights.
    >
    >
    Leslie, Oct 25, 2007
    #3
  4. Hi Leslie,

    Sorry for the delay. I was not in office last Friday.

    This is a quick note to let you know that I am performing research on this
    issue and will get back to you as soon as possible. I appreciate your
    patience.


    Regards,
    Walter Wang (, remove 'online.')
    Microsoft Online Community Support

    ==================================================
    When responding to posts, please "Reply to Group" via your newsreader so
    that others may learn and benefit from your issue.
    ==================================================

    This posting is provided "AS IS" with no warranties, and confers no rights.
    Walter Wang [MSFT], Oct 29, 2007
    #4
  5. Hi Leslie,

    I was wondering how's currently you're download the C++ DLL and where is it
    installed to?

    There's one possible solution to this is to use dynamic P/Invoke to load
    different versions of the DLL according to 32-bit or 64-bit environment
    that the control is running in. You can determine this by checking
    IntPtr.Size, if it's equal to 4, it's 32-bit, if it's equal to 8, it's
    64-bit.

    #Junfeng Zhang's Windows Programming Notes : Dynamic PInvoke
    http://blogs.msdn.com/junfeng/archive/2004/07/14/181932.aspx


    Please feel free to let me know if there's anything unclear. Thanks.


    Regards,
    Walter Wang (, remove 'online.')
    Microsoft Online Community Support

    ==================================================
    When responding to posts, please "Reply to Group" via your newsreader so
    that others may learn and benefit from your issue.
    ==================================================

    This posting is provided "AS IS" with no warranties, and confers no rights.
    Walter Wang [MSFT], Oct 29, 2007
    #5
  6. Leslie

    Leslie Guest

    Currently I have a Windows Forms Control which is downloaded to the client
    browser. The WFC uses the C++ dll. The reference that the C# control holds on
    the C++ dll includes the property of "Copy Local=True". When the WFC is
    downloaded, the C++ dll is downloaded as well.

    Thanks for your help.

    Leslie

    ""Walter Wang [MSFT]"" wrote:

    > Hi Leslie,
    >
    > I was wondering how's currently you're download the C++ DLL and where is it
    > installed to?
    >
    > There's one possible solution to this is to use dynamic P/Invoke to load
    > different versions of the DLL according to 32-bit or 64-bit environment
    > that the control is running in. You can determine this by checking
    > IntPtr.Size, if it's equal to 4, it's 32-bit, if it's equal to 8, it's
    > 64-bit.
    >
    > #Junfeng Zhang's Windows Programming Notes : Dynamic PInvoke
    > http://blogs.msdn.com/junfeng/archive/2004/07/14/181932.aspx
    >
    >
    > Please feel free to let me know if there's anything unclear. Thanks.
    >
    >
    > Regards,
    > Walter Wang (, remove 'online.')
    > Microsoft Online Community Support
    >
    > ==================================================
    > When responding to posts, please "Reply to Group" via your newsreader so
    > that others may learn and benefit from your issue.
    > ==================================================
    >
    > This posting is provided "AS IS" with no warranties, and confers no rights.
    >
    >
    Leslie, Oct 29, 2007
    #6
  7. Hi Leslie,

    So the C++ dll is a managed assembly built with C++/CLI, right? If this is
    the case, you can try to use /clr:safe switch to generate safe IL code of
    the C++ managed assembly. In this case, the generated IL code is also
    processor independent, which means it will also be JIT compiled as 32-bit
    or 64-bit native code according to the host process.

    I have a related discussion here for your reference:

    http://msdn.microsoft.com/newsgroups/managed/default.aspx?dg=microsoft.publi
    c.dotnet.framework.windowsforms.controls&tid=6e96ebc9-5507-425a-a27b-0950d94
    a3584&m=1&p=1

    Regards,
    Walter Wang (, remove 'online.')
    Microsoft Online Community Support

    ==================================================
    When responding to posts, please "Reply to Group" via your newsreader so
    that others may learn and benefit from your issue.
    ==================================================

    This posting is provided "AS IS" with no warranties, and confers no rights.
    Walter Wang [MSFT], Oct 30, 2007
    #7
  8. Leslie

    Leslie Guest

    Walter,

    This is good to know. Thanks very much for the additional information.

    Leslie

    ""Walter Wang [MSFT]"" wrote:

    > Hi Leslie,
    >
    > So the C++ dll is a managed assembly built with C++/CLI, right? If this is
    > the case, you can try to use /clr:safe switch to generate safe IL code of
    > the C++ managed assembly. In this case, the generated IL code is also
    > processor independent, which means it will also be JIT compiled as 32-bit
    > or 64-bit native code according to the host process.
    >
    > I have a related discussion here for your reference:
    >
    > http://msdn.microsoft.com/newsgroups/managed/default.aspx?dg=microsoft.publi
    > c.dotnet.framework.windowsforms.controls&tid=6e96ebc9-5507-425a-a27b-0950d94
    > a3584&m=1&p=1
    >
    > Regards,
    > Walter Wang (, remove 'online.')
    > Microsoft Online Community Support
    >
    > ==================================================
    > When responding to posts, please "Reply to Group" via your newsreader so
    > that others may learn and benefit from your issue.
    > ==================================================
    >
    > This posting is provided "AS IS" with no warranties, and confers no rights.
    >
    >
    Leslie, Oct 30, 2007
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark Oliver

    x64 PC approved manufacturers

    Mark Oliver, Feb 5, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    316
    Joerg Jooss
    Feb 6, 2005
  2. Shan McArthur
    Replies:
    3
    Views:
    5,619
    Juan T. Llibre
    Jul 20, 2005
  3. Adrian Parker

    ASP.NET Tab missing in IIS on 2003 x64

    Adrian Parker, Dec 3, 2005, in forum: ASP .Net
    Replies:
    10
    Views:
    23,936
    =?Utf-8?B?UGV0ZXI=?=
    Feb 25, 2006
  4. Felix Joachim
    Replies:
    0
    Views:
    511
    Felix Joachim
    Dec 31, 2005
  5. rodchar
    Replies:
    0
    Views:
    379
    rodchar
    Nov 26, 2007
Loading...

Share This Page