Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Unanswered

Method not found: Azure.Response`1 Azure.Storage.Files.Shares.ShareDirectoryClient.Exists

(0) ShareShare
ReportReport
Posted on by
As the microsoft announcement of Migration from deprecated libraries – WindowsAzure.Storage and Microsoft.Azure.Storage to Azure.Storage.Blobs ,  I was instructed to migrate old Azure File Share logic to use the new library, BUT I encountered a weird runtime exception saying 'Method not found: 'Azure.Response`1<Boolean> Azure.Storage.Files.Shares.ShareDirectoryClient.Exists(System.Threading.CancellationToken)'

My X++ code below:
 
using Azure.Storage;
using Azure.Storage.Files.Shares;
using Azure.Storage.Files.Shares.Models;
using System.Collections;
using System.Threading;
class AzureFile
{
    ...
    public void existsFolder(Filename _FilePath)
    {
        ShareClient shareClient = new ShareClient(connectionString,fileShareReference);
        ShareDirectoryClient rootDir = shareClient.GetRootDirectoryClient();
        ShareDirectoryClient fileDir = rootDir.GetSubdirectoryClient(_FilePath);
        if (!fileDir.Exists(CancellationToken::None))
        {
            error(fileDir.Uri.ToString());
        }
    }
    ...
}

As I know in C#, it doesn't need to pass any parameter, but X++ says it doesn't support literal of CancellationToken, is this the problem?

By the way, the version of my dev environment is PU64(10.0.40), the corresponding Azure.Storage.Files.Shares.dll is 12.12.1.0, the corresponding Azure.core.dll 1.35.0

I also check the loaded assembly with reflection code below, it shows the method did exist.....

 
        assembly = Assembly::Load(assemblyName);
        var version = assembly.GetName().Version;
        Info("Azure.Storage.Files.Shares Version:" + version.ToString());
        System.Type type = assembly.GetType("Azure.Storage.Files.Shares.ShareDirectoryClient");
        System.Reflection.MethodInfo methodInfo = type.GetMethod("Exists");
        if (methodInfo != null)
        {
            info("Return type: " + methodInfo.ReturnType.ToString());
            ParameterInfo[] parameters = methodInfo.GetParameters();
            int i, paramCount;
            paramCount = parameters.Length;
            
            for (i = 1; i <= paramCount; i++)
            {
                ParameterInfo parameter = methodInfo.GetParameters().Get(i - 1);
                info(strFmt("Parameter %1: %2", i, parameter.ParameterType.ToString()));
            }
        }
        else
        {
            info("Method 'Exists' not found.");
        }

 
  • Jinhe Zhan Profile Picture
    Jinhe Zhan on at
    Method not found: Azure.Response`1 Azure.Storage.Files.Shares.ShareDirectoryClient.Exists
    hi @Martin Dráb

    I am using the dll under K:\AOSService as reference, I think it should be the assembly shipped by Microsoft with F&O?


     
    Below are the loaded assembly info captured during exception

     
    The version are the same I think?
  • Martin Dráb Profile Picture
    Martin Dráb 230,596 Most Valuable Professional on at
    Method not found: Azure.Response`1 Azure.Storage.Files.Shares.ShareDirectoryClient.Exists
    If it compiles but fails at runtime, it suggests that the version used for compilation is different from the one used at runtime. Are you using the assembly shipped by Microsoft with F&O?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Congratulations 2024 Spotlight Stars!

Kudos to all of our 2024 community stars!

Meet the Top 10 leaders for December!

Congratulations to our December super stars!

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,576 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,596 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans