c# - UWP 应用 CosmosDb 构造器抛出错误
问题描述
我有一个我以前从未见过的错误。在我的 CosmosDb DocumentClient 构造函数中:
docClient = new DocumentClient(new
Uri("https://docdb.documents.azure.com:443/"),
"key_here",new ConnectionPolicy { ConnectionMode = ConnectionMode.Direct,
ConnectionProtocol = Protocol.Tcp });
当我设置断点时,它会引发此错误:
A type initializer threw an exception. To determine which type,
inspect the InnerException's StackTrace property.
InnerException 的堆栈跟踪:
Severity Code Description Project File Line Suppression State
Warning MCG : warning MCG0007: Unresolved P/Invoke method
'DocumentDB.LogStoreViewer.dll!FreeIOManager'
for method 'System.Int32
Microsoft.Azure.Documents.LogStoreViewerInterop.
LogStoreViewerInteropWrapper.
FreeIOManager(System.IntPtr)'.
Calling this method would throw exception at runtime. Please make sure the
P/Invoke either points to a Windows API allowed in UWP applications,
or a native DLL that is part of the package. If for some reason your
P/Invoke does not satisfy those requirements,
please use [DllImport(ExactSpelling=true) to indicate that you understand
the implications of using non-UWP APIs.
在我的项目中,我引用了一个 .Net Standard 2.0 类库。根据错误信息,它看起来像
Microsoft.Azure.Documents.LogStoreViewerInterop.
LogStoreViewerInteropWrapper.
FreeIOManager(System.IntPtr)'.
我找不到这个来删除它或理解它的作用,所以不知道如何治愈这个邪恶的东西。
解决方案
推荐阅读
- python - Numba 可以用来继承 Keras 层吗?
- javascript - JavaScript 按钮点击事件
- javascript - 是否可以在javascript中将数组转换为NodeList?leetcode问题--链表--
- javascript - 检查数组中的对象是否包含数组中另一个对象中的所有值
- node.js - Twitter OAuth API 超时(Nginx 还是 Twitter?)
- excel-formula - 什么是阿拉伯上标数字?
- javascript - 我可以传递一个对象作为 onClick 函数的参数吗
- php - 如何从 PHP/MySQL 中检索逗号分隔的值?
- amazon-web-services - 如何从 Cognito 用户池获取联合 API 的访问令牌
- mysql - 如何从具有其他条件的表中删除多行?