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 / .NET SDK / May 2004

Tip: Looking for answers? Try searching our database.

Type Library conversion problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Norman Ordas - 15 Apr 2004 08:45 GMT
(Type your message here)
I tried using the tlbimp.exe utility of .NET sdk to import a type library(a C API) to a compatible assembly code. I was succesful at doing that and was able to Add a Reference to the namespace i assigned. However when I tried to get the function of the imported assembly code its not there!!The enumtypes, deftypes, constants were present except for all the functions innate to the library. Has anyone encountered the same scenario? Should i program it now in unmanaged code using .NET's interop services if im unsuccessful of doing the latter one?
Mattias Sj?gren - 15 Apr 2004 13:25 GMT
>Has anyone encountered the same scenario? Should i program it now in unmanaged code using .NET's interop services if im unsuccessful of doing the latter one?

Were these functions in a module in the typelib? TlbImp imports pretty
much anything (coclasses, interfaces and so on) except modules, so
that would explain the missing functions.

I have a semi working tool that reads typelib modules and generates
DllImport methods for the the functions. If you want you can mail me
the typelib and I'll see if it generates something useful.

Mattias

Signature

Mattias Sjögren [MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Norman Ordas - 23 Apr 2004 08:36 GMT
Using P/Invoke how would i know that i should be passing "by value" or "by  reference" to the arguments of a method or function of the DLL
2. Equivalent type in .Net of the used data type for each variable (e.g what's the equivalent type of BSTR in VB.Net/C#
3. In the type library it says
VARIANT_BOOL _stdcall NE_QueryElementByID
                       [in] long net,
                       [in] ElementTypeEnum eltype,
                       [in, out] IDAttRec* id,
                       [in, out] HandleAttRec* h)

This is the way i called it in VB.Net...is this correct
..
<DllImport("neteng.dll")>
Public Shared Function NE_QueryElementByID(ByRef net As Long, ByRef eltype As ElementTypeEnum, ByRef id As IDAttRec, ByRef h As HandleAttRec) As Boolea
End Functio
..

Dim h1 As HandleAttRec      
hi.Handle =
Dim id1 As IDAttRec  
Dim m_startid As Int32 = 442

id1.UserID = 9
id1.LayerKey =
dim bol as Boolean = NE_QueryElementByID(net, ElementTypeEnum.NE_EDGE, id1, h1

Tnx a lot!
Mattias Sj?gren - 12 May 2004 08:58 GMT
>2. Equivalent type in .Net of the used data type for each variable (e.g what's the equivalent type of BSTR in VB.Net/C#?

<MarshalAs(UnmanagedType.BStr)> String

>This is the way i called it in VB.Net...is this correct?
>...
><DllImport("neteng.dll")> _
>Public Shared Function NE_QueryElementByID(ByRef net As Long, ByRef eltype As ElementTypeEnum, ByRef id As IDAttRec, ByRef h As HandleAttRec) As Boolean
>End Function

No, but try

Public Shared Function NE_QueryElementByID(ByVal net As Integer, ByVal
eltype As ElementTypeEnum, ByRef id As IDAttRec, ByRef h As
HandleAttRec) As <MarshalAs(UnmanagedType.VariantBool)> Boolean

Mattias

Signature

Mattias Sjögren [MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.


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



©2009 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.