Hi Amdrit,
As for the "GetCallingAssembly" method, it should return the immediate
caller of the current method. I'm not sure whether there is anything else
in your applicaiton/assmeblies that may cause the problem, but if what you
want to do is get reference to a certain assembly, you can consider using
the a type in the assembly to reference it. e.g.
"MyAssembly.MyType" is a known type defined in the target assemly I want
to get reference
================
Type tp =typeof(MyAssembly.MyType);
Assembly asm = tp.Assembly;
================
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
From: =?Utf-8?B?UVNJRGV2ZWxvcGVy?= <
[email protected]>
References: <
[email protected]>
<
[email protected]>
Subject: Re: Retrieve name of VB6 calling app via reflection from C# COM in
Date: Mon, 14 Apr 2008 10:43:14 -0700
When I call GetCallingAssembly It does not fail (my bad) but I get the
Current assembly, in the prev description that would be the C# logging
assembly rather than the C# COM interface assembly as I had expected.
I also tried applying MethodImplAttribute attribute with
MethodImplOptions.NoInlining to the C# logging assembly constructor but it
had no affect.
I also tried GetEntryAssembly but that return null when run with a VB6
executable calling the COM interface.
I would like not to need an additional parameter for the name because this
will impact existing code. I would prefer a silent/automatic name
creation.
:
What do you mean "fails"? Do you get an exception, or do you get and
empty
string, or do you get a string that makes no sense?
It would seem to me that you are on the right track, and since the VB
Client
is the ultimately the caller, is should come back with it's name if at
all.
However, since you have the middle interface, why not require the caller
to
name itself to the interface and just pass in App.Name there?
I have a C# logging assembly with a static constructor and methods that
is
called from another C# Assembly that is used as a COM interface for a
VB6
Application. Ideally I need to build a file name based on the name of
the
VB6 application. A second choice would be a file name based on the #
COM
interface assembly. I have tried calling
Assembly.GetCallingAssembly()
but
this fails when I use the VB6 client. Is there a way to get this
information
at runtime?