Getting calling Exe's name

A

AA2e72E

I expected

System.Reflection.Assembly.GetCallingAssembly().GetName().Name;

to give me the name of the exe calling a c# class library. It isn't - the c#
class library is a COM interrop dll and the calling exe is a Win32 Exe.

What am I doing wrong, any ideas?
 
P

Patrice

Hello,

Likely because a win32 exe file is not an assembly... Perhaps by getting the
current process ?
 
A

Arne Vajhøj

I expected

System.Reflection.Assembly.GetCallingAssembly().GetName().Name;

to give me the name of the exe calling a c# class library. It isn't - the c#
class library is a COM interrop dll and the calling exe is a Win32 Exe.

What am I doing wrong, any ideas?

You could try:
Process.GetCurrentProcess().MainModule.FileName
and see if it works in this context.

A Win32 EXE is not a .NET assembly, so I am not surprised
that's not working.

Arne
 
F

Family Tree Mike

I expected

System.Reflection.Assembly.GetCallingAssembly().GetName().Name;

to give me the name of the exe calling a c# class library. It isn't - the c#
class library is a COM interrop dll and the calling exe is a Win32 Exe.

What am I doing wrong, any ideas?

In addition to the other responses, if you have A.exe calling B.dll,
which in turn calls C.dll, then this function inside of C.dll shows B.dll.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top