-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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.LoadFrom works on files inside the single-file bundle #40138
Comments
Tagging subscribers to this area: @swaroop-sridhar, @agocke |
/cc @MichalStrehovsky @jkotas for API behavioral compatibility |
I agree with the behavior you are proposing. |
Curios about the following scenario:
How would I do that? |
This issue is about the fact that The overall principle is to make as many things work consistently across single-file and non-single-file deployments (no surprises and so on). It's not always possible ( Accessing files in the bundle is currently not exposed in any public API - there's no API which lets you specifically open a file from the bundle. We intentionally made this choice to avoid confusion with File.IO and other APIs. To load assembly from the bundle, you just call If there's a need to include additional "data" in the bundle, the recommended way to do that is to embed such file as a managed resource into one of the assemblies. Then it can be accessed via |
Repro is part of the test app here: https://github.com/vitek-karas/single-file-feature-test |
Nit: The best API for this is |
For this specific issue feel free to ignore the following feedback: I'm pretty sure this leads to additional issues / requests in the future. I can fully understand that its for the .NET team easier to consider everything to be "real" / existing on the disk, rather than having to modify so many APIs to work with both... however. A single file application is meant to be that. And by allowing to store native files (e.g. non DOT NET files) its also to be meant to bundle NON RESOURCES files with it... otherwise, you would have told everyone to mark such a file as a resource file in the project. Which makes your decision to bundle native files obsolete... doesn't it?!?!? This discussion is not part of this particular issue, I'm sorry for "hijacking" it and I'm sorry for bringing up these points but I definitely see a problem about this at all, even if there are no feedback about this already. This bundle "thing" has become more like a "virtual file system" and when it runs inside memory which is what you are working on, the more expectations will raise with this in the future, even though my opinion seems like it doesn't matter for you. |
I do agree that the existing property which let's developers include additional files in the bundle should ideally be eventually deprecated. My reasoning is:
On the topic of native libraries (native I would like to not treat the bundle as a virtual file system - I think it's just too much potential complexity for relatively little gain. Ideally the actual implementation of how we store the assemblies in the bundle would not be visible anywhere (this specific issue is an example where the implementation leaks to the public API - so we should fix that). I personally think that we should not try to support every application with single-file as is - there are certain thing we just can't emulate, so there will always be some amount of potential changes to the app to make it work as single-file. We're starting to work on better tooling to help with understanding what needs to change in the app: dotnet/roslyn-analyzers#3921. |
For example if the single-file application is in
C:\temp\MyApp.exe
and it hasMyApp.dll
bundled in it, callingAssembly.LoadFrom(@"C:\temp\MyApp.dll")
will actually work and return theMyApp
assembly. Even thoughC:\temp\MyApp.dll
doesn't exist on disk.For single-file apps I think that
Assembly.LoadFrom
should still work on real files (ability to load a plugin for example). It should NOT work paths which don't exist on disk.More so, if there actually is
C:\temp\MyApp.dll
file on disk, it's not the one which is returned fromLoadFrom
, that file is ignored, even though the code asked to load that explicitly.The text was updated successfully, but these errors were encountered: