How to obtain assembly name in unmanaged call?

  • Thread starter Gnanaprakash Rathinam
  • Start date
G

Gnanaprakash Rathinam

Hi Expert,

Is there a way to obtain assembly name in an unmanaged call? During Interop
call between managed to unmanaged, I would like to know in unmanaged code
about the caller of assembly file name?

Thanks,
GP.
 
A

Alan

Hello GP,
Perhaps you may get the assebmly name on the managed side, then pass it by
one public method to the unmanaged side.
 
G

Gnanaprakash Rathinam

Thanks for your reply,

But the problem here is different, due to some valid reason I can't modify
the signature of unmanaged call, In my appdomain there may be more than one
or more assemblies loaded and each may try to call unmanaged function
concurrently and based on the caller of the assembly I need to perform some
operation in my unmanaged function. I know that using managed & unmanaged
call stack trace I can retrieve the assembly name, but this is very lengthy
procedure. I looking for more easy way to do the same!!!

-GP
 
D

David Levine

If you cannot add an argument to the method signature to identify the caller
then you are left with walking the stack to determine the caller. This is
expensive (i.e. non-performant) but if it is your only option, there you
are. You can cache the results so that further calls can be quickly looked
up.

Your best solution is to modify the unmanaged call signature.
 

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

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top