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

All in a sudden Functions compilation in Visual Studio fails with exception #139

Closed
ahmelsayed opened this issue Nov 13, 2017 · 12 comments
Closed

Comments

@ahmelsayed
Copy link
Contributor

From @ChristianWeyer on November 12, 2017 20:57

Hi all,

Did anybody ever see this?

I have a .NET 4.6.1 project. Everything worked fine - util a certain point.
From one moment to the other I get this exception:

2>C:\Users\Christian Weyer\.nuget\packages\microsoft.net.sdk.functions\1.0.6\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(32,5): warning :
2>C:\Users\Christian Weyer\.nuget\packages\microsoft.net.sdk.functions\1.0.6\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(32,5): error : System.IO.FileNotFoundException: Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.
2>C:\Users\Christian Weyer\.nuget\packages\microsoft.net.sdk.functions\1.0.6\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(32,5): error : File name: 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
2>C:\Users\Christian Weyer\.nuget\packages\microsoft.net.sdk.functions\1.0.6\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(32,5): error :    at System.Signature.GetSignature(Void* pCorSig, Int32 cCorSig, RuntimeFieldHandleInternal fieldHandle, IRuntimeMethodInfo methodHandle, RuntimeType declaringType)
2>C:\Users\Christian Weyer\.nuget\packages\microsoft.net.sdk.functions\1.0.6\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(32,5): error :    at System.Reflection.RuntimeMethodInfo.FetchNonReturnParameters()
2>C:\Users\Christian Weyer\.nuget\packages\microsoft.net.sdk.functions\1.0.6\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(32,5): error :    at System.Reflection.RuntimeMethodInfo.GetParameters()
2>C:\Users\Christian Weyer\.nuget\packages\microsoft.net.sdk.functions\1.0.6\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(32,5): error :    at MakeFunctionJson.MethodInfoExtensions.GetDisabled(MethodInfo method)
2>C:\Users\Christian Weyer\.nuget\packages\microsoft.net.sdk.functions\1.0.6\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(32,5): error :    at MakeFunctionJson.MethodInfoExtensions.HasUnsuportedAttributes(MethodInfo method, String& error)
2>C:\Users\Christian Weyer\.nuget\packages\microsoft.net.sdk.functions\1.0.6\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(32,5): error :    at MakeFunctionJson.FunctionJsonConverter.TryGenerateFunctionJsons()
2>C:\Users\Christian Weyer\.nuget\packages\microsoft.net.sdk.functions\1.0.6\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(32,5): error :    at MakeFunctionJson.FunctionJsonConverter.TryRun()
2>C:\Users\Christian Weyer\.nuget\packages\microsoft.net.sdk.functions\1.0.6\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(32,5): error : 
2>C:\Users\Christian Weyer\.nuget\packages\microsoft.net.sdk.functions\1.0.6\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(32,5): error : WRN: Assembly binding logging is turned OFF.
2>C:\Users\Christian Weyer\.nuget\packages\microsoft.net.sdk.functions\1.0.6\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(32,5): error : To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
2>C:\Users\Christian Weyer\.nuget\packages\microsoft.net.sdk.functions\1.0.6\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(32,5): error : Note: There is some performance penalty associated with assembly bind failure logging.
2>C:\Users\Christian Weyer\.nuget\packages\microsoft.net.sdk.functions\1.0.6\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(32,5): error : To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
2>C:\Users\Christian Weyer\.nuget\packages\microsoft.net.sdk.functions\1.0.6\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(32,5): error : 
2>C:\Users\Christian Weyer\.nuget\packages\microsoft.net.sdk.functions\1.0.6\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(32,5): error : Error generating functions metadata
2>C:\Users\Christian Weyer\.nuget\packages\microsoft.net.sdk.functions\1.0.6\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(32,5): error :
2>C:\Users\Christian Weyer\.nuget\packages\microsoft.net.sdk.functions\1.0.6\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(32,5): error : Metadata generation failed.
2>Done building project "HomeAutomation-Functions.csproj" -- FAILED.

I restarted VS, no help.
Any idea?

Thanks!

Copied from original issue: Azure/Azure-Functions#586

@ahmelsayed
Copy link
Contributor Author

From @tohling on November 13, 2017 19:0

Could you add an explicit reference for Newtonsoft version 9.0.1 and see if the error goes away?

@ahmelsayed
Copy link
Contributor Author

From @ChristianWeyer on November 13, 2017 20:32

Thanks for this idea. Yep, tried that. Same result.

After further investigating, I found my issue is similar to this one:
#115
dotnet/sdk#1405

@scottcha
Copy link

scottcha commented Dec 7, 2017

@ahmelsayed did you ever resolve this? I just ran in to this too but haven't been able to identify the right fix to resolve it.
Thanks

@Yvand
Copy link

Yvand commented Dec 12, 2017

Hello, I have exactly this same error in my .NET 4.6.1 Azure function project, but it's really not clear how I should fix it.
I added this in my .csproj but it doesn't change anything:

<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>

Can anybody provide a simple explanation how to fix this?
Thanks

@scottcha
Copy link

@Yvand I tried the binding redirect too but it didn't help as I believe the error is happening at runtime for the function generator and not in your components. If you see my referenced comment above I basically had to go through the changes line by line to find the offending code (in my case it was refactoring some azure auth code to a shared method) and remove that code. There may be other methods but that painstaking one was the only one I found which resolved this in my instance.

@Yvand
Copy link

Yvand commented Dec 12, 2017

HI @scottcha, aahh ok, thank you.
This is very bad, I realize now that I get this error just because I created a class that inherits JsonMediaTypeFormatter, I have no idea how to work around this...

@cschwendtner
Copy link
Contributor

cschwendtner commented Dec 28, 2017

@Yvand I had a similar issue. I moved all "my" code (not the functions) into a separate project. What also worked was changing the access modifier of "my" classes (not the functions) to internal. Both approaches solved the problem for me.

@Jordy84
Copy link

Jordy84 commented Jan 4, 2018

@cschwendtner Moving my code to a separate class library project mitigated the problem for me. Thanks!

@ahmelsayed
Copy link
Contributor Author

fixed by @cschwendtner in #151 Please update to 1.0.8

@Moffmo
Copy link

Moffmo commented Feb 15, 2018

I'm still getting this issue with 1.0.8 on .NET Standard 2.0. (Functions V2).

Severity Code Description Project File Line Suppression State
Error System.IO.FileNotFoundException: Could not load file or assembly 'System.ValueTuple, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.
File name: 'System.ValueTuple, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
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
Mobility.Services.Functions C:\Users\MatthewBa.nuget\packages\microsoft.net.sdk.functions\1.0.8\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets 39

I will try the work around now. I'm a bit confused how my function can call my code in other project if I mark it all as internal?

Thanks.

EDIT: Even an empty .net standard 1.08 project will not compile. Downgrading to 1.07 is the only option right now.

@cschwendtner
Copy link
Contributor

cschwendtner commented Feb 15, 2018

@Moffmo - The fix in #151 / 1.0.8 does only fix certain situations (not the "whole" underlying problem) - see this comment.

Compiling an empty Azure Functions V2 (netstandard2.0) project (with 1.0.8) works fine on my machine.
Could you create a sample project to reproduce the error?

The workaround (that was described in this comment) is changing the access modifier of "your" classes (not the functions) to internal OR to move "your" code (not the functions) into a separate project - not doing both.

@jordan112
Copy link

jordan112 commented Feb 28, 2018

I'm getting the same issue. Created a StackOverflow for it. StackOverflow link

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

7 participants