PC Review


Reply
Thread Tools Rate Thread

COM Interop - MarshalAs

 
 
Michael Moreno
Guest
Posts: n/a
 
      9th Mar 2005
Hello,

I have a .Net DLL that I use as a COM Server.

I would like to return a SafeArray of double to a VB 6 client.

I have declared this interface

Public Interface ITest
...
Function RetSafe() As <MarshalAs(UnmanagedType.SafeArray,
SafeArraySubType:=VarEnum.VT_R8)> Double()
End Interface

And have implemented a test code:

Public Function RetSafe() As Double() Implements ITest.RetSafe
Dim v As Double()
Dim i As Int16

ReDim v(10)

For i = 0 To v.Length
v(i) = i
Next

RetSafe = v
End Function

In the client, when I do

Dim v as variant
....
v = Test.RetSafe

I get a big crash.

I could not find a way to return a SafeArray in a function. Any idea
how to do it please?

thanks

--
----
http://michael.moreno.free.fr/

 
Reply With Quote
 
 
 
 
Michael Moreno
Guest
Posts: n/a
 
      9th Mar 2005
Please read

> For i = 0 To v.Length-1


instead of

> For i = 0 To v.Length


--
----
http://michael.moreno.free.fr/

 
Reply With Quote
 
Michael Moreno
Guest
Posts: n/a
 
      9th Mar 2005
The answer is simple : just return an array and COM interop does the
job.

--

----------------------------------------------

http://michael.moreno.free.fr/

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Interoperation the MarshalAs attribute Tony Johansson Microsoft C# .NET 0 26th Apr 2010 10:20 AM
Why and when to use MarshalAs? Milsnips Microsoft Dot NET Compact Framework 1 23rd Mar 2007 12:10 PM
MarshalAs attribute? =?Utf-8?B?SGVsZW4gV2Fybg==?= Microsoft Dot NET Compact Framework 1 26th Jun 2006 03:17 AM
need help with ArraySubType in MarshalAs jg Microsoft VB .NET 5 20th Oct 2005 01:07 PM
Newbie - When to use MarshalAs.UnmanagedType?? Dirk Schulze Microsoft C# .NET 1 15th Jul 2003 09:28 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:23 PM.