473,671 Members | 2,216 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Passing an Active X object reference into C# and using it.

I can't seem to figure out the right thing to search on, so I thought
I'd just provide an example and see if someone can point me to some
tips.

What I have is an Automation Server that has a method that will start
another automation server. These Activex automation servers that it
talks to require a specific interface that the calling server uses to
manage the child active x automation servers. This is all part of an
application architecture that is unchangable, thus I need to work
within the constraints.

Here is an pseudo example with VB6 (the apps native language)

The object manager requires an interface on each called object that
looks like:
Option Explicit

Public obObjMgr as Object

Public Function InitializeObjec t(byval ObjMgr as Object)
set obObjMgr = ObjMgr
end function

Then this allows our app to do something like:

procedure cmdPopCustomer( custid as string)

dim CustForm as Object
set CustForm = obObjMgr.Launch Child(custProj. clsCustMaint)
CustForm.LoadCu st(custid)
end sub

I can get a C# app to expose the interface so the Object Manager can
launch it. But I am not sure how to go about consuming the reference
to the object manager, or for that part, any object that might be
returned by calling a ActiveX objects methods.

Any help is appreciated.

In VB 6, this is how it works:

The EXE is loaded into memory and is the main "object manager". It
launches any other ActiveX server keeping track of a reference to each
activex object it launches. As part of the interface, it also passes
a reference to itself to the launched app, so that the launched app
has access to some system services. One of these system services is
requesting another Active X object to be launched.

So say I am an invoice screen and I right click on the Customer name,
options come up including customer maintenance. I can click on that
and the customer maintenance form will open and populate with the
customer id matching the invoice I was looking at.

This is done by the Invoice screen having an object that contains a
reference to the object manager. To pop the cust maintenance form we
dim oChildForm as object
set oChildForm = objMgr.GetChild (MaintCustProj. clsMaintCust)
oChildForm.Navi gateTo(this.Cus tID)

May 17 '07 #1
1 2015
Mike,

In this case, you have an interface in the loosest sense of the word.
You really should have type libraries which define actual interfaces that
the objects expose.

If you are able to add the interfaces, you should, if anything, it helps
enforce your application architecture. With type libraries, you can create
a .NET interop assembly and then just cast to that interface in the
assembly, and it will work.

If you can't even add the proper interface, then you will need to use
Reflection, calling the methods using late binding.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Mike H" <mi*********@gm ail.comwrote in message
news:11******** *************@u 30g2000hsc.goog legroups.com...
>I can't seem to figure out the right thing to search on, so I thought
I'd just provide an example and see if someone can point me to some
tips.

What I have is an Automation Server that has a method that will start
another automation server. These Activex automation servers that it
talks to require a specific interface that the calling server uses to
manage the child active x automation servers. This is all part of an
application architecture that is unchangable, thus I need to work
within the constraints.

Here is an pseudo example with VB6 (the apps native language)

The object manager requires an interface on each called object that
looks like:
Option Explicit

Public obObjMgr as Object

Public Function InitializeObjec t(byval ObjMgr as Object)
set obObjMgr = ObjMgr
end function

Then this allows our app to do something like:

procedure cmdPopCustomer( custid as string)

dim CustForm as Object
set CustForm = obObjMgr.Launch Child(custProj. clsCustMaint)
CustForm.LoadCu st(custid)
end sub

I can get a C# app to expose the interface so the Object Manager can
launch it. But I am not sure how to go about consuming the reference
to the object manager, or for that part, any object that might be
returned by calling a ActiveX objects methods.

Any help is appreciated.

In VB 6, this is how it works:

The EXE is loaded into memory and is the main "object manager". It
launches any other ActiveX server keeping track of a reference to each
activex object it launches. As part of the interface, it also passes
a reference to itself to the launched app, so that the launched app
has access to some system services. One of these system services is
requesting another Active X object to be launched.

So say I am an invoice screen and I right click on the Customer name,
options come up including customer maintenance. I can click on that
and the customer maintenance form will open and populate with the
customer id matching the invoice I was looking at.

This is done by the Invoice screen having an object that contains a
reference to the object manager. To pop the cust maintenance form we
dim oChildForm as object
set oChildForm = objMgr.GetChild (MaintCustProj. clsMaintCust)
oChildForm.Navi gateTo(this.Cus tID)

May 17 '07 #2

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

Similar topics

5
4056
by: John Dewbert | last post by:
*** post for FREE via your newsreader at post.newsfeed.com *** Hello, I have trouble passing a folder object (from a FileSystemObject) to a sub procedure. Consider the following code: =================================
3
14929
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) { document.images.src = eval("mt" +menu+ ".src") } alert("imgOff_hidemenu"); hideMenu=setTimeout('Hide(menu,num)',500);
58
10123
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of code... TCHAR myArray; DoStuff(myArray);
8
2114
by: Dennis Myrén | last post by:
I have these tiny classes, implementing an interface through which their method Render ( CosWriter writer ) ; is called. Given a specific context, there are potentially a lot of such objects, each requiring a call to that method to fulfill their purpose. There could be 200, there could be more than 1000. That is a lot of references passed around. It feels heavy. Let us say i changed the signature of the interface method to:
17
9379
by: LP | last post by:
Hello, Here's the scenario: Object A opens a Sql Db connection to execute number of SqlCommands. Then it needs to pass this connection to a constructor of object B which in turn executes more commands on the same connection. I have an understanding that if SqlConnection is passed as "value" (unboxed), object B will create its own copy of SqlConnection, so when object A closes its connection, it remains open for object B's copy. Is this
11
8116
by: John Pass | last post by:
Hi, In the attached example, I do understand that the references are not changed if an array is passed by Val. What I do not understand is the result of line 99 (If one can find this by line number) which is the last line of the following sub routine: ' procedure modifies elements of array and assigns ' new reference (note ByVal) Sub FirstDouble(ByVal array As Integer()) Dim i As Integer
6
5990
by: MSDNAndi | last post by:
Hi, I get the following warning: "Possibly incorrect assignment to local 'oLockObject' which is the argument to a using or lock statement. The Dispose call or unlocking will happen on the original value of the local." My code is: using System; using System.Collections.Generic;
12
2678
by: Andrew Bullock | last post by:
Hi, I have two classes, A and B, B takes an A as an argument in its constructor: A a1 = new A(); B b = new B(a1);
7
3298
by: TS | last post by:
I was under the assumption that if you pass an object as a param to a method and inside that method this object is changed, the object will stay changed when returned from the method because the object is a reference type? my code is not proving that. I have a web project i created from a web service that is my object: public class ExcelService : SoapHttpClientProtocol {
0
8912
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8819
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8597
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7428
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6222
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4403
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2809
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2049
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1807
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.