Skip to content

FSI: Could not load file or assembly Azure.ResourceManager.Resources #10893

Closed

Description

@stmax82

Running the following in dotnet fsi:

#r "nuget: Azure.Identity, 1.3.0"
#r "nuget: Azure.ResourceManager.Resources, 1.0.0-preview.2"

let creds = Azure.Identity.DefaultAzureCredential()

// next line fails
let resourceClient = Azure.ResourceManager.Resources.ResourcesManagementClient("mySubscriptionId", creds)

Fails with:

error FS0193: Could not load file or assembly 'Azure.ResourceManager.Resources, Version=1.0.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8, processorArchitecture=MSIL'. The system cannot find the file specified.

Note that if Azure.ResourceManager.Resources is replaced with a similar NuGet package Azure.ResourceManager.Insights it works without errors:

#r "nuget: Azure.Identity, 1.3.0"
#r "nuget: Azure.ResourceManager.Insights, 1.0.0-preview.1"

let creds = Azure.Identity.DefaultAzureCredential()

// works fine
let insightsClient = Azure.ResourceManager.Insights.InsightsManagementClient("mySubscriptionId", creds)
  • Tested on Windows and Linux
  • dotnet: 5.0.100
  • fsi: 11.0.0.0 for F# 5.0

Activity

  1. KevinRansom commented on Jan 20, 2021

    @KevinRansom
    Contributor

    @stmax , hmmm this is quite interesting. Because the assembly is not resolvable even though it has already been loaded. I will dig in, see if I can find out what the issue is.

    --> Referenced 'C:/Users/codec/.nuget/packages/azure.resourcemanager.resources/1.0.0-preview.2/lib/netstandard2.0/Azure.ResourceManager.Resources.dll' (file may be locked by F# Interactive process)
    
    > let resourceClient = Azure.ResourceManager.Resources.ResourcesManagementClient("mySubscriptionId", creds);;
    
    
    error FS0193: Could not load file or assembly 'Azure.ResourceManager.Resources, Version=1.0.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8'. The system cannot find the file specified.
    
    >
    
  2. stmax82 commented on Jan 20, 2021

    @stmax82
    ContributorAuthor

    @KevinRansom thanks for looking into it.

    One more thing I tried is extracting the dll from the nuget package and referencing it directly (#r "Azure.ResourceManager.Resources.dll") - it led to the same error, so this does not seem to be a problem with #r nuget.

    Running the same code in a net5.0 console app works fine.

  3. added this to the Backlog milestone on Jan 20, 2021
  4. KevinRansom commented on Jan 20, 2021

    @KevinRansom
    Contributor

    @stmax , yes I tried the same thing last night ... it is an assembly resolution issue, I fear that somehow ... our resolve handlers aren't getting notified.

  5. KevinRansom commented on Jan 20, 2021

    @KevinRansom
    Contributor

    Okay I got it: thanks for this report.

    image

    The issue was actually quite interesting, and shows the evolution in the scenarios for resolution that FSI now has to cope with, thanks to nuget packages.

    Anyway, the fix is to make sure that the fsi, assembly resolve handler, will search the list of #r assemblies when trying to resolve assemblies to load.

  6. added a commit that references this issue on Jan 27, 2021
    a07da44
  7. added a commit that references this issue on Jan 27, 2021
    ae2ab7d
  8. stmax82 commented on Jan 29, 2021

    @stmax82
    ContributorAuthor

    thanks for the fix. didn't expect the name would be the problem :)

  9. modified the milestones: Backlog, 16.10 on Feb 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions