azure-webjobs-sdk icon indicating copy to clipboard operation
azure-webjobs-sdk copied to clipboard

System.TypeLoadException at System.Reflection.CustomAttribute._CreateCaObject

Open JORGEGO opened this issue 2 years ago • 2 comments

Dear all, Yesterday, started my nightmare... I have upgrade my Azure Functions to .NET 6.0 deploy from Visual Studio 2022 from development environment (all as expectation). but my nightmare started on Azure DevOps, when I deploy using Pipeline, again and again same error:

/25/2022, 12:50:47.255 PM System.TypeLoadException at System.Reflection.CustomAttribute._CreateCaObject System.TypeLoadException System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e System.Reflection.CustomAttribute.CreateCaObject Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexingException Error indexing method 'SecurityB2BFunction' Microsoft.Azure.WebJobs.Host, Version=3.0.32.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexer+<IndexMethodAsync>d__21.MoveNext System.TypeLoadException Could not load type 'System.Runtime.CompilerServices.AsyncTaskMethodBuilder1' from assembly 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e System.Reflection.CustomAttribute._CreateCaObject 3 [{"severityLevel":"Error","outerId":"0","message":"Error indexing method 'SecurityB2BFunction'","type":"Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexingException","id":"54426330","parsedStack":[{"assembly":"Microsoft.Azure.WebJobs.Host, Version=3.0.32.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","method":"Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexer+<IndexMethodAsync>d__21.MoveNext","level":0,"line":157,"fileName":"C:\\projects\\azure-webjobs-sdk-rqm4t\\src\\Microsoft.Azure.WebJobs.Host\\Indexers\\FunctionIndexer.cs"},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw","level":1,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess","level":2,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification","level":3,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.GetResult","level":4,"line":0},{"assembly":"Microsoft.Azure.WebJobs.Host, Version=3.0.32.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","method":"Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexer+<IndexTypeAsync>d__17.MoveNext","level":5,"line":85,"fileName":"C:\\projects\\azure-webjobs-sdk-rqm4t\\src\\Microsoft.Azure.WebJobs.Host\\Indexers\\FunctionIndexer.cs"}]},{"severityLevel":"Error","outerId":"54426330","message":"Could not load type 'System.Runtime.CompilerServices.AsyncTaskMethodBuilder1' from assembly 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.","type":"System.TypeLoadException","id":"20074930","parsedStack":[{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Reflection.CustomAttribute.CreateCaObject","level":0,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Reflection.CustomAttribute.CreateCaObject","level":1,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Reflection.CustomAttribute.AddCustomAttributes","level":2,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Reflection.CustomAttribute.GetCustomAttributes","level":3,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Reflection.CustomAttribute.GetCustomAttributes","level":4,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Reflection.RuntimeMethodInfo.GetCustomAttributes","level":5,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Attribute.GetCustomAttributes","level":6,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Attribute.GetCustomAttribute","level":7,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Reflection.CustomAttributeExtensions.GetCustomAttribute","level":8,"line":0},{"assembly":"Microsoft.Azure.WebJobs.Host, Version=3.0.32.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","method":"Microsoft.Azure.WebJobs.Host.TypeUtility.IsAsync","level":9,"line":154,"fileName":"C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\TypeUtility.cs"},{"assembly":"Microsoft.Azure.WebJobs.Host, Version=3.0.32.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","method":"Microsoft.Azure.WebJobs.Host.TypeUtility.IsAsyncVoid","level":10,"line":168,"fileName":"C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\TypeUtility.cs"},{"assembly":"Microsoft.Azure.WebJobs.Host, Version=3.0.32.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","method":"Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexer+<IndexMethodAsyncCore>d__22.MoveNext","level":11,"line":310,"fileName":"C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Indexers\FunctionIndexer.cs"},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw","level":12,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess","level":13,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification","level":14,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.GetResult","level":15,"line":0},{"assembly":"Microsoft.Azure.WebJobs.Host, Version=3.0.32.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","method":"Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexer+<IndexMethodAsync>d__21.MoveNext","level":16,"line":149,"fileName":"C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Indexers\FunctionIndexer.cs"}]}] exception {"LogLevel":"Error","prop{OriginalFormat}":"Error indexing method

And that for all the functions... But when I done the same form Visual Studio to production works perfect Target Framework net6.0 Deployment Mode Framework-dependent Target Runtime Portable

So any one could give me some light...

Thanks

JORGEGO avatar Feb 25 '22 13:02 JORGEGO

I believe I've found the solution... When I am deployment form Visual Studio it force to me to change the Runtime from 3 to 4... Know I believe I could deploy again from Azure Dev Ops, I must do more test but... it seems works, please conform to me that...

JORGEGO avatar Feb 25 '22 13:02 JORGEGO

The point it is that It was so complicate change the runtime version from Azure... it show 1 or 3 not 4, for it is only from Visual Studio

JORGEGO avatar Feb 25 '22 13:02 JORGEGO