2

我看到 Visual Studio 进程Microsoft.VisualStudio.Web.Host.exe为 gRPC 锁定本机 dll 的问题grpc_csharp_ext.x86.dll

我们有一个在 IIS 中运行的 .net Framework 4.6.1 Web 应用程序,在 Windows 机器(Windows10 和服务器)上。它使用 gRPC 并与它捆绑以下 dll

Grpc.Core.dll
Grpc.Core.Api.dll
grpc_csharp_ext.x64.dll
grpc_csharp_ext.x86.dll

据我所知,gRPC库在这里为它的架构加载了正确的dll https://github.com/grpc/grpc/blob/2780136fcf9bd268aaddea74b115fbc2faa97c61/src/csharp/Grpc.Core/Internal/NativeExtension.cs#L83和从不尝试释放它。我相信这没关系,因为一旦运行过程停止,所有东西都应该被释放。

但是,如果您在 IIS 中运行应用程序并从 Visual Studio 附加调试器,然后尝试重新构建应用程序,Visual Studio 将要求您停止调试,执行构建并遇到此问题,主要表现为:

"...\packages\Grpc.Core.2.29.0\runtimes\win\native\grpc_csharp_ext.x86.dll" to "bin\grpc_csharp_ext.x86.dll". 
 Exceeded retry count of 10. Failed. The file is locked by: "Microsoft.VisualStudio.Web.Host.exe (34932)"
"...\packages\Grpc.Core.2.29.0\runtimes\win\native\grpc_csharp_ext.x86.dll" to "bin\grpc_csharp_ext.x86.dll". 
 The process cannot access the file 'bin\grpc_csharp_ext.x86.dll' because it is being used by another process.

我在 IIS 锁定相同的 dll 时遇到了类似的问题,并且我知道针对 gRPC https://github.com/grpc/grpc/issues/21867提出的这个问题导致Grpc_SkipNativeLibsCopy被创建。此问题已通过添加预构建应用程序池回收得到缓解。

然而,似乎没有任何方法可以解决这个问题,唯一的做法似乎是终止Microsoft.VisualStudio.Web.Host.exe进程。

任何人都可以帮助我们进一步了解如何阻止这种情况发生,或者找到一种更好的方法来缓解这个问题吗?

4

0 回答 0