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

Could not load file or assembly System.Collections.Immutable #353

Closed
Alxandr opened this issue Nov 19, 2019 · 4 comments
Closed

Could not load file or assembly System.Collections.Immutable #353

Alxandr opened this issue Nov 19, 2019 · 4 comments

Comments

@Alxandr
Copy link

Alxandr commented Nov 19, 2019

After upgrading one of my dependencies I'm getting the following build error:

C:\Users\D45\.nuget\packages\microsoft.net.sdk.functions\1.0.29\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error : System.IO.FileLoadException: Could not load file or assembly 'System.Collections.Immutable, Version=1.2.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Could not find or load a specific file. (Exception from HRESULT: 0x80131621) [C:\Git\PolicyStaging\src\PolicyStaging\PolicyStaging.csproj]
C:\Users\D45\.nuget\packages\microsoft.net.sdk.functions\1.0.29\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error : File name: 'System.Collections.Immutable, Version=1.2.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' ---> System.IO.FileLoadException: Could not load file or assembly 'System.Collections.Immutable, Version=1.2.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. [C:\Git\PolicyStaging\src\PolicyStaging\PolicyStaging.csproj]
C:\Users\D45\.nuget\packages\microsoft.net.sdk.functions\1.0.29\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :    at System.Runtime.Loader.AssemblyLoadContext.LoadFromPath(IntPtr ptrNativeAssemblyLoadContext, String ilPath, String niPath, ObjectHandleOnStack retAssembly) [C:\Git\PolicyStaging\src\PolicyStaging\PolicyStaging.csproj]
C:\Users\D45\.nuget\packages\microsoft.net.sdk.functions\1.0.29\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :    at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath) [C:\Git\PolicyStaging\src\PolicyStaging\PolicyStaging.csproj]
C:\Users\D45\.nuget\packages\microsoft.net.sdk.functions\1.0.29\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :    at System.Reflection.Assembly.LoadFrom(String assemblyFile) [C:\Git\PolicyStaging\src\PolicyStaging\PolicyStaging.csproj]
C:\Users\D45\.nuget\packages\microsoft.net.sdk.functions\1.0.29\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :    at System.Reflection.Assembly.LoadFromResolveHandler(Object sender, ResolveEventArgs args) [C:\Git\PolicyStaging\src\PolicyStaging\PolicyStaging.csproj]
C:\Users\D45\.nuget\packages\microsoft.net.sdk.functions\1.0.29\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :    at System.AppDomain.InvokeResolveEvent(ResolveEventHandler eventHandler, RuntimeAssembly assembly, String name) [C:\Git\PolicyStaging\src\PolicyStaging\PolicyStaging.csproj]
C:\Users\D45\.nuget\packages\microsoft.net.sdk.functions\1.0.29\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :    at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes) [C:\Git\PolicyStaging\src\PolicyStaging\PolicyStaging.csproj]
C:\Users\D45\.nuget\packages\microsoft.net.sdk.functions\1.0.29\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :    at System.Reflection.RuntimeAssembly.GetExportedTypes() [C:\Git\PolicyStaging\src\PolicyStaging\PolicyStaging.csproj]
C:\Users\D45\.nuget\packages\microsoft.net.sdk.functions\1.0.29\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :    at MakeFunctionJson.FunctionJsonConverter.TryGenerateFunctionJsons() [C:\Git\PolicyStaging\src\PolicyStaging\PolicyStaging.csproj]
C:\Users\D45\.nuget\packages\microsoft.net.sdk.functions\1.0.29\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :    at MakeFunctionJson.FunctionJsonConverter.TryRun() [C:\Git\PolicyStaging\src\PolicyStaging\PolicyStaging.csproj]
C:\Users\D45\.nuget\packages\microsoft.net.sdk.functions\1.0.29\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :  [C:\Git\PolicyStaging\src\PolicyStaging\PolicyStaging.csproj]
C:\Users\D45\.nuget\packages\microsoft.net.sdk.functions\1.0.29\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :  [C:\Git\PolicyStaging\src\PolicyStaging\PolicyStaging.csproj]
C:\Users\D45\.nuget\packages\microsoft.net.sdk.functions\1.0.29\build\netstandard1.0\Microsoft.NET.Sdk

I've tried to create a simple reproduction in a new project but I'm unfortunately unable to, so it's a bit hard to say what exactly is causing this. Mostly, I'm posting this issue here in hopes that someone will have suggestions on how to resolve it.

@Alxandr
Copy link
Author

Alxandr commented Nov 21, 2019

I managed to make a pretty simple reproduction: https://gist.github.com/Alxandr/de2988691b5a8546a36b085ba009c78f

The gist of it;

  1. Make a new azure functions project.
  2. Add a dependency to System.Collections.Immutable 1.6.0.
  3. Use dependency in a function (might need to be in the function signature).
  4. Build.

@AArnott
Copy link

AArnott commented Nov 21, 2019

It looks like it works up to S.C.I. 1.5.0. 1.6.0 is the first one to cause a failure.

@simonvane
Copy link

I had a similar issue at runtime when some library code my function was using called ToImmutableList.

The issue occurs with both System.Collections.Immutable 1.6.0 and 1.7.0. Downgrading to version 1.5.0 resolved the issue after a very considerable amount of wasted time.

System.MissingMethodException
Method not found: 'System.Collections.Immutable.ImmutableList`1<!!0> System.Collections.Immutable.ImmutableList.ToImmutableList(Builder<!!0>)'.

@liliankasem
Copy link
Member

Looks like PR to fix this issue has been merged

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

4 participants