473,320 Members | 1,713 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,320 software developers and data experts.

Using ActiveX in C#

Hello,

I have the commands to access the AutoCAD database via
ActiveX within a VB application. Now I am searching for
the equivalent commands in C#:

VB --> C#
GetObject --> ???
CreateObject --> ???
Can you help me?

Thx
Stefan
Nov 15 '05 #1
7 13054
Hello Stefan,
CreateObject --> ???
Take a look at the System.Activator.CreateInstance(...) and
System.Type.GetTypeFromProgID(...)
GetObject --> ???
Not sure there's an equivalent. I hope somebody else will shed more light on
this.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Stefan Saur" <an*******@discussions.microsoft.com> wrote in message
news:09****************************@phx.gbl... Hello,

I have the commands to access the AutoCAD database via
ActiveX within a VB application. Now I am searching for
the equivalent commands in C#:

VB --> C#
GetObject --> ???
CreateObject --> ???
Can you help me?

Thx
Stefan


Nov 15 '05 #2

"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote
in message news:Oz**************@TK2MSFTNGP09.phx.gbl...
Hello Stefan,
CreateObject --> ???
Take a look at the System.Activator.CreateInstance(...) and
System.Type.GetTypeFromProgID(...)
GetObject --> ???


Not sure there's an equivalent. I hope somebody else will shed more light

on this.
Urmm, although I don't know how to use it:
System.Runtime.InteropServices.Marshal.BindToMonik er(); should be what you
need.
from MSDN:
Marshal.BindToMoniker exposes the BindToMoniker COM API method, which
produces an object that you can cast to any COM interface you require. This
method provides the same functionality as the GetObject method in Visual
Basic 6.0 and Visual Basic .NET. For additional information about the
BindToMoniker COM method, see the MSDN Library.

I had to use it to activate someting one time...using a string like
new://progid but I don't recall exactly what it did and knew nothing beyond
that...
hopefully someone else can shed more light on this as well, ;)
--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Stefan Saur" <an*******@discussions.microsoft.com> wrote in message
news:09****************************@phx.gbl...
Hello,

I have the commands to access the AutoCAD database via
ActiveX within a VB application. Now I am searching for
the equivalent commands in C#:

VB --> C#
GetObject --> ???
CreateObject --> ???
Can you help me?

Thx
Stefan

Nov 15 '05 #3
>
GetObject --> ???


System.Runtime.InteropServices.Marshal.GetActiveOb ject()
is the good one.

Nov 15 '05 #4
What about the way Microsoft is suggesting to bind COM-objects to managed
code?
They suggest to add a reference to the COM-class to the reference list of
the project, wich will
generate a managed assembly wrapping the COM-class. Then they'll bind it the
folowing way:

....
using NameOfImportedCOMLib; //Just the wrapper-assemblies namespace
....
{
NameOfImportedCOMLibClass myInstance = new NameOfImportedCOMLibClass
();//Creating an object from wrapper class as with any other class
myInstance.DoSumptin ();//Use as any other object
...
}
....

Stefan

"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> schrieb
im Newsbeitrag news:Oz**************@TK2MSFTNGP09.phx.gbl...
Hello Stefan,
CreateObject --> ???
Take a look at the System.Activator.CreateInstance(...) and
System.Type.GetTypeFromProgID(...)
GetObject --> ???


Not sure there's an equivalent. I hope somebody else will shed more light

on this.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Stefan Saur" <an*******@discussions.microsoft.com> wrote in message
news:09****************************@phx.gbl...
Hello,

I have the commands to access the AutoCAD database via
ActiveX within a VB application. Now I am searching for
the equivalent commands in C#:

VB --> C#
GetObject --> ???
CreateObject --> ???
Can you help me?

Thx
Stefan

Nov 15 '05 #5
This actually won't work, as it would create a new instance of the
object in question. When using GetObject, it will get an object that is
already created, and located where that resource is (which is typically the
Running Object Table, but can be anything).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Scarfeet" <sc******@operamail.com> wrote in message
news:ut**************@TK2MSFTNGP11.phx.gbl...
What about the way Microsoft is suggesting to bind COM-objects to managed
code?
They suggest to add a reference to the COM-class to the reference list of
the project, wich will
generate a managed assembly wrapping the COM-class. Then they'll bind it the folowing way:

...
using NameOfImportedCOMLib; //Just the wrapper-assemblies namespace
...
{
NameOfImportedCOMLibClass myInstance = new NameOfImportedCOMLibClass
();//Creating an object from wrapper class as with any other class
myInstance.DoSumptin ();//Use as any other object
...
}
...

Stefan

"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> schrieb im Newsbeitrag news:Oz**************@TK2MSFTNGP09.phx.gbl...
Hello Stefan,
CreateObject --> ???
Take a look at the System.Activator.CreateInstance(...) and
System.Type.GetTypeFromProgID(...)
GetObject --> ???


