如题,我将2.3的DLL放在Unity(4.6和5.4)中测试使用,和demo中使用同样的代码和高权限用户参数(这里我保证参数正确),当调用到GetObject会出现错误;在demo中运行正常。。
public static void GetObject()
{
try
{
//client.PutObject(bucketName, key, fileToUpload);
var client = new OssClient("http://oss-cn-shanghai.aliyuncs.com", "参数", "参数");
var result = client.GetObject("参数", "参数"); //在这里出错
using (var requestStream = result.Content)
{
using (var fs = File.Open("C:/Users/Administrator/Desktop" + "/DataGetTemplateR.json", FileMode.OpenOrCreate))
{
int length = 4 * 1024;
var buf = new byte[length];
do
{
length = requestStream.Read(buf, 0, length);
fs.Write(buf, 0, length);
} while (length != 0);
}
}
}
catch (OssException ex)
{
Debug.Log("Failed with error code: " + ex.ErrorCode + "; Error info: " + ex.Message + "\nRequestID:" + ex.RequestId + "\tHostID:{3}" +ex.HostId);
}
}
错误信息如下:
NullReferenceException: Object reference not set to an instance of an object
Aliyun.OSS.Common.Communication.HttpExtensions.AddInternal (System.Net.WebHeaderCollection headers, System.String key, System.String value)
Aliyun.OSS.Common.Communication.HttpFactory.SetRequestHeaders (System.Net.HttpWebRequest webRequest, Aliyun.OSS.Common.Communication.ServiceRequest serviceRequest, Aliyun.OSS.Common.ClientConfiguration configuration)
Aliyun.OSS.Common.Communication.HttpFactory.CreateWebRequest (Aliyun.OSS.Common.Communication.ServiceRequest serviceRequest, Aliyun.OSS.Common.ClientConfiguration configuration)
Aliyun.OSS.Common.Communication.ServiceClientImpl.SendCore (Aliyun.OSS.Common.Communication.ServiceRequest serviceRequest, Aliyun.OSS.Common.Communication.ExecutionContext context)
Aliyun.OSS.Common.Communication.ServiceClient.Send (Aliyun.OSS.Common.Communication.ServiceRequest request, Aliyun.OSS.Common.Communication.ExecutionContext context)
Aliyun.OSS.Common.Communication.RetryableServiceClient.SendImpl (Aliyun.OSS.Common.Communication.ServiceRequest request, Aliyun.OSS.Common.Communication.ExecutionContext context, Int32 retryTimes)
-------------------------
-------------------------
-------------------------
-------------------------
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。