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 / September 2003

Tip: Looking for answers? Try searching our database.

Late Binding

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Justin Starnes - 23 Sep 2003 04:29 GMT
Is it possible to late bind to a dll written in C# from VB6? If so, does
anyone have an example.
Rob Windsor - 23 Sep 2003 16:06 GMT
Yes, you need to use COM Interop. Here are some links.

C# Programmer's Reference
COM Interop Part 2: C# Server Tutorial
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csref/html/vcwl
kcominteroppart2cservertutorial.asp


.NET Framework Developer's Guide
Exposing .NET Framework Components to COM
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cp
conexposingnetframeworkcomponentstocom.asp


Signature

Rob Windsor
G6 Consulting
Toronto, Canada

> Is it possible to late bind to a dll written in C# from VB6? If so, does
> anyone have an example.
Vadim Melnik - 24 Sep 2003 23:33 GMT
Hi,

> Is it possible to late bind to a dll written in C# from VB6? If so, does
> anyone have an example.

It's possible but you need somehow instantiate this object. mscoree.dll
exposes undocumented ClrCreateManagedInstance function, it's declared in
mscoree.h as the following:

STDAPI ClrCreateManagedInstance(LPCWSTR pTypeName, REFIID riid, void
**ppObject);

and C++ usage:

 HRESULT hr = ClrCreateManagedInstance(L"ClrTestLib.CFoo, ClrTestLib,
Version=1.0.1207.27541, Culture=neutral, PublicKeyToken=a8c61b7e4c98192e",
IID_IUnknown, reinterpret_cast<void**>(&spUnk));

Or you can use technique described in "Microsoft .NET: Implement a Custom
Common Language Runtime Host for Your Managed App"  MSDN Magazine article to
create CLR by CorBindToRuntimeEx call, then Start it, and then create or
retrieve default domain by ICorRuntimeHost::CreateDomain/GetDefaultDomain,
and after use it to instantiate class instance - e.g.
AppDomain.CreateInstanceFrom.

..
Cheers,
Vadim.
Phil Wilson - 25 Sep 2003 16:05 GMT
If you mean classic late binding as in VB CreateObject("Progid") and
IDispatch-based calls, start with Type.GetTypeFromProgID.
Signature

Phil Wilson [MVP Windows Installer]

> Is it possible to late bind to a dll written in C# from VB6? If so, does
> anyone have an example.

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.