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

Tip: Looking for answers? Try searching our database.

VB6 types marshaling

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Luigi - 24 Jun 2005 10:59 GMT
Hi all

I have a COM DLL written in VB6 that exposes a public class with a method
that can be summarized as follow

public function MyPublicMethod(...) as Variant
   ...
   MyPublicMethod = AnotherMethod(...)
   ...
end function

AnotherMethod is a function that returns a user defined type (call it
MyPublicType) that can is similar to the following

public type MyPublicType
   ....
   Member1 as AnotherPublicType
   ...
end type

where AnotherPublicType is another user defined public type.
Both MyPublicType and AnotherPublicType are defined as public member of a
public class.

I need to call this method from a C# application, so I added the reference
to the COM object (by AddReference of Visual Studio).
What happens is that when I call this method (the object is correctly
instantiated) I receive an exception that has almost the following message
(I'm traducing it from the italian text, so I don't know which is the correct
english message)

"It's not possible to map the specified record to a managed class"

The problems occurs when MyPublicMethod set the return value to a UDT: if I
change it as follows

public function MyPublicMethod(...) as Variant
   ...
   MyPublicMethod = 'hallo world'
   ...
end function

all works fine.

Does anybody can help me ??

Thanks a lot
Johannes Passing - 25 Jun 2005 15:37 GMT
Hi,

.Net does not really like Variants containing UDTs as well as SAFEARRAYs
  containing UDTs (your other post about nested UDTs).

You have not mentioned which .Net Version you are using - if I remember
right, .Net 1.1 SP 1 is the first version addressing this issue. Earlier
versions simply do not support it.

However, if you can go without UDTs, you will save yourself a lot of
trouble...

/Johannes

> Hi all
>
[quoted text clipped - 43 lines]
>
> Thanks a lot
Luigi - 28 Jun 2005 13:20 GMT
Thank you Johannes for your help.

>> You have not mentioned which .Net Version you are using - if I remember
>> right, .Net 1.1 SP 1 is the first version addressing this issue. Earlier
>> versions simply do not support it.

I'm using .NET 1.1 SP1 but is seems that it doesn't like nested structeres
at all.

>>However, if you can go without UDTs, you will save yourself a lot of
>>trouble...

Unfortunately I have no way to change the ActiveX DLL, so it seems that I'll
not be able to use it.

Bye

Rate this thread:







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.