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 / November 2005

Tip: Looking for answers? Try searching our database.

vararg SAFEARRAY(VARIANT)* in C#

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ruslan Popov - 14 Nov 2005 11:56 GMT
Hello,

Is there a way to expose to COM a method of a C# type according to the
following IDL:

[vararg] void MyMethod([in, out] SAFEARRAY(VARIANT)* params)

Signature

Best regards,
Ruslan Popov

"Peter Huang" [MSFT] - 15 Nov 2005 08:57 GMT
Hi

Here is a sample for your reference.
    [ClassInterface(ClassInterfaceType.AutoDual)]
    public class TestClass
    {
        public void
MyMethod([MarshalAs(UnmanagedType.SafeArray,SafeArraySubType=VarEnum.VT_VARI
ANT)]ref System.Array param)
        {
            ;
        }
    }

Also here is link about Default Marshaling for Arrays in .NET.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm
l/cpconDefaultMarshalingForArrays.asp

Best regards,

Peter Huang
Microsoft Online Partner Support

Signature

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Ruslan Popov - 16 Nov 2005 08:31 GMT
Hi Peter,

If you look at the resulting IDL more carefully, you'll see your method is
exposed without the vararg attribute, which was the main point. Well, I
managed to get what I want automatically by creating a NAnt task for editing
IDL. Thanks for your help.

Signature

Best regards,
Ruslan Popov

"Peter Huang" [MSFT] - 16 Nov 2005 11:32 GMT
Hi

Thanks for your knowledge sharing.

Best regards,

Peter Huang
Microsoft Online Partner Support

Signature

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.


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.