Failed to load native library grpc_csharp_ext.x86.dll while running Azure Function in Visual Studio

一笑奈何 提交于 2021-02-10 20:18:34

问题


lately I have encountered a following problem. Azure Function that is run in Visual Studio always throws an exception:

System.IO.IOException HResult=0x80131620 Message=Error loading native library "C:\Users\\AppData\Local\AzureFunctionsTools\Releases\2.16.0\cli\grpc_csharp_ext.x86.dll" Source=Grpc.Core StackTrace: at Grpc.Core.Internal.UnmanagedLibrary..ctor(String[] libraryPathAlternatives) at Grpc.Core.Internal.NativeExtension.LoadUnmanagedLibrary() at Grpc.Core.Internal.NativeExtension.LoadNativeMethods() at Grpc.Core.Internal.NativeExtension..ctor() at Grpc.Core.Internal.NativeExtension.Get() at Grpc.Core.GrpcEnvironment.GrpcNativeInit() at Grpc.Core.GrpcEnvironment..ctor() at Grpc.Core.GrpcEnvironment.AddRef() at Grpc.Core.Server..ctor(IEnumerable`1 options) at Microsoft.Azure.WebJobs.Script.Grpc.GrpcServer..ctor(FunctionRpcBase serviceImpl) in C:\azure-webjobs-sdk-script\src\WebJobs.Script.Grpc\Server\GrpcServer.cs:line 24

The file that is supposedly missing is at its place of course. I've tried to reinstall Azure Function Tools and Visual Studio and nothing helped. Any ideas?

Thanks in advance.

EDIT1:

The problem seems to be caused by non-english characters in the path to the library. I've just created another account without them and suddenly everything started to work.


回答1:


from the point that the root cause of error is because of the non-english characters in the path to the library, you can consider to rename path of your user profile.

To do so, here is the steps

  • Log out and login with another Administrator user to your PC
  • open command prompt by CTRL + R then type cmd
  • type wmic useraccount get name, sid and get SID of your profile
  • type regedit under start menu, right click on it and select Run as Administrator
  • Go under Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\YOUR_SID_HERE
  • Double Click on ProfileImagePath and change the value data according to your need (you can close Registry Editor)
  • go under USER PROFILES folder (%USERPROFILE%\..\) and change the path of your user profile accordingly
  • Restart your computer


来源:https://stackoverflow.com/questions/54289901/failed-to-load-native-library-grpc-csharp-ext-x86-dll-while-running-azure-functi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!