How to obtain assembly name in unmanaged call?

  • Thread starter Thread starter Gnanaprakash Rathinam
  • Start date 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.
 
Hello GP,
Perhaps you may get the assebmly name on the managed side, then pass it by
one public method to the unmanaged side.
 
Hi GP,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to get the name of an Assembly
in an unmanaged call. If there is any misunderstanding, please feel free to
let me know.

As far as I know, there isn't a direct way for us to get the Assembly name
in unmanaged code. However, we can get it easily in managed call. So we can
try to write a managed method which returns the name of the assembly and
interop with this assembly. You can use tlbexp.exe to export the type
library. Here is some more information.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cptools/htm
l/cpgrfTypeLibraryExporterTlbExpexe.asp

We have to use a COM client to call the exported library. A win32 call
isn't suitable.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
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
 
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.
 
Back
Top