azure-functions-openapi-extension icon indicating copy to clipboard operation
azure-functions-openapi-extension copied to clipboard

Error with loading file Microsoft.Azure.WebJobs.Extensions.Http.dll

Open Ashan-FCC opened this issue 3 years ago • 10 comments

I'm using 0.7.2-preview version and I get this error when I go to URL /swagger/ui

image

The assemble is available in bin/Debug/netcore3.1/ directory but not in bin/Debug/netcore3.1/bin/.

I tried manually copying this file to the bin/Debug/netcore3.1/bin/ directory. The error goes away then, but I see an empty API definition.

image

Ashan-FCC avatar Jul 28 '21 08:07 Ashan-FCC

@Ashan-FCC Thanks for the issue! Would you please try the new release, v0.8.1-preview and let me know?

If the same issue still persists, please let me know how to reproduce your issue on my end.

justinyoo avatar Aug 12 '21 13:08 justinyoo

@justinyoo I was able to reproduce the same behavior as @Ashan-FCC on v0.8.1-preview

The http dll is missing from bin/Debug/netcore3.1/bin/

image

Core Tools Version: 3.0.3442 Function Runtime Version: 3.0.15417.0

alinagard avatar Aug 18 '21 04:08 alinagard

Alright. Would you please provide steps you've reproduced this error, so that I can follow the steps?

justinyoo avatar Aug 18 '21 05:08 justinyoo

Ok I did something super simple. I followed the instructions defined here: https://github.com/Azure/azure-functions-openapi-extension/blob/main/docs/enable-open-api-endpoints-in-proc.md

  1. Installed the lib on my project v0.8.1-preview. Code snippets from my csproj <TargetFramework>netcoreapp3.1</TargetFramework> <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.OpenApi" Version="0.8.1-preview" />

  2. The class I'm trying to test looks like this. (sorry for the screenshot). The class and the functions are not static. Do I have to have the rest of the functions marked as ignore? Bc they are not. Only this one has the decorators, Just in case. image

  3. Run the functions app on my http://localhost:7071

  4. Navigate to http://localhost:7071/api/swagger/ui

  5. Then the console throws the assembly error and the ui says error

Thanks @justinyoo

alinagard avatar Aug 18 '21 06:08 alinagard

@alinapach Could you confirm whether your bin/Debug/netcoreapp3.1 and bin/Debug/netcoreapp3.1/bin directories have only one *.deps.json file or multiple *.deps.json files?

justinyoo avatar Sep 03 '21 16:09 justinyoo

Getting this on my end as well. I'm able to reproduce just by using the starter that visual studio provides and removing all of the static keywords

pmiller22 avatar Sep 09 '21 21:09 pmiller22

There are possibly two causes on this issue:

  1. If there are multiple *.deps.json files within your bin/Debug/netcoreapp3.1 or bin/Debug/netcoreapp3.1/bin directory, it might be the one, as mentioned above.

  2. Try this approach on your .csproj file, which is a sort of official workaround for the time being:

    <PropertyGroup>
      ...
      <_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput>
    </PropertyGroup>
    

justinyoo avatar Sep 09 '21 22:09 justinyoo

There are possibly two causes on this issue:

  1. If there are multiple *.deps.json files within your bin/Debug/netcoreapp3.1 or bin/Debug/netcoreapp3.1/bin directory, it might be the one, as mentioned above.
  2. Try this approach on your .csproj file, which is a sort of official workaround for the time being:
    <PropertyGroup>
      ...
      <_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput>
    </PropertyGroup>
    

It is easy to reproduce the bug, and the _FunctionsSkipCleanOutput didn't work for me.

steps:

  1. follow the article https://techcommunity.microsoft.com/t5/apps-on-azure/create-and-publish-openapi-enabled-azure-functions-with-visual/ba-p/2381067 to create a template project with OpenApi 0.7.2-preview.
  2. change the openapi to 0.8.1-preview (optional)
  3. add <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Http" Version="3.0.12" /> to the project.
  4. press F5 to start debugging, then visit http://localhost:7071/api/swagger/ui you will get error Could not load file or assembly 'Microsoft.Azure.WebJobs.Extensions.Http, Version=3.0.12.0
  5. add <_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput> to the project
  6. visit http://localhost:7071/api/swagger/ui again, it seems work and the assembly is fine right now. but you will get No operations defined in spec! which mean there is nothing in the openapi document.

