none
dot net interop failing to get data from .net dll called from native code on x64 windows server 2008 RRS feed

  • General discussion

  • Hi,

    I have developed a CSharp.Net dll that is getting used by native code in c++ using interop. I am using event sink technique to consume the data from dot net dll.

    The work is going fine on 32 bit machine, no problem at all.

    but, on 64 bit windows server 2008 I am not receiving data properly from dot net dll 

    Here is the structure I am using,

    [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi)]

    public class MyDemo

    {

    public IntPtr ptr1,

    .

    .

    .

    public IntPtr ptr9,

    public String str1,

    .

    .

    .public String str6

    I am receiving false values for few InPtr fields and bad pointer for few string, although few string are getting values of other string fields ,

    I don't have any idea what's going on,

    please help!

     


    Wednesday, April 30, 2014 4:44 AM

All replies

  • Hi Yashzee,

    I assume this problem is caused by x64. If your component is an in-process COM component then you'll have to rethink things as a 64 bit process can't use 32 bit in process COM components. You could force your server to run under x86 so that you can access the components (they'll both be 32 bit processes). If you don't want to do this then you'll have to see if there a x64 bit version of the COM components you're using.

    Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, May 1, 2014 3:08 AM
    Moderator
  • Hi Herro,

    Thanks for reply,

    I built my .net dll using x64 build and used in vc++ with WIN32 build, then things are working properly, I am getting data properly from dll,

    But, when I tried build .net dll using x64 and vc++with x64 build, then problem arise, I was not getting field data properly

    Thursday, May 1, 2014 8:41 AM
  • Hi Yashzee,

    If you need the net assembly both run on x86 and x64, I think you should change its target to “any” – it can be run in both 64 bit process and a 32bit process. It is determined by the platform that the program is being executed on.  This will avoid many platform problem.

    http://stackoverflow.com/questions/1190842/in-visual-studio-how-to-correctly-build-an-application-for-64-bit-machines.

    Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, May 2, 2014 6:10 AM
    Moderator
  • Hi Herro,

    Thanks, very interesting article from Rick Byers,

    Sorry, I didn't told you I already tried build dll using AnyCPU configuration, but didn't worked with x64 build of VC++ code

    Friday, May 2, 2014 8:31 AM