Home All Groups Group Topic Archive Search About

Can't get Assembly.GetCallingAssembly() to reflect the proper assembly

Author
30 Nov 2006 3:44 PM
Brad Wood
I have an executable that references a separate .dll assembly.  Inside the
..dll I call GetCallingAssembly and I always get a reference to the .exe.

Documentation for GetCallingAssembly says, "Returns the Assembly of the
method that invoked the currently executing method."  Obviously that wasn't
the case.  Reading further, I see that the copiler may be inlinining my
method and that I should decorate the method I'm calling GetCallingAssembly
from with MethodImpl(MethodImplOptions.NoInlining).  No joy.

Is there anything else I can try?  I couldn't find anyone else who
experienced this...

Author
30 Nov 2006 4:56 PM
Steve B.
Use GetExecutingAssembly if you wantto return the dll... the exe is the
calling assembly, not the executing...


"Brad Wood" <d***@sweet.com> a écrit dans le message de news:
eSta7ZJFHHA.2***@TK2MSFTNGP06.phx.gbl...
Show quote
>I have an executable that references a separate .dll assembly.  Inside the
>.dll I call GetCallingAssembly and I always get a reference to the .exe.
>
> Documentation for GetCallingAssembly says, "Returns the Assembly of the
> method that invoked the currently executing method."  Obviously that
> wasn't the case.  Reading further, I see that the copiler may be
> inlinining my method and that I should decorate the method I'm calling
> GetCallingAssembly from with MethodImpl(MethodImplOptions.NoInlining).  No
> joy.
>
> Is there anything else I can try?  I couldn't find anyone else who
> experienced this...
>
Author
30 Nov 2006 11:12 PM
Brad Wood
"Steve B." <steve_beauge@com.msn_swap_msn_and_com> wrote in message
news:uFLKiCKFHHA.2112@TK2MSFTNGP03.phx.gbl...
> Use GetExecutingAssembly if you wantto return the dll... the exe is the
> calling assembly, not the executing...

I tried that.  Same thing with or w/o the attribute.
Author
30 Nov 2006 11:38 PM
Brad Wood
"Steve B." <steve_beauge@com.msn_swap_msn_and_com> wrote in message
news:uFLKiCKFHHA.2112@TK2MSFTNGP03.phx.gbl...
> Use GetExecutingAssembly if you wantto return the dll... the exe is the
> calling assembly, not the executing...

Sorry, this was a Copy Local issue.  I had tried GetExecutingAssebly, but I
was extracting the path (which always returned the path to the location of
the exe).  I was expecting the location of the .dll as I referenced it.

And yes, I should use GetExectingAssembly.

AddThis Social Bookmark Button