问题
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 getSID
of your profile - type
regedit
under start menu, right click on it and selectRun 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