-
Notifications
You must be signed in to change notification settings - Fork 509
Getting current assembly location returns empty string #5467
Comments
What do you need this information for? After native compilation, the assembly no longer exists on the file system (all assemblies get compiled into a single EXE file). We return an empty string because it's a valid return value and better than throwing an exception (e.g. it will be an empty string when the assembly was loaded from a byte array on the CLR). |
The most common use cases we have seen is when people call this to get a path to the app's directory. If you really need a name of a file that no longer exists, you could construct it with |
I use a library and they use that to set the working directory in a static constructor :/, i think they do that because .net core applications set the Project directory as a working directory But thanks to your explanation i understand now, and it make sense :) |
This can be worked around now by adding: AppContext.SetSwitch("Switch.System.Reflection.Assembly.SimulatedLocationInBaseDirectory", true); to |
Needed to use this workaround for using Grpc.Core as it uses |
`Assembly.Location` will return an empty string after being wrapped into a self-contained native PE. dotnet/corert#5467
* Add publish-plugins YAML stub * Update plugin projects and build * Remove PublishTrimmed property from plugin build script It's currently not supported to use trimming for non-SCD apps. If the PublishTrimmed option is left in, you'll see an error like this: ``` error NETSDK1102: Optimizing assemblies for size is not supported for the selected publish configuration. Please ensure that you are publishing a self-contained app. [/home/vsts/work/1/s/src/plugins/ChronicleMunger/ChronicleMunger.csproj] ``` https://dev.azure.com/scorpdx/ironmunge/_build/results?buildId=368&view=logs&j=1cbb5fa8-227a-5271-32b9-169471ebf78b&t=ee99034a-8350-59b1-e746-a0270efb6ce5&l=45 * Fix crash on startup `Assembly.Location` will return an empty string after being wrapped into a self-contained native PE. dotnet/corert#5467 * Don't publish an artifact just for plugins
Version: 026c934
Output:
Location:
Expected (.net core 2.0):
Location: C:\Users\Scellow\dev\test\bin\Debug\netcoreapp2.0\test.dll
OS: Win 10 x64
The text was updated successfully, but these errors were encountered: