Open spiderpoison opened 3 years ago
Hi, I had the same issue, and problem might be solved by updating .net version you are using to one of the .Net Framework 4.x versions.
So either you should:
Hope this will help someone else.
2024年了,3年过去了,这个问题依然没有修复…… 看来是真不管issue啊?
如果你是windows系统:
看下构建的是 net framwork
还是 .net or netcore
运行时,
1)如果是 net framework,需要依赖 https://www.nuget.org/packages/Aliyun.OSS.SDK
2)如果是.net 或者 net core 的,需要依赖 https://www.nuget.org/packages/Aliyun.OSS.SDK.NetCore
另外,github上有相应的示例工程,用户可以参考。https://github.com/aliyun/aliyun-oss-csharp-sdk/tree/master/samples
简单的示例程序:
var client = new OssClient("http://oss-cn-hangzhou.aliyuncs.com", "xx","xxx"); client.GetObject("xxx", "xxx");
csproj文件如下: `
`
在mac可以顺利运行,但在windows报错:
Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object. at Aliyun.OSS.Common.Communication.HttpExtensions.AddInternal(WebHeaderCollection headers, String key, String value) at Aliyun.OSS.Common.Communication.HttpFactory.SetRequestHeaders(HttpWebRequest webRequest, ServiceRequest serviceRequest, ClientConfiguration configurati on) at Aliyun.OSS.Common.Communication.HttpFactory.CreateWebRequest(ServiceRequest serviceRequest, ClientConfiguration configuration) at Aliyun.OSS.Common.Communication.ServiceClientImpl.SendCore(ServiceRequest serviceRequest, ExecutionContext context) at Aliyun.OSS.Common.Communication.ServiceClient.Send(ServiceRequest request, ExecutionContext context) at Aliyun.OSS.Common.Communication.RetryableServiceClient.SendImpl(ServiceRequest request, ExecutionContext context, Int32 retryTimes) at Aliyun.OSS.Common.Communication.RetryableServiceClient.Send(ServiceRequest request, ExecutionContext context) at Aliyun.OSS.Commands.OssCommand.Execute() at Aliyun.OSS.Commands.OssCommand
1.Execute() at Aliyun.OSS.OssClient.GetObject(GetObjectRequest getObjectRequest) at Aliyun.OSS.OssClient.GetObject(String bucketName, String key) at ossdemo.Program.Main(String[] args) in F:\Temp\ossdemo\ossdemo\Program.cs:line 12 `