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

ConfigurationReader in Android throw exceptions. #150

Closed
Lukiya opened this issue Oct 16, 2018 · 3 comments · Fixed by #159
Closed

ConfigurationReader in Android throw exceptions. #150

Lukiya opened this issue Oct 16, 2018 · 3 comments · Fixed by #159
Labels

Comments

@Lukiya
Copy link

Lukiya commented Oct 16, 2018

ConfigurationReader.cs line 312.

query = from outputAssemblyPath in System.IO.Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory, "*.dll")

AppDomain.CurrentDomain.BaseDirectory cannot be used in Android platform, it always return null.
Due to this, a System.ArgumentNullException will be thrown out.

@MV10
Copy link
Contributor

MV10 commented Oct 17, 2018

I'm betting this would also fail on iOS (though I have no way to test this).

Turns out the problem on Android is that everything is inside the APK. There would be no way to dynamically scan DLLs.

I think the real question is why Assembly.GetEntryAssembly returns null. Do Android apps compile down to unmanaged native binaries?

If so, this package probably won't work at all, I don't think reflection works in that case. At least, not without compiler support that I don't think exists yet (the stuff MS is working on based on the Unity game engine's IL2CPP compiler, which was originally started to get around iOS rules against things like JIT compilers).

This may be a "wontfix".

@MV10 MV10 added the bug label Oct 17, 2018
@Lukiya
Copy link
Author

Lukiya commented Oct 17, 2018

Fortunately, iOS doesn't have this issue. Here is how I get the base directory in android.
I pass the main entry class type into my app, and use that type to get its location, it works pretty well. But this only works when you check "Shared Runtime" under Android options.

private string GetBinDirectory(Type entryPointType = null)
{
    if (null!= entryPointType)
    {
        var binDirectory = Path.GetDirectoryName(entryPointType.Assembly.Location);
    }
    else
    {
        var binDirectory = AppDomain.CurrentDomain.BaseDirectory;
    }
    return binDirectory;
}

@tsimbalar
Copy link
Member

This should get easier to implement once the refactorings in PR #151 are merged.

skomis-mm pushed a commit that referenced this issue Jan 7, 2019
DllScanningAssemblyFinder fixes (#157, #150, #122, #156)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants