473,402 Members | 2,050 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,402 software developers and data experts.

Where is the COM object?

After I add a reference to a COM object to my project, I would like to be
able to return the path and filename of the dll in my C# code. How can I do
that?
Nov 16 '05 #1
3 1345
If you use VS.NET, you can just add click.
menu project->add reference.
and you will can find very easy.

Good Luck,

Jhin-Seok.

"Ron Weldy" wrote:
After I add a reference to a COM object to my project, I would like to be
able to return the path and filename of the dll in my C# code. How can I do
that?

Nov 16 '05 #2
Hi Ron,
After I add a reference to a COM object to my project, I would like to be
able to return the path and filename of the dll in my C# code. How can I do
that?


Assembly asmbly=Assembly.GetAssembly(typeof(ADODB.Recordset ));
string dllWraperPath=asmbly.Location;

Cheers!

Marcin
Nov 16 '05 #3
Ron,

Yes, you can do this. Someone else suggested that you use the Location
property of the assembly. However, I feel that you might not want this, as
this will return the location of the wrapper assembly, and not the COM
server itself. In order to get this information, you will have to do the
following.

First, define the QueryPathOfRegTypeLib API function in .NET. I've
placed the definition on pinvoke.net. Once you have this, you will need the
following code:

// Get the assembly of the type.
// I'm using ADODB.Connection, but you should use any type in the library
you want the path of.
Assembly pobjWrapper = typeof(ADODB.ConnectionClass).Assembly;

// Get the id of the library.
Guid pobjLibId = Marshal.GetTypeLibGuidForAssembly(pobjWrapper);

// Pass that to QueryPathOfRegTypeLib to get the path.
string pstrPath = null;

// Get the string. You need to have the correct version numbers in order to
do this.
int pintResult = QueryPathOfRegTypeLib(ref pobjLibId, 2, 7, 0, ref
pstrPath);

The one caveat here is the version number. If you don't know it, then
you can actually get the UCOMITypeInfo implementation, work your way up to
the type library, and then get the version information from that.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Ron Weldy" <ro******@msn.com> wrote in message
news:e%****************@TK2MSFTNGP12.phx.gbl...
After I add a reference to a COM object to my project, I would like to be
able to return the path and filename of the dll in my C# code. How can I do that?

Nov 16 '05 #4

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

Similar topics

3
by: Tim Hoffman | last post by:
Hi I have been using object crafts csv module for quite a few projects, mainly because I found the csv in python in it's current incarnation is funtionally inferior to object crafts. The object...
0
by: Bijay Kumar | last post by:
Hi Guys, I was going through the source code of Object class (Object.cs in rotor). What I found is Equals() implemented as follows: public extern virtual bool Equals(Object obj); What...
10
by: Paul Cheetham | last post by:
Hi, I am developing an application that needs to store some machine-specific settings. The application is going to be published on the network in order to keep the clients on the latest version....
15
by: amit.man | last post by:
Hi, i have newbie qestion, when i write #include <somthing.h> the precompiler subtitue that line with the lines from "somthing.h" header file. when, where and how the compiler insert the...
4
by: =?Utf-8?B?TWlrZSBDb2xsaW5z?= | last post by:
I am trying to set up a dynamic search using linq. I believe the syntax is correct, but cannot confirm it because when I try to cast my Session from a List<to IQueryable<>, I get a cast error...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
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...
0
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...

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.