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 / May 2006

Tip: Looking for answers? Try searching our database.

what is wrong with my interop code

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
gs - 23 May 2006 01:26 GMT
I am using the visual studio express 2005's setting of "register com
interop". does the proper job of registering my Classslib as useable by
native(unmanaged)  com consumer?
Can any one confirm one way or another?

using the com interface from unmanaged application, I don't have any problem
calling functions returning only primitive data types and even strings.

However I am having problem using the assembly from the same native
application through
com interface when there is string array involved.  In the vb project I did
"enable com interop". and use the class library template.

the desired call signature by COM consumer is something like this
integer li_rc, li_sz
string  ls_out[]
string  ls_in

li_rc = myfcn(ls_in , ls_out, li_sz)   / li_sz is to contain the number of
the elements in ls_out
   // only ls_in is to pass by vale, the rest by reference

Vb classlib has something like this

Function myfcn( ByVal sIn As String,  _
        <Out()> <MarshalAs(UnmanagedType.LPArray,
ArraySubType:=UnmanagedType.LPStr, SizeParamIndex:=1)> ByRef sOut As
String(),_
        <Out()> ByRef iCnt As Integer) As Integer
       sOut = Split(sIn, vbTab)
       icnt  =  sOut.GetUpperBound(0) + 1
End Function
Dmytro Lapshyn [MVP] - 23 May 2006 08:23 GMT
Hi,

>I am using the visual studio express 2005's setting of "register com
>interop". does the proper job of registering my Classslib as useable by
>native(unmanaged)  com consumer?

It should. However, I am not sure this IDE setting *fully* registers your
assembly for COM interop. In VS 2003, I recall there were issues with the
lack of proper TLB registration and the code base when the "register com
interop" IDE setting was used.

You can consider adding pre- and post-build steps in which you would invoke
the regasm.exe command-line tool with all the proper arguments.

> However I am having problem using the assembly from the same native
> application through
> com interface when there is string array involved.  In the vb project I
> did
> "enable com interop". and use the class library template.

Try this workaround:

http://technolog.nl/EProgrammer/archive/2005/11/24/402.aspx

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.