parse-community / Parse-SDK-dotNET

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

Unity Exception with Version 2019.1.1f1 #314

Closed step4 closed 5 years ago

step4 commented 5 years ago

I am using the fork https://github.com/TobiasPott/Parse-SDK-dotNET/tree/feature/recode-unity-support

I build it with dotnet build Parse.sln and copy the content of Parse/bin/Debug/netstandard2.0/ into a folder in the Unity project assets.

When I try tu run

ParseClient.Initialize(new ParseClient.Configuration
{
      ApplicationID = "hochschulQuiz",
      Key = "123",
      ServerURI = "http://localhost:8080/api"
});

I get the error:

NullReferenceException: Object reference not set to an instance of an object
Parse.Internal.AppInformation..cctor () (at C:/projects/Parse-SDK-dotNET/Parse/Internal/Utilities/AppInformation.cs:27)
Rethrow as TypeInitializationException: The type initializer for 'Parse.Internal.AppInformation' threw an exception.
Parse.ParseClient.get_Version () (at C:/projects/Parse-SDK-dotNET/Parse/Public/ParseClient.cs:218)
Parse.ParseClient..cctor () (at C:/projects/Parse-SDK-dotNET/Parse/Public/ParseClient.cs:210)
Rethrow as TypeInitializationException: The type initializer for 'Parse.ParseClient' threw an exception.
Initialization.Start () (at Assets/Scripts/Initialization.cs:12)

On this issue TobiasPott mentioned he got it working on 2019.1.0.

Is there something I am missing?

TobiasPott commented 5 years ago

Ah yep, unfortunately I've never updated the Readme.md to be more concrete on how to build the unity support branch. I'll bring that one up to date as soon as I can.

The dotnet build Parse.sln guide is the one which applies for the master branch.

To get the assemblies for unity support you need to build either the Debug-Unity oder Debug-UnityEditor configuration or both. Which configuration you need to build depends on which context you want to use Parse in. If you need it to run from editor scripts there are minor differences which will be build with the Debug-UnityEditor configuration, if you need it solely in runtime (play-mode is considered runtime) Debug-Unity is the configuration you need to build. This results in slighly different build commands dotnet build Parse.sln -c Debug-Unity and dotnet build Parse.sln -c Debug-UnityEditor

This more obvious to notice when opening the solution within Visual Studio and I must admit I did not think about the command line build guide at this point.

step4 commented 5 years ago

Thanks, compilation worked and the previous error disappeared.

TobiasPott commented 5 years ago

You're welcome, I've changed the respective Readme.md to include a hint for that.

pnostudiodeveloper commented 4 years ago

I'm experiencing a similar error using the code in the above-mentioned fork.
NullReferenceException: Object reference not set to an instance of an object Parse.Internal.AppInformation.get_Build () (at /Users/pshannon/Downloads/Parse-SDK-dotNET-feature-recode-unity-support 3/Parse/Internal/Utilities/AppInformation.cs:31) Parse.ParseClient+Configuration+VersionInformation..cctor () (at /Users/pshannon/Downloads/Parse-SDK-dotNET-feature-recode-unity-support 3/Parse/Public/ParseClient.cs:136) Rethrow as TypeInitializationException: The type initializer for 'VersionInformation' threw an exception. Scene.Start () (at Assets/Scene.cs:27)

I've tried using a configuration to Initialize, that includes VersionInformation, but it doesn't affect the error. I'm using Unity 2019.3.0f6. Would very much appreciate any assistance.

(Also, I have tried building using all of the relevant targets in Visual Studio - Debug-Unity, Debug-UnityEditor)

TobiasPott commented 4 years ago

@pshannon1000 Could you please make a new issue for your case as it affects a different version of Unity and your stack trace does differ quite a bit. I'll then take a look at it as soon as I have some spare time.

pnostudiodeveloper commented 4 years ago

Thanks TobiasPott - I did end up being able to get my Parse / Heroku / Mailgun set-up working in Unity after about 3 days. I would post my solution here to help others, but at this point I honestly can hardly keep all the parse SDK versions and solutions I tried straight... it does work in the most recent version of Unity however, after hours and hours of trial and error.

pnostudiodeveloper commented 4 years ago

Ok, ended up having to get into this today again, because the Parse framework was getting an Access Denied error when I trying running my build on iOS...

After copying the DLL to the Parse SDK build folder, add a Reference to UnityEngine.dll in the Parse Visual Studio solution.