azure-sdk-for-net icon indicating copy to clipboard operation
azure-sdk-for-net copied to clipboard

Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1

Open jrockfl opened this issue 3 years ago • 6 comments
trafficstars

I have created an Azure Function App with .NET Framework 4.71 and I'm receiving the following exception.

Microsoft.Azure.WebJobs.Host.FunctionInvocationException : Exception while executing function: Function1 ---> System.IO.FileNotFoundException : Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.\r\n at System.MemoryExtensions.AsSpan(String text)

var resourceIdentifier = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000");

image

I have also set this up in a Console App .NET Framework 4.7.1 without any issues.

image

What can I do to resolve this issue?

jrockfl avatar Feb 13 '22 17:02 jrockfl

Thank you for your feedback. Tagging and routing to the team member best able to assist.

jsquire avatar Feb 14 '22 13:02 jsquire

Thank you for reaching us, @archerzz please check if this is the mgmt issue.

ArthurMa1978 avatar Feb 17 '22 10:02 ArthurMa1978

@jrockfl ResourceIdentifiter is from Azure.Core, did you add it in your project dependency?

archerzz avatar Mar 02 '22 07:03 archerzz

Yes, I added Azure.Core. It was in the nuget package. Loading Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1 is something different.

I was able to get this to work with a console app but not Azure Function.

-----Original Message----- From: "Mingzhe Huang" @.> Sent: Wednesday, March 2, 2022 2:25am To: "Azure/azure-sdk-for-net" @.> Cc: "jrockfl" @.>, "Mention" @.> Subject: Re: [Azure/azure-sdk-for-net] Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1 (Issue #26987)

@jrockfl ResourceIdentifiter is from Azure.Core, did you add it in your project dependency? — Reply to this email directly, view it on GitHub , or unsubscribe . Triage notifications on the go with GitHub Mobile for iOS or Android . You are receiving this because you were mentioned.Message ID: @.***>

jrockfl avatar Mar 02 '22 20:03 jrockfl

Hi, I have exactly the same issue after migrating from Microsoft.Azure.ServiceBus to Azure.Messaging.ServiceBus. When I run my solution locally, it executes. However deploying the solution onto a Windows Server 2019 it fails with the following:

Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) at System.Threading.Tasks.ValueTask`1.get_IsCompleted() at Azure.Messaging.ServiceBus.Amqp.AmqpReceiver.<ReceiveMessagesAsync>d__36.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Azure.Messaging.ServiceBus.ServiceBusReceiver.<ReceiveMessagesAsync>d__39.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Azure.Messaging.ServiceBus.ReceiverManager.<ReceiveAndProcessMessagesAsync>d__13.MoveNext()

Not sure if its related or helps resolve...

Thanks

DomCotton avatar May 25 '22 16:05 DomCotton

I had this exact error message when I tried to use Azure in my project. I searched for the .dll on my computer and found the correct version. Added it to the GAC using gacutil -i . Seemed to solve that issue but then it threw the same error with a new assembly name.

jfeller403 avatar Feb 13 '23 02:02 jfeller403

@jrockfl @DomCotton @jfeller403 This should be a binding redirect problem. Try to explicitly upgrade Unsafe to latest version, or try binding redirect as indicated here.

archerzz avatar Aug 01 '23 06:08 archerzz

Hi @jrockfl. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue.

github-actions[bot] avatar Aug 07 '23 06:08 github-actions[bot]

Hi @jrockfl, we're sending this friendly reminder because we haven't heard back from you in 7 days. We need more information about this issue to help address it. Please be sure to give us your input. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!

github-actions[bot] avatar Aug 14 '23 09:08 github-actions[bot]