Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Nuget package is tied to AutoFac 4.0.0 #2

Closed
richardacre opened this issue Jul 4, 2018 · 14 comments
Closed

Nuget package is tied to AutoFac 4.0.0 #2

richardacre opened this issue Jul 4, 2018 · 14 comments

Comments

@richardacre
Copy link

It needs to target >=4.0.0 as the reset of my project is on 4.6.1

@holgerleichsenring
Copy link
Owner

Hi richardacre,

actually, the definition in .nuget should lead to let you use any version above or equal to 4.0. Have a look onto the nuget spec.

<!-- Accepts any version 6.1 and above. -->
<PackageReference Include="ExamplePackage" Version="6.1" />

Can you add some more detail about your exceptions/ loading issues you get? I can add a new functions project, reference autofac 4.6.1 and add the nuget package without any issues.

@richardacre
Copy link
Author

richardacre commented Jul 5, 2018

I've got a solution with multiple projects in, all referencing AutoFac 4.6.1 which builds fine. If I add a reference to AutofacOnFunctions to one of them (my Functions project) and try to build it I get a build error like "AutoFac , Version=4.0.0, or one of its dependencies. The system cannot find the file specified." . I'll continue to investigate, it may be VS2017 being a pain.

Edit: Fixed it I had to upgrade Microsoft.NET.Sdk.Functions to v1.0.14
Edit Edit: No that didn't. I had the relevant code commented out, once I had code that referenced AutofacOnFunctios the error came back!

This is what my project.assets.json has come out like, note AutofacOnFunctions is still saying it wants 1.0.13 and 4.0.0

{ "version": 3, "targets": { ".NETStandard,Version=v2.0": { "Autofac/4.6.1": { "type": "package", "dependencies": { "NETStandard.Library": "1.6.0", "System.ComponentModel": "4.0.1" }, "compile": { "lib/netstandard1.1/Autofac.dll": {} }, "runtime": { "lib/netstandard1.1/Autofac.dll": {} } }, "AutofacOnFunctions/0.1.5": { "type": "package", "dependencies": { "Autofac": "4.0.0", "Microsoft.NET.Sdk.Functions": "1.0.13" }, "compile": { "lib/netstandard2.0/AutofacOnFunctions.dll": {} }, "runtime": { "lib/netstandard2.0/AutofacOnFunctions.dll": {} } }, ... }

@holgerleichsenring
Copy link
Owner

AutofacOnFunctions uses Azure Functions v2 based on .net standard. V1 can be used with .net framework. Which one do you use?
Unluckily I wasn't successful in creating a nuget package based on Azure Functions v1. You can read the reasons here: codingsoul: azure functions dependency injection with autofac. Scroll down to the "update" section.

@richardacre
Copy link
Author

We're using .Net Core so it'll be V2

@holgerleichsenring
Copy link
Owner

I double checked your project.assets.json with mine and cannot see any difference. Can you put a screenshot or a sample project anywhere that I can reproduce this with your code?

@jvmeir
Copy link

jvmeir commented Aug 21, 2018

I have the same issue (see below). The code is quite sensitive to share, but let me know what info can help and I'll try to provide it. Thanks in advance!

Error: System.IO.FileNotFoundException: Could not load file or assembly 'Autofac, Version=4.0.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da' or one of its dependencies. The system cannot find the file specified.

File name: 'Autofac, Version=4.0.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da'
at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)
at System.Reflection.RuntimeAssembly.GetExportedTypes()
at MakeFunctionJson.FunctionJsonConverter.TryGenerateFunctionJsons()
at MakeFunctionJson.FunctionJsonConverter.TryRun()

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

Error generating functions metadata
(1, 1)

@jvmeir
Copy link

jvmeir commented Aug 21, 2018

Binding log:
image

@jvmeir
Copy link

jvmeir commented Aug 21, 2018

FYI: When I add your v2 project directly into my solution and link it up that way it works.

@holgerleichsenring
Copy link
Owner

Sorry for late answer, had been on vacation last two weeks.

Thanks for letting me know. Do you have this issue locally as well as when being deployed to azure?

@holgerleichsenring
Copy link
Owner

Can you try with latest version and check if it works?

@holgerleichsenring
Copy link
Owner

Closed due to no interaction anymore on this.

@magoicochea
Copy link

Hello

I have come across the same issue. It works when I have Autofac 4.0.0, but as soon as I update to 4.8.1 I get a build error. I assume it must be something related to binding redirects, but don't think you can do that on azure functions.

I am attaching a small project where you can see this happening.

AutofacOnFunctionsVersionIssue.zip

@holgerleichsenring
Copy link
Owner

thanks @magoicochea will have a look onto your sample 👍

@holgerleichsenring
Copy link
Owner

Finally this issue described in Azure Functions had been solved in Azure Functions v2 GA. redirects in Azure Functions

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

No branches or pull requests

4 participants