Hello All
My app requires runtime creation of an ActiveX control on demand. I
attempted to fullfil this requirment with the following code snippet:
..
..
..
System::Type ^t =
System::Type::GetTypeFromProgID("CONTINUUMX.TRecor dSetCtrl.1");
AxCONTINUUMXLib::AxTRecordSet ^rs =
(AxCONTINUUMXLib::AxTRecordSet^)System::Activator: :CreateInstance(t);
rs->DataChange += gcnew
AxCONTINUUMXLib::_DTRecordSetEvents_DataChangeEven tHandler(this,&Form1::OnDataChange);
rs->Open(textBox1->Text + "," + "Daily");
rs->Init(100, 0);
rs->GetRecDouble(0,0, val);
Unfortunately the above results in the following runtime error:
Unable to cast COM object of type 'AxCONTINUUMXLib.AxTRecordSet' to
class type ''. Instances of types that represent COM components cannot
be cast to types that do not represent COM components; however they can
be cast to interfaces as long as the underlying COM component supports
QueryInterface calls for the IID of the interface.
Is reflection and the use of System::Type::GetMethod the only (and
tedious) way of doing this?
Any hint or help is greatly appreciated.
Regards 3 2048
"none" <no**@nowhere.inv> wrote in message
news:RX*******************@fe04.news.easynews.com. .. Hello All
My app requires runtime creation of an ActiveX control on demand. I attempted to fullfil this requirment with the following code snippet:
. . . System::Type ^t = System::Type::GetTypeFromProgID("CONTINUUMX.TRecor dSetCtrl.1");
AxCONTINUUMXLib::AxTRecordSet ^rs = (AxCONTINUUMXLib::AxTRecordSet^)System::Activator: :CreateInstance(t);
rs->DataChange += gcnew AxCONTINUUMXLib::_DTRecordSetEvents_DataChangeEven tHandler(this,&Form1::OnDataChange);
rs->Open(textBox1->Text + "," + "Daily"); rs->Init(100, 0); rs->GetRecDouble(0,0, val);
Unfortunately the above results in the following runtime error:
Unable to cast COM object of type 'AxCONTINUUMXLib.AxTRecordSet' to class type ''. Instances of types that represent COM components cannot be cast to types that do not represent COM components; however they can be cast to interfaces as long as the underlying COM component supports QueryInterface calls for the IID of the interface.
Is reflection and the use of System::Type::GetMethod the only (and tedious) way of doing this?
Yes, reflection only. If you want late binding support for COM at the
language level you should use VB.NET, C++/CLI and C# aren't well suited for
this.
Willy.
"Willy Denoyette [MVP]" <wi*************@telenet.be> wrote in
news:OO**************@TK2MSFTNGP12.phx.gbl: Yes, reflection only. If you want late binding support for COM at the language level you should use VB.NET, C++/CLI and C# aren't well suited for this.
Willy.
Thank you, Willy. I appreciate your expedient response.
Regards
> System::Type ^t = System::Type::GetTypeFromProgID("CONTINUUMX.TRecor dSetCtrl.1");
AxCONTINUUMXLib::AxTRecordSet ^rs = (AxCONTINUUMXLib::AxTRecordSet^)System::Activator: :CreateInstance(t);
What you get from Activator create instance is a Runtime Callable Wrapper
(RCW). If you cast an RCW to a .NET interface with the Guid attribute, it
calls QueryInterface under the hood.
Often, the easiest way to get an interface with the correct attribute
settings etc., is the TLBIMP.EXE tool.
Marcus Heege This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Gary |
last post by:
sorry for not cross-posting originally (originally posted in the components
subgroup)
I seem to have run into two documented bugs whose workarounds are
incompatible. What I have is an OCX...
|
by: Blake |
last post by:
I'm using late binding to create Outlook email from an Access2K
database. I am not referencing the Microsoft Office 9.0 Object Library
nor the Microsoft Outlook 9.0 Object Library. Instead, I have...
|
by: Blake |
last post by:
I'm using late binding to create Outlook email from an Access2K
database. I am not referencing the Microsoft Office 9.0 Object Library
nor the Microsoft Outlook 9.0 Object Library. Instead, I have...
|
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...
|
by: JL_327 |
last post by:
No one on any of the other boards seem to know
In VB.Net this late binding works fine
Dim Version As Integer
Dim Revision As Integer
Dim Wnum As Integer
Dim o As System.Array =...
|
by: Rocio |
last post by:
I have a windows app. written in VB6, now we need to expose some of
its classes through a web service.
I am only able to expose the classes using late binding becasue that's
the way the original...
|
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...
|
by: jdanoz |
last post by:
Hello,
i have a vb.net project with a reference to an ActiveX object (ocx).
If i try to use the ocx from vb6 project (adding the reference) it
works ok (using CreateObject).
In vb.net,
the...
|
by: Michael Maes |
last post by:
Hi,
We have an ERP-Application that needs to interact with an "external
accountancy program". This is acchieved through a "Connector" (ActiveX-dll)
so kindly provided by the Accountancy-Program....
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |