Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / April 2007

Tip: Looking for answers? Try searching our database.

Question about C# & non-automation compliant interfaces

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
carl_bevil@yahoo.com - 18 Apr 2007 23:07 GMT
Hi all.  I have searched on the web and usenet but haven't seen a good
solution for this problem; there may not be one that meets my needs.
But I thought I'd ask here; if you can help I'd appreciate it.

I have a COM interface that I would like a C# object to implement.  I
also have a C++ DLL that calls some methods of objects that implement
this interface, and I intend to call my C# object from the C++ DLL.
The problem is that one of the methods in the interface uses a raw
BYTE* as a pointer to an array of data.  This was done for performance
reasons (there is an alternate method using a SAFEARRAY, but I need to
implement both methods).

When I tell Visual Studio to implement the interface, it lists the
first parameter as type "ref byte".  I'd much rather it was a byte[]
or an IntPtr.  But if I change it, the method signature changes and I
get errors about not implementing the proper interface.

The interop assembly was created using tlbimp.  I've read about
manually editing the IL using ILDASM, but this is not such a good
solution, as every time we re-create the interop assembly, someone has
to remember to go in and manually edit this method.

So I'm hoping to find a solution that does not require manual editing
of the interop assembly, does not require changing the signature of
the method in question, and preferably does not use unsafe code.

The C++/COM method looks like this:

HRESULT Method(BYTE* data, int dataSize);

the equivalent C# method becomes:

void Interface.Method(ref byte data, int dataSize);

Can anyone help?

Thanks,

Carl
carl_bevil@yahoo.com - 22 Apr 2007 06:46 GMT
Guess this is not possible after all, I'll have to make a compromise
somewhere.  Ah well.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.