Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assembly.GetExecutingAssembly() doesn't work correctly. #52

Open
SlowLogicBoy opened this issue Jul 11, 2018 · 1 comment
Open

Assembly.GetExecutingAssembly() doesn't work correctly. #52

SlowLogicBoy opened this issue Jul 11, 2018 · 1 comment
Labels

Comments

@SlowLogicBoy
Copy link

SlowLogicBoy commented Jul 11, 2018

There are cases when Calling assembly also work incorrectly (depends on JIT) but I can't reproduce it regularly.
And looks like Release and Debug builds work differently but that's not related to SystemWrappers I don't think.
Code to reproduce with:

#r "$NuGet\SystemWrapper.Interfaces\0.24.0.177\lib\net45\SystemInterface.dll"
#r "$NuGet\SystemWrapper.Wrappers\0.24.0.177\lib\net45\SystemWrapper.dll"

using SystemInterface.Reflection;
using SystemWrapper.Reflection;

void ExecutingAssembly(IAssembly assembly)
{
    var sys = assembly.GetExecutingAssembly().FullName;
    var clr = Assembly.GetExecutingAssembly().FullName;
    $"{sys}{Environment.NewLine}{clr}".Dump("Executing");
}

void CallingAssembly(IAssembly assembly)
{
    var sys = assembly.GetCallingAssembly().FullName;
    var clr = Assembly.GetCallingAssembly().FullName;
    $"{sys}{Environment.NewLine}{clr}".Dump("Calling");
}

void EntryAssembly(IAssembly assembly)
{
    var sys = assembly.GetEntryAssembly().FullName;
    var clr = Assembly.GetEntryAssembly().FullName;
    $"{sys}{Environment.NewLine}{clr}".Dump("Entry");
}
IAssembly assembly = new AssemblyWrap();
ExecutingAssembly(assembly);
CallingAssembly(assembly);
EntryAssembly(assembly);

output:

Executing:
SystemWrapper, Version=0.24.0.177, Culture=neutral, PublicKeyToken=fbc3a63dd3cf8960
ℛ℘-5deae9ff-10fc-4bfe-b099-b1621ae5f24b-6, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null

Calling:
ℛ℘-5deae9ff-10fc-4bfe-b099-b1621ae5f24b-6, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
ℛ℘-5deae9ff-10fc-4bfe-b099-b1621ae5f24b-6, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null

Entry:
RoslynPad.Host32, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
RoslynPad.Host32, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
@jozefizso
Copy link
Owner

Wrappers for these methods does not provide correct results because how .NET computes the executing and calling assembly.

I think these wrappers should be removed because this functionality cannot be wrapped.

@jozefizso jozefizso added the bug label Sep 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants