Visual Studio Development Bookmark and Share   
 index > Visual C# Express Edition > int64 and long woes...
 

int64 and long woes...

OK, I know that in C# long is simply a shortcut to int64.  But I am looking to make an app that is COM visible.  The other side of the application expects to see a type library with this kind of interface:
...
        [id(0x60020002), propget]
        HRESULT gParentWnd([out, retval] long* pRetVal);
        [id(0x60020002), propput]
        HRESULT gParentWnd([in] long pRetVal);
...
<This is the disassembled view of a type library which shows the interface method signatures>


The closest I can get in C# is this:

        [id(0x60020002), propget]
        HRESULT gParentWnd([out, retval] int64* pRetVal);
        [id(0x60020002), propput]
        HRESULT gParentWnd([in] int64 pRetVal);


See how the longs are no longer longs, they are int64.  This is a problem on the other end where they are looking for signatures that contain the long data type.  I can't seem to get VC# to output long as the data type.  Anyone know of a workaround?
Steve Luke  Thursday, October 08, 2009 10:01 PM
You're almost right.

In C#, long is an Int64.

However, in IDL , long is a 32bit integer value.

To make this work, setup your C# project with int , not long .  C#'s int matches the long type in IDL (and C++, btw).

Reed Copsey, Jr. - http://reedcopsey.com
  • Marked As Answer bySteve Luke Friday, October 09, 2009 2:14 AM
  •  
Reed Copsey, Jr.  Thursday, October 08, 2009 11:09 PM
You're almost right.

In C#, long is an Int64.

However, in IDL , long is a 32bit integer value.

To make this work, setup your C# project with int , not long .  C#'s int matches the long type in IDL (and C++, btw).

Reed Copsey, Jr. - http://reedcopsey.com
  • Marked As Answer bySteve Luke Friday, October 09, 2009 2:14 AM
  •  
Reed Copsey, Jr.  Thursday, October 08, 2009 11:09 PM
Perfect.  Thanks.  I pretty much assumed that int would come across as int32.  Thanks again.

Steve
Steve Luke  Friday, October 09, 2009 2:16 AM

You can use google to search for other answers

Custom Search

More Threads

• Target x86 platform in VC# Express.
• PictureBox / Form.Controls Issue
• How do I add a file as a link between different projects in Visual C# Express?
• How can I copy data from an .xls file without opening excel
• Any way to get KeyPress in a Panel?
• Reading and Writing ListView's to file, with a twist
• Form control in C#
• Creating Speech-based programs
• building a new form
• i need my program to wait...