473,769 Members | 2,062 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 2019
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
4064
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
14949
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
10179
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
2118
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
9392
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
8128
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
5999
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
2685
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
3307
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
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10049
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...
0
9865
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8872
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
7410
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
5307
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3564
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
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.