Not sure there's an equivalent. I hope somebody else will shed more

light on
this.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Stefan Saur" <an*******@discussions.microsoft.com> wrote in message
news:09****************************@phx.gbl...
Hello,

I have the commands to access the AutoCAD database via
ActiveX within a VB application. Now I am searching for
the equivalent commands in C#:

VB --> C#
GetObject --> ???
CreateObject --> ???
Can you help me?

Thx
Stefan


Nov 15 '05 #6
Stefan,

I had to do this very thing yesterday with CreateObject. Here's what
worked for me.

VB
Set xmlReq = CreateObject("Microsoft.XMLHTTP")
C#
MSXML.XMLHTTPRequest xmlReq = (MSXML.XMLHTTPRequest)
Activator.CreateInstance(Type.GetTypeFromProgID("M icrosoft.XMLHTTP"));
seems like a lot more to write out.. but it works like a charm.

Kevin

"Stefan Saur" <an*******@discussions.microsoft.com> wrote in message news:<09****************************@phx.gbl>...
Hello,

I have the commands to access the AutoCAD database via
ActiveX within a VB application. Now I am searching for
the equivalent commands in C#:

VB --> C#
GetObject --> ???
CreateObject --> ???
Can you help me?

Thx
Stefan

Nov 15 '05 #7
Nice... but,

doesn't seem to work with ActiveX controls.
Looking into it I have observed that the designer creates another kind of
wrapper for ActiveX controls, if I create a reference via the toolbox.
The Objectbrowser shows that reference as "axinterop.NameOfTheImportedLib".
Using the wrapper contained there just works fine for me.
The code looks like this:
....
using AxNameOfTheImportedLib; //The wrappers namespace created by the
designer
....
{
//AxNameOfTheImported is just the wrapper class available in
//namespace AxNameOfTheImportedLib
AxNameOfTheImported myInstance = new AxNameOfTheImported ();
myInstance.CreateControl(); //Just force the damn thing to be created
;-)
myInstance.DoSumptin(); //You can now start to use the controls members
...
}

Scarfeet


"Kevin" <cw****@insight.rr.com> schrieb im Newsbeitrag
news:18*************************@posting.google.co m...
Stefan,

I had to do this very thing yesterday with CreateObject. Here's what
worked for me.

VB
Set xmlReq = CreateObject("Microsoft.XMLHTTP")
C#
MSXML.XMLHTTPRequest xmlReq = (MSXML.XMLHTTPRequest)
Activator.CreateInstance(Type.GetTypeFromProgID("M icrosoft.XMLHTTP"));
seems like a lot more to write out.. but it works like a charm.

Kevin

"Stefan Saur" <an*******@discussions.microsoft.com> wrote in message

news:<09****************************@phx.gbl>...
Hello,

I have the commands to access the AutoCAD database via
ActiveX within a VB application. Now I am searching for
the equivalent commands in C#:

VB --> C#
GetObject --> ???
CreateObject --> ???
Can you help me?

Thx
Stefan

Nov 15 '05 #8

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

Similar topics

7
by: NewbieJon | last post by:
I am attempting to send the variable "sComputerName" from my ActiveX script to "GetInfo.asp" using javascript. (Having been advised this is the way to get my ActiveX variable into my ASP script) ...
6
by: Sergio Otoya | last post by:
Hi all, Is there any way of copying a file using javascript, not using the Filesystemobject (ActiveX). I need this to run in Windows and MACS. Any help would be greatly appreciated. Thanks...
1
by: Norman Fritag | last post by:
Hi there I have avoided to use active x controls because I thought they are causing more problems then they are doing any good. I a new application I would want to use the tree and list view...
1
by: Raed Sawalha | last post by:
Hello I have ActiveX DLL and I usually register it using following procedure 1. gactutil -i ActiveXDLL 2. regasm ActiveXDLL /tlb:DLLNAME/codebase 3. then using the activeX can I automate step...
3
by: fumihiko | last post by:
Hi, I created an activex control (C++), and it uses another COM dll (C++). This COM dll links with a static library that dose some calculation. (both are debug multithreaded dll) I created a...
2
by: Mehr H | last post by:
I have been working on this for several days and am still have had no success in achieving this. Pleae help. It seems that documentation for this is very limited. I have looked in several books and...
3
by: EJ1003 | last post by:
Hello I would like to create Activex Control uisng C# and use it in ASP.Net webform. User Control is not solving my requirement so I am going for Activex Control. Please guide me on this, how...
9
by: Prabhat | last post by:
Hi Friends, I have created one ActiveX DLL in VB that has one public function ("GetClientCPUID") which will return a string of the CPUID. I want to use this to get the clients CPUID and retuern...
3
by: tuvman | last post by:
We are developing a web application. Our web app is a heavy client- our existing .net app exposed as an activex control running in IE. We need the activex to be able to access our remote database...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
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...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
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....
0
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
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.