Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Determine COM objects executing location

HI,

I built a COM object in VB .Net 2003 but can't find a way for the COM object to determine its executing location. The COM object is be called from ASP.
These are the solutions I've tried but each triggers an error:

1. Search the Registry's HKEY_CLASSES_ROOT for the CLSID of the COM object to get the CodeBase value but Registry access is prohibited.

2. Defining an object of type [Assembly] to get the CodeBase property.
Dim ThisAssembly As [Assembly] = System.Reflection.Assembly.GetExecutingAssembly

Solution 2 triggers the "An exception of type 'mscorlib: URI formats are not supported' exception.

Thank you for your help,

Scott
[734 byte] By [scottlemen] at [2007-11-11 8:46:27]
# 1 Re: Determine COM objects executing location
Why does the COM object need to know its executing location? Perhaps there's another way to accomplish what you're trying to do.
Phil Weber at 2007-11-11 21:46:58 >
# 2 Re: Determine COM objects executing location
Phil,

For business reasons, the COM object must load some configuration data at instantiation and so it must know where to find the configuration file. I ended up using an Environmental variable that the COM object reads to find the file.

By the way, since COM objects can't write to the Application log, how do they report errors?

Thanks,

Scott
scottlemen at 2007-11-11 21:48:04 >