我创建了一个非常简单的程序,它应该列出 Google Cloud 项目中可用的主题。代码很简单:
using System;
using Google.Pubsub.V1;
public class Test
{
static void Main()
{
var projectId = "(fill in project ID here...)";
var projectName = PublisherClient.FormatProjectName(projectId);
var client = PublisherClient.Create();
foreach (var topic in client.ListTopics(projectName))
{
Console.WriteLine(topic.Name);
}
}
}
当我从针对 .NET 4.5 的“常规”msbuild 项目运行它时,它运行良好。当我尝试将 dotnet cli (1.0.0-preview2-003121) 与以下project.json
文件一起使用时:
{
"buildOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Google.Pubsub.V1": "1.0.0-beta01"
},
"frameworks": {
"net45": { }
}
}
...我看到一个例外:
Unhandled Exception: System.IO.FileNotFoundException: Error loading native library.
Not found in any of the possible locations c:\[...]\Pubsub.Demo\bin\Debug\net45\win7-x64\nativelibs\windows_x64\grpc_csharp_ext.dll
at Grpc.Core.Internal.UnmanagedLibrary.FirstValidLibraryPath(String[] libraryPathAlternatives)
at Grpc.Core.Internal.UnmanagedLibrary..ctor(String[] libraryPathAlternatives)
at ...
我没有尝试以 .NET Core 为目标,所以不应该支持吗?