473,386 Members | 1,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Late Binding

Is it possible to late bind to a dll written in C# from VB6? If so, does
anyone have an example.
Nov 15 '05 #1
4 5238
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/de...ertutorial.asp

..NET Framework Developer's Guide
Exposing .NET Framework Components to COM
http://msdn.microsoft.com/library/de...nentstocom.asp

--
Rob Windsor
G6 Consulting
Toronto, Canada
"Justin Starnes" <jl*******@chartertn.net> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Is it possible to late bind to a dll written in C# from VB6? If so, does
anyone have an example.

Nov 15 '05 #2
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.

Nov 15 '05 #3
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.

Nov 15 '05 #4
If you mean classic late binding as in VB CreateObject("Progid") and
IDispatch-based calls, start with Type.GetTypeFromProgID.
--
Phil Wilson [MVP Windows Installer]

"Justin Starnes" <jl*******@chartertn.net> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Is it possible to late bind to a dll written in C# from VB6? If so, does
anyone have an example.

Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Mike MacSween | last post by:
Had some trouble with Word automation. Sorted it, in the process thought I would try late binding. Some people reccomend it. So this: *********************************************************...
1
by: JD Kronicz | last post by:
Hi .. I have an issue I have been beating my head against the wall on for some time. I am trying to use late binding for MS graph so that my end users don't have to worry about having the right...
14
by: Composer | last post by:
I've read many postings about the problem of Access.References.IsBroken and the consensus seems to be that late binding is the cure-all. I have a very complex Access application that needs...
9
by: Zlatko Matić | last post by:
I was reading about late binding, but I'm not completely sure what is to be done in order to adjust code to late binding... For example, I'm not sure if this is correct: early binding: Dim ws...
5
by: eBob.com | last post by:
In another thread VJ made me aware of Tag. Fantastic! I've been wanting this capability for a long time. But it seems that I cannot use it with Option Strict On. In an event handler I have ......
30
by: lgbjr | last post by:
hi All, I've decided to use Options Strict ON in one of my apps and now I'm trying to fix a late binding issue. I have 5 integer arrays: dim IA1(500), IA2(500), IA3(500), IA4(500), IA5(500) as...
6
by: Tim Roberts | last post by:
I've been doing COM a long time, but I've just come across a behavior with late binding that surprises me. VB and VBS are not my normal milieux, so I'm hoping someone can point me to a document...
2
by: GS | last post by:
I have installed the ms PIA for ofc XP, and followed the article http://support.microsoft.com/kb/247412/ trying to paste into a worksheet However I got late binding not allowed errors .......
3
ADezii
by: ADezii | last post by:
The process of verifying that an Object exists and that a specified Property or Method is valid is called Binding. There are two times when this verification process can take place: during compile...
14
by: Siv | last post by:
hi, I am converting an application that writes to an Excel spreadsheet and the code trips the "option Strict" that I would like on because the parser says "option Strict On disallows late...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.