C# 使用Azure函数V1时,Azure存储文件共享dll在运行时导致runtime.compiler.unsafe错误
Azure.Storage.Files.Shares v12.0.0-12.5.0给出运行时错误 Microsoft.Azure.WebJobs.Host.FunctionInvocationException:执行函数时异常:Function2-->System.IO.FileNotFoundException:无法加载文件或程序集'System.Runtime.CompilerServices.Unsafe,版本=4.0.4.1 当我们通过Nuget在Azure Function V1中包含此功能时 有什么解决方法可以使用这个吗 我正在使用C# 使用Azure函数V1时,Azure存储文件共享dll在运行时导致runtime.compiler.unsafe错误,c#,azure-functions,azure-storage,azure-storage-files,.net-4.7.2,C#,Azure Functions,Azure Storage,Azure Storage Files,.net 4.7.2,Azure.Storage.Files.Shares v12.0.0-12.5.0给出运行时错误 Microsoft.Azure.WebJobs.Host.FunctionInvocationException:执行函数时异常:Function2-->System.IO.FileNotFoundException:无法加载文件或程序集'System.Runtime.CompilerServices.Unsafe,版本=4.0.4.1 当我们通过Nuget在Azure Function V1中包含
ShareFileClient file = directory.GetFileClient(filename);
ShareFileDownloadInfo download = file.Download();
下载时()出现此错误。Azure function v1似乎与包的最新版本冲突,请使用
Microsoft.WindowsAzure.Storage.File
您可以参考以下代码下载您的文件:
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(<storage-connect-string>);
CloudFileClient fileClient = storageAccount.CreateCloudFileClient();
CloudFileShare share = fileClient.GetShareReference(<share-name>);
if (share.Exists())
{
// Get a reference to the root directory for the share.
CloudFileDirectory rootDir = share.GetRootDirectoryReference();
// Get a reference to the directory we created previously.
CloudFileDirectory sampleDir = rootDir.GetDirectoryReference(<directory-name>);
// Ensure that the directory exists.
if (sampleDir.Exists())
{
// Get a reference to the file we created previously.
CloudFile file = sampleDir.GetFileReference("test.txt");
// Ensure that the file exists.
if (file.Exists())
{
log.Info(file.DownloadTextAsync().Result);
}
}
}
CloudStorageAccount-storageAccount=CloudStorageAccount.Parse();
CloudFileClient fileClient=storageAccount.CreateCloudFileClient();
CloudFileShare=fileClient.GetShareReference();
if(share.Exists())
{
//获取对共享的根目录的引用。
CloudFileDirectory rootDir=share.GetRootDirectoryReference();
//获取对我们先前创建的目录的引用。
CloudFileDirectory sampleDir=rootDir.GetDirectoryReference();
//确保该目录存在。
if(sampleDir.Exists())
{
//获取对我们先前创建的文件的引用。
CloudFile file=sampleDir.GetFileReference(“test.txt”);
//确保该文件存在。
if(file.Exists())
{
log.Info(file.DownloadTextAsync().Result);
}
}
}
是。。。谢谢,我已经用过了,+1表示正确答案