parse-community / Parse-SDK-dotNET

Parse SDK for .NET, Xamarin, Unity.
http://parseplatform.org
Apache License 2.0
322 stars 260 forks source link

The name 'ParseCloud' does not exist in the current context #361

Closed hhgz9527 closed 2 years ago

hhgz9527 commented 2 years ago

SDK Version: 2.0.0 Parse Server version: 4.5.0 Local or remote host: Local

Use in Unity.

I can use await client.SignUpAsync(username: "Test", password: "Test"); to sign up success in parse,

but i use cloud code, always show me this error: The name 'ParseCloud' does not exist in the current context

I searched every possible keyword, but no solution was found.

Could you please tell me how to solve this problem, Thanks!


        void Start()
    {
        new ParseClient("x", "http://localhost:1337/api", "x"
        ,
        new LateInitializedMutableServiceHub { },
        new MetadataMutator
        {
            EnvironmentData = new EnvironmentData { OSVersion = SystemInfo.operatingSystem, Platform = $"Unity {Application.unityVersion} on {SystemInfo.operatingSystemFamily}", TimeZone = TimeZoneInfo.Local.StandardName },
            HostManifestData = new HostManifestData { Name = Application.productName, Identifier = Application.productName, ShortVersion = Application.version, Version = Application.version }
        }
        ).Publicize();
    }

    public async void fetchGuideInfoAction()
    {
        IDictionary<string, object> dictionary = new Dictionary<string, object>
        {
            { "name", "test" }
        };

        ParseCloud.CallFunctionAsync<float>("fetchGuideInfo", dictionary).ContinueWith(t =>
        {
            var result = t.Result;
            Debug.Log(result);
        });
    }
hhgz9527 commented 2 years ago

And I used

                if (ParseUser.CurrentUser != null)
        {
                    loginPanel.SetActive(false);
        }

show CS0117: 'ParseUser' does not contain a definition for 'CurrentUser' error

chamboryk commented 2 years ago

May be you lose "using" command.

using Parse; using Parse.Infrastructure; using Parse.Platform.Objects;

    _parseClient = new ParseClient("myAppId", "http://localhost:1337/parse/", "",
        new LateInitializedMutableServiceHub { },
        new MetadataMutator
        {
            EnvironmentData = new EnvironmentData { OSVersion = SystemInfo.operatingSystem, Platform = $"Unity {Application.unityVersion} on {SystemInfo.operatingSystemFamily}", TimeZone = TimeZoneInfo.Local.StandardName },
            HostManifestData = new HostManifestData { Name = Application.productName, Identifier = Application.productName, ShortVersion = Application.version, Version = Application.version }
        },
        new AbsoluteCacheLocationMutator
        {
            CustomAbsoluteCacheFilePath = $"{Application.persistentDataPath.Replace('/', Path.DirectorySeparatorChar)}{Path.DirectorySeparatorChar}Parse.cache"
        }
    );