AdDeviceAsync方法的注册表抛出异常ArgumentNull。参数、寄存器管理器和输出参数no美金为空,但它仍然引发异常。
异常:{"Message":"ErrorCode: ArgumentNull; BadRequest","ExceptionMessage":"Track ID: adf7e83e7db046969086702500cbe73b-G: 2-TimeStamp:03/21/2018 14:09:50"}方法: ProjectXXX. NTB. FN. Device注册。标识创建服务。描述:意外异常
是与微软有关的问题。天青。设备库??
代码
RegistryManager registryManager = null;
void Initialize()
{
registryManager = RegistryManager.CreateFromConnectionString(AppSetting.IoTHubConnectionString);
}
public async Task<string> CreateDeviceIdentity(string deviceId, string deviceKey)
{
Device device = new Device(deviceId);
Device newdevice = new Device();
Exception exception = null;
bool bExceptionHasOccured = false;
string token = string.Empty;
string primarySasToken = Base64Encode(deviceKey);
string secondarySasToken = Base64Encode($"{deviceId}-{deviceId}");
device.Authentication = new AuthenticationMechanism
{
SymmetricKey = new SymmetricKey
{
PrimaryKey = primarySasToken,
SecondaryKey = secondarySasToken
}
};
try
{
newdevice = await registryManager.AddDeviceAsync(device);
break;
}
catch (DeviceAlreadyExistsException)
{
token = GetDeviceToken(deviceId);
break;
}
catch (IotHubThrottledException e)
{
}
catch (SocketException e)
{
}
catch (Exception e)
{
}
token = newdevice.Authentication.SymmetricKey.PrimaryKey;
return token;
}
堆栈跟踪系统。在微软。天青。设备。HttpClientHelperd__36。MoveNext(微软。天青。设备,版本=1.0.0.0,文化=中性,PublicKeyToken=31bf3856ad364e35)at System.运行时。CompilerServices.TaskAwaiter.在System.运行时。CompilerServices.TaskAwaiter.在Microsoft中处理非成功和调试器通知(mcorlib,版本=4.0.0.0,文化=中性,PublicKeyToken=b77a5c561934e089)。天青。设备。HttpClientHelperd__121.MoveNext(微软。天青。设备,版本=1.0.0.0,文化=中性,PublicKeyToken=31bf3856ad364e35)at System.运行时。CompilerServices.TaskAwaiter.在System.运行时。CompilerServices.TaskAwaiter.在System.运行时。CompilerServices.TaskAwaiter
1.在ProjectXXX. NTB. FN. Device注册获得结果(mcorlib,版本=4.0.0.0,文化=中性,PublicKeyToken=b77a5c561934e089)。d__6。MoveNext(ProjectXXX. NTB. FN.设备注册,版本=1.0.0.0,文化=中性,PublicKeyToken=nullProjectXXX. NTB. FN.设备注册,版本=1.0.0.0,文化=中性,PublicKeyToken=null: D:\ProjectXXX\ProjectXXX. NTB\ProjectXXX. NTB\Device注册Lib\ProjectXXX. NTB. FN.设备注册\IdtyCreationService.csProjectXXX. NTB. FN.设备注册,版本=1.0.0.0,文化=中性,PublicKeyToken=null:122)
通过降级微软。蔚蓝色的1.5.1至1.3.2中的设备应正常工作
有效的SymmetricKey必须是Base64编码的字符串,长度在16到64字节之间。
我不知道什么样的DeviceKey
。我使用一个GUID并用下面的代码块进行测试,设备可以成功创建。
public static async Task<string> CreateDeviceIdentity(string deviceId)
{
Device device = new Device(deviceId);
Device newdevice = new Device();
string token = string.Empty;
var primaryKey = Guid.NewGuid();
var secondaryKey = Guid.NewGuid();
byte[] bytes = Encoding.UTF8.GetBytes(primaryKey.ToString());
string base64PrimaryKey = Convert.ToBase64String(bytes);
bytes = Encoding.UTF8.GetBytes(secondaryKey.ToString());
string base64SecondaryKey = Convert.ToBase64String(bytes);
try
{
device.Authentication = new AuthenticationMechanism
{
SymmetricKey = new SymmetricKey
{
PrimaryKey = base64PrimaryKey,
SecondaryKey = base64SecondaryKey
}
};
newdevice = await registryManager.AddDeviceAsync(device);
}
catch (Exception ex)
{
}
token = newdevice.Authentication.SymmetricKey.PrimaryKey;
return token;
}
当我降级微软时,它起了作用。蔚蓝。从1.5.1到1.3.2的装置
接口说明 用于设备注册,当第三方应用安装时调用。 接口地址 https://pan.baidu.com/rest/2.0/xpan/device?method=register 请求方式 GET 请求参数 参数 类型 必需 示例值 描述 device_type string 是 2020073115900228875 设备类型,具体值需要线下提供,联系邮箱:netdisk-union@baidu.
代码管理方法 我们目前版本控制工具已经从 SVN 切换到了 Git。Git 作为目前主流的代码版本管理工具,它的强大之处我就不在此赘述了,它的先进的分支操作等等,总之是谁用谁知道!下面我将从0开始对Git 的安装配置,以及代码库常用的操作命令进行总结。工欲善其事,必先利其器!这里我们先从Git 的安装配置说起。
在64位计算机上运行Visual Studio 2012应用程序时,会显示以下错误消息: 由于以下错误,检索CLSID为{F2D4F4E5-EEA1-46FF-A83B-A270C92DAE4B}的组件的COM类工厂失败:80040154类未注册(HRESULT的异常:0x80040154(REGDB_E_CLASSNOTREG)) 我正在visualstudio中使用Inventor packa
我有一个包含各种列的表“用户”。其中一列是用户名。我决定通过迁移删除该列。这样做之后,我试图通过注册表单(创建操作)创建一个新用户,但收到用户名的未定义方法错误,我不确定为什么。@user.save 上引发错误。 下面是相关的代码,首先是用户控制器的动作,然后是实际提交的表单。 有什么想法吗?堆栈跟踪,根据要求:
我想通过本教程将spring boot admin starter客户端注册到spring boot admin server:http://codecentric.github.io/spring-boot-admin/1.4.5/#register-客户端应用程序 但在运行之后,我发现了一个错误: 你知道怎么修吗??
环境 LDAP服务器:交钥匙OpenLDAP spring-ldap-core版本:2.3.3.发布 活动是什么 null 异常中找不到注释和数据等信息