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?