Accessing COM (VB6) User-Defined types (UDTs) from a VB.NET dll

  • Thread starter jimfollett1 via DotNetMonster.com
  • Start date
J

jimfollett1 via DotNetMonster.com

Hey all,

I was wondering if you could put me out of my misery (hopefully, not literaly)
..

I am currently trying to port some VB6 code to VB.NET because of a possible
significant performance improvement on a very large simulation based system.
All my variables are currently encapsulated in public UDTs. If I could
access these COM UDTs from a .NET dll, I will be sorted for porting the
important engine of the system without having to change any VB6 GUIs. I got
through the quagmire that is CCW (Com Callable Wrappers) and have a working .
NET dll with respect to accessing the .NET dll from VB6, but can't seem to
pass my UDTs from COM to .NET. They are complex multi-tiered, nested UDTs
within UDTs.

The question: can UDTs be passed (marshalled) from COM to .NET? If not,
should I scrap the UDTs, create a .NET structure or class and instantiate
that within COM in the first place?

cheers,
James
 
P

Paul Clement

¤ Hey all,
¤
¤ I was wondering if you could put me out of my misery (hopefully, not literaly)
¤ .
¤
¤ I am currently trying to port some VB6 code to VB.NET because of a possible
¤ significant performance improvement on a very large simulation based system.
¤ All my variables are currently encapsulated in public UDTs. If I could
¤ access these COM UDTs from a .NET dll, I will be sorted for porting the
¤ important engine of the system without having to change any VB6 GUIs. I got
¤ through the quagmire that is CCW (Com Callable Wrappers) and have a working .
¤ NET dll with respect to accessing the .NET dll from VB6, but can't seem to
¤ pass my UDTs from COM to .NET. They are complex multi-tiered, nested UDTs
¤ within UDTs.
¤
¤ The question: can UDTs be passed (marshalled) from COM to .NET? If not,
¤ should I scrap the UDTs, create a .NET structure or class and instantiate
¤ that within COM in the first place?

This is more trouble than it's worth. For a while you couldn't marshal a UDT via COM either until
they added support via Variants and SafeArrays.

I would highly recommend you use classes instead.


Paul
~~~~
Microsoft MVP (Visual Basic)
 
J

jimfollett1 via DotNetMonster.com

Thanks Paul for your reply.

If accessing COM UDTs from .NET is not really an option, then I have no easy
solution to the problem. I had to use UDTs in the first place with VB6
because VB6 classes don't handle arrays well, and now this has the knock-on
effect that my code is not very portable to .NET - doh.

I am trying out replacing my COM UDTs with .NET public classes called from
VB6, but proof of concept is no small task sadly. This is because the memory
strucutres are a tad complex and a great deal of changes will have to be
made to alter the implementation from array based structures to "collection"
classes. If I used "ArrayList" classes would this change over be minimised
because interating is the same type of coding, UBound exists etc?

cheers, James
 
P

Paul Clement

¤ Thanks Paul for your reply.
¤
¤ If accessing COM UDTs from .NET is not really an option, then I have no easy
¤ solution to the problem. I had to use UDTs in the first place with VB6
¤ because VB6 classes don't handle arrays well, and now this has the knock-on
¤ effect that my code is not very portable to .NET - doh.
¤
¤ I am trying out replacing my COM UDTs with .NET public classes called from
¤ VB6, but proof of concept is no small task sadly. This is because the memory
¤ strucutres are a tad complex and a great deal of changes will have to be
¤ made to alter the implementation from array based structures to "collection"
¤ classes. If I used "ArrayList" classes would this change over be minimised
¤ because interating is the same type of coding, UBound exists etc?
¤
¤ cheers, James

I didn't want to imply that it wasn't an option just that it might be a bit of a hassle.

I'm probably not going to be able to help you with the nested UDT issue so you may want to try
posting your question in the microsoft.public.dotnet.framework.interop newsgroup.


Paul
~~~~
Microsoft MVP (Visual Basic)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top