We did some research and find out it could be this code Where(p => p.GetParameters().FirstOrDefault(q => q.ExistsCustomAttribute<HttpTriggerAttribute>()) != null) HttpTriggerAttribute may have 3.0.2 and 3.0.12 conflict.

A possible solution for me is to downgrade Microsoft.Azure.WebJobs.Extensions.Http to 3.0.2

Wish my practice can help.

redpandabigcat avatar Sep 10 '21 08:09 redpandabigcat

There are possibly two causes on this issue:

  1. If there are multiple *.deps.json files within your bin/Debug/netcoreapp3.1 or bin/Debug/netcoreapp3.1/bin directory, it might be the one, as mentioned above.
  2. Try this approach on your .csproj file, which is a sort of official workaround for the time being:
    <PropertyGroup>
      ...
      <_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput>
    </PropertyGroup>
    

It is easy to reproduce the bug, and the _FunctionsSkipCleanOutput didn't work for me.

steps:

  1. follow the article https://techcommunity.microsoft.com/t5/apps-on-azure/create-and-publish-openapi-enabled-azure-functions-with-visual/ba-p/2381067 to create a template project with OpenApi 0.7.2-preview.
  2. change the openapi to 0.8.1-preview (optional)
  3. add <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Http" Version="3.0.12" /> to the project.
  4. press F5 to start debugging, then visit http://localhost:7071/api/swagger/ui you will get error Could not load file or assembly 'Microsoft.Azure.WebJobs.Extensions.Http, Version=3.0.12.0
  5. add <_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput> to the project
  6. visit http://localhost:7071/api/swagger/ui again, it seems work and the assembly is fine right now. but you will get No operations defined in spec! which mean there is nothing in the openapi document.

We did some research and find out it could be this code Where(p => p.GetParameters().FirstOrDefault(q => q.ExistsCustomAttribute<HttpTriggerAttribute>()) != null) HttpTriggerAttribute may have 3.0.2 and 3.0.12 conflict.

A possible solution for me is to downgrade Microsoft.Azure.WebJobs.Extensions.Http to 3.0.2

Wish my practice can help.

This exactly. I was able to resolve my issues when I removed a package reference that used 3.0.12. (In this case, I was using a third-party package to generate open api documents in the past and we were migrating to this package because of another bug...) When I removed the package, all references were downgraded to 3.0.2 and my problems went away

pmiller22 avatar Sep 10 '21 13:09 pmiller22

There are possibly two causes on this issue:

  1. If there are multiple *.deps.json files within your bin/Debug/netcoreapp3.1 or bin/Debug/netcoreapp3.1/bin directory, it might be the one, as mentioned above.
  2. Try this approach on your .csproj file, which is a sort of official workaround for the time being:
    <PropertyGroup>
      ...
      <_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput>
    </PropertyGroup>
    

It is easy to reproduce the bug, and the _FunctionsSkipCleanOutput didn't work for me.

steps:

  1. follow the article https://techcommunity.microsoft.com/t5/apps-on-azure/create-and-publish-openapi-enabled-azure-functions-with-visual/ba-p/2381067 to create a template project with OpenApi 0.7.2-preview.
  2. change the openapi to 0.8.1-preview (optional)
  3. add <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Http" Version="3.0.12" /> to the project.
  4. press F5 to start debugging, then visit http://localhost:7071/api/swagger/ui you will get error Could not load file or assembly 'Microsoft.Azure.WebJobs.Extensions.Http, Version=3.0.12.0
  5. add <_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput> to the project
  6. visit http://localhost:7071/api/swagger/ui again, it seems work and the assembly is fine right now. but you will get No operations defined in spec! which mean there is nothing in the openapi document.

We did some research and find out it could be this code Where(p => p.GetParameters().FirstOrDefault(q => q.ExistsCustomAttribute<HttpTriggerAttribute>()) != null) HttpTriggerAttribute may have 3.0.2 and 3.0.12 conflict.

A possible solution for me is to downgrade Microsoft.Azure.WebJobs.Extensions.Http to 3.0.2

Wish my practice can help.

How do you know the API conflicts?

Smartisa avatar Feb 28 '22 13:02 Smartisa