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 version issue #648

Closed
intrasight opened this issue Nov 29, 2021 · 11 comments
Closed

Assembly version issue #648

intrasight opened this issue Nov 29, 2021 · 11 comments

Comments

@intrasight
Copy link

Hi,

Since Google implied that it's related to assembly resolution, I'm posting a link here to the issue that I reported

googleapis/google-api-dotnet-client#2009

My references:

#r "nuget: Google.Apis, 1.55.0"
#r "nuget: Google.Apis.Core, 1.55.0"
#r "nuget: Google.Apis.Auth, 1.55.0"
#r "nuget: Google.Apis.AnalyticsReporting.v4, 1.55.0"
#r "nuget: Newtonsoft.Json, 13.0.1"

I get error:

Could not load file or assembly 'Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'. Could not find or load a specific file. (0x80131621)

@seesharper
Copy link
Collaborator

Could you try executing the script with --isolated-load-context

@intrasight
Copy link
Author

intrasight commented Nov 29, 2021

That did the trick. I just read this for context:

https://www.strathweb.com/2021/09/dotnet-script-1-2-is-out-with-assembly-isolation-feature/

I think adding that the readme would be a good idea.

@georgiosd
Copy link

Looks like I stumbled upon the same! #663

@SamVanheer
Copy link

I take it this is the same reason why referencing a NuGet package like NuGet.Versioning causes Object reference not set to an instance of an object errors? Dotnet-script loads this during script execution, probably when restoring packages.

When a script tries to pass a SemanticVersion object to another package that references NuGet.Versioning that error occurs. It looks like my local version is 6.0.2 whereas the package being referenced is version 6.1.0.

#637 mentions difficulties using isolated contexts, but doesn't specify what those difficulties are. Why isn't full isolation the default?

@seesharper
Copy link
Collaborator

Closed as resolved with --isolated-load-context

@hrumhurum
Copy link
Contributor

#637 mentions difficulties using isolated contexts, but doesn't specify what those difficulties are. Why isn't full isolation the default?

Not all parts of .NET were ready for assembly isolation as of .NET 5.0 when this feature was first implemented. I don't remember the particulars, but there were omissions in assembly loading context during some reflection operations. This caused some packages to fail. Probably we should review the default setting for isolated load context after .NET 8.0 is released, as there is a great chance that outstanding issues in .NET had been already fixed.

@seesharper
Copy link
Collaborator

@hrumhurum I think Assembly.LoadFrom was one of the scenarios where interception did not work.

@seesharper
Copy link
Collaborator

@hrumhurum I have a branch here that runs all tests in isolated load context. It is just one failing test (ShouldHandlePackageWithNativeLibraries). It is a test that also loads native dll's
https://github.com/dotnet-script/dotnet-script/tree/default-isolation-context
Maybe you want to have a look at it. We consider making this the default in the next major version

@hrumhurum
Copy link
Contributor

@seesharper I'll give it a shot. I'll post the results here.

@seesharper
Copy link
Collaborator

Thanks ❤️

@hrumhurum
Copy link
Contributor

@seesharper When I try to run tests in https://github.com/dotnet-script/dotnet-script/tree/default-isolation-context branch, ShouldHandlePackageWithNativeLibraries test passes with ok result, no failure observed. Any hints?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants