[英]how to add Microsoft.WindowsAzure.Storage assembly in powershell script
Add-Type -Path c:\AzureStorageFile\Microsoft.WindowsAzure.Storage.dll
$AzStorObject = New-Object -TypeName Microsoft.WindowsAzure.Commands.Storage.AzureStorageContext
Gives me error给我错误
New-Object
: A constructor was not found.New-Object
:未找到构造函数。 Cannot find an appropriate constructor for typeMicrosoft.WindowsAzure.Commands.Storage.AzureStorageContext
.找不到类型Microsoft.WindowsAzure.Commands.Storage.AzureStorageContext
的合适构造函数。
You are not passing the -ArgumentList
parameter to New-Object
, so when attempting to instantiate the specified type it will look for a constructor that takes no parameters.您没有将-ArgumentList
参数传递给New-Object
,因此在尝试实例化指定类型时,它将寻找不带参数的构造函数。 The parameterless constructor of the AzureStorageContext
class is protected
, not public
, though... AzureStorageContext
class的无参数构造函数是protected
,不是public
,虽然......
protected AzureStorageContext ();
...so New-Object
will not be able to invoke it. ...所以New-Object
将无法调用它。
That same Microsoft.WindowsAzure.Storage.dll
assembly is used by theAzure.Storage
package . Azure.Storage
package使用相同的Microsoft.WindowsAzure.Storage.dll
程序集。 Upon installing that...在安装那个...
Install-Module -Name Azure.Storage
...you can invoke the New-AzureStorageContext
cmdlet to create AzureStorageContext
instances... ...您可以调用New-AzureStorageContext
cmdlet来创建AzureStorageContext
实例...
$AzStorObject = New-AzureStorageContext # Additional parameters needed
Otherwise, there is a public
constructor of the AzureStorageContext
class...否则,有AzureStorageContext
class 的public
构造函数...
public AzureStorageContext (Microsoft.WindowsAzure.Storage.CloudStorageAccount account);
...that you could use if you pass a CloudStorageAccount
instance... ...如果您传递CloudStorageAccount
实例,您可以使用它...
$AzStorObject = New-Object -TypeName Microsoft.WindowsAzure.Commands.Storage.AzureStorageContext -ArgumentList $myCloudStorageAccount
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.