all groups > dotnet interop > september 2006 >
You're in the

dotnet interop

group:

Interop from ASP -> .NET assembly, how to determine caller...


Interop from ASP -> .NET assembly, how to determine caller... Mwob
9/28/2006 7:21:07 AM
dotnet interop:
Hi all,

I have an assembly in .NET, that I expose to COM for interop by setting
the "Register for Com Interop" setting for the project to create the
TLB file.

This assembly is called from classic ASP pages (because its registered
with COM), and it is also called from other .NET assemblies too (which
are in turn called from .NET console applications). I need to be able
to detemine in my assembly if it was called from the ASP page through
interop, or if it was called through the other .net assembly. I
throught this snippet of code would help me:

Process p = Process.GetCurrentProcess();
return p.MainModule.ModuleName;

But when I try that code from the ASP page, I get an access denied
error. Can anyone shed some light on this or tell me an alternative way
to discover this information?

Many thanks

Matt.
Re: Interop from ASP -> .NET assembly, how to determine caller... Dmytro Lapshyn [MVP]
10/2/2006 5:45:38 PM
Hi,

I recall that if you call Assembly.GetEntryAssembly and the .NET DLL is
being used by a COM client, you'll get null. But:

- Might not be 100% reliable
- Can work only on certain versions of .NET Framework

--
Regards,
Dmytro Lapshyn [MVP]
http://blogs.vbcity.com/DmytroL

[quoted text, click to view]
Re: Interop from ASP -> .NET assembly, how to determine caller... Mwob
10/20/2006 1:01:42 AM
Hi,

Sorry for the late response. Thanks for the answer, thats useful to
know.
I think that with this being not 100% reliable, I will use some other
technique to determine if the assembly is called from COM - maybe a
property on the assembly that the COM client can set.



[quoted text, click to view]
AddThis Social Bookmark Button