ArgumentNullException: Value cannot be null

Discussion of problems, ideas, suggestions and more.
Post Reply
SlickStudios
Posts: 3
Joined: Sun Apr 12, 2020 9:45 pm

ArgumentNullException: Value cannot be null

Post by SlickStudios »

Hi i am having an issue playing audio back from my server. It used to work previously but returning to my project some months later I am receiving the following error:

ArgumentNullException: Value cannot be null.
Parameter name: _unity_self

code below, Any help much appreciated.

Error highlighted in the code near the bottom.

Code: Select all

public class PlayThoughts : MonoBehaviour {

	public AudioSource audioSource;
	//public ThoughtsManager th;
	public string thoughtsTag;
	public List<string> tempList = new List<string> ();

	//Play thought from database here
	public void PlaySavedThought(){
		audioSource.Stop ();
		tempList.Clear ();
		thoughtsTag =("");
		StartCoroutine(DownloadAudio());
	}
	
	public IEnumerator DownloadAudio()
	{
		// Create a URL and add parameters to the end of it.
		string myURL = "HIDDEN";
		myURL += "HIDDEN";
		// Create our ES2Web object.
		ES2Web web = new ES2Web(myURL);

		// Start downloading our data and wait for it to finish.
		yield return StartCoroutine(web.Download());

		foreach (string tags in web.GetTags()) {

			tempList.Add (tags);
        }
		if(web.isError)
		{
			// Enter your own code to handle errors here.
			Debug.LogError(web.errorCode + ":" + web.error);
		}
		else
		{
			// We could save our data to a local file and load from that.
			//web.SaveToFile("thoughts_tags.txt");
			// Or we could just load directly from the ES2Web object.
			thoughtsTag = tempList [Random.Range(0, tempList.Count)];

           ERROR COMING FROM THIS LINE >>>> audioSource.clip = web.Load<AudioClip>(thoughtsTag);

			audioSource.PlayOneShot (audioSource.clip, 0.7f);
		}
	}
}

User avatar
Joel
Moodkie Staff
Posts: 2827
Joined: Wed Nov 07, 2012 10:32 pm

Re: ArgumentNullException: Value cannot be null

Post by Joel »

Hi there,

I moved this to the Easy Save 2 forum as this seems to be what you're using.

Firstly, I would recommend updating Easy Save 2 if you haven't already done so. You can do this by downloading from the Asset Store, then double-click the update package in Assets/Plugins/Easy Save 3/Legacy/Easy Save 2.unitypackage.

If this doesn't resolve the issue, please could you send the complete error message including line numbers?

All the best,
Joel
Joel @ Moodkie Interactive
Twitter - Unity

SlickStudios
Posts: 3
Joined: Sun Apr 12, 2020 9:45 pm

Re: ArgumentNullException: Value cannot be null

Post by SlickStudios »

Thanks for your help, I followed your instructions but still seem to be getting the same issue.

Error codes below:
ArgumentNullException: Value cannot be null.
Parameter name: _unity_self
ES2Web.CheckWWWUsage () (at Assets/Plugins/Easy Save 2/Scripts/ES2Web.cs:556)
ES2Web.Load[T] (System.String tag) (at Assets/Plugins/Easy Save 2/Scripts/ES2Web.cs:336)
PlayThoughts+<DownloadAudio>d__4.MoveNext () (at Assets/Scripts/PlayThoughts.cs:46)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <f38c71c86aa64e299d4cea9fb7c715e1>:0)


Thanks again

User avatar
Joel
Moodkie Staff
Posts: 2827
Joined: Wed Nov 07, 2012 10:32 pm

Re: ArgumentNullException: Value cannot be null

Post by Joel »

I still don't seem to be able to replicate this. Would you be able to private message me a project?

All the best,
Joel
Joel @ Moodkie Interactive
Twitter - Unity

SlickStudios
Posts: 3
Joined: Sun Apr 12, 2020 9:45 pm

Re: ArgumentNullException: Value cannot be null

Post by SlickStudios »

sent you the project via pm

dandolby
Posts: 4
Joined: Fri May 08, 2020 8:42 am

Re: ArgumentNullException: Value cannot be null

Post by dandolby »

Hi,

I am getting the same error, I can upload and have checked on my server and the files are there but when I try to download I get this error below.
I am using the latest download from unity asset store and the latest playmaker (Unity2018.3.Playmaker.1.9.0.p20.unitypackage) unity 2019.3.9f1

ArgumentNullException: Value cannot be null.
Parameter name: _unity_self
UnityEngine.Networking.UnityWebRequest.get_downloadProgress () (at <b2574b1886b64e74964732bc4cada36b>:0)
ES2Web.get_progress () (at Assets/Plugins/Easy Save 2/Scripts/ES2Web.cs:58)
HutongGames.PlayMaker.Actions.ES2DownloadAction.OnUpdate () (at Assets/Plugins/Easy Save 2/Playmaker/ES2PlayMaker.cs:384)
HutongGames.PlayMaker.FsmState.OnUpdate () (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/FsmState.cs:265)
HutongGames.PlayMaker.Fsm.UpdateState (HutongGames.PlayMaker.FsmState state) (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2786)
HutongGames.PlayMaker.Fsm.Update () (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:1995)
PlayMakerFSM.Update () (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/PlayMakerFSM.cs:594)

User avatar
Joel
Moodkie Staff
Posts: 2827
Joined: Wed Nov 07, 2012 10:32 pm

Re: ArgumentNullException: Value cannot be null

Post by Joel »

Hi there,

Assuming the cause is the same as the previous poster, if you send me a PM with your invoice number, I can send you an update to resolve this.

All the best,
Joel
Joel @ Moodkie Interactive
Twitter - Unity

Kirrua
Posts: 6
Joined: Sat May 25, 2019 4:59 am

Re: ArgumentNullException: Value cannot be null

Post by Kirrua »

I am still getting this error even after updating.

What can I do to fix it?


EDIT: I did some investigations and the error seems to be related to the fact that you can't have `obj` being null when the lock is acquired and it tries to add the object to the dictionary.

```
I simply changed the relevant part of the `Add` function to:

lock (_lock)
{
if (obj != null)
{
idRef[id] = obj;
refId[obj] = id;
}
else
{
return -1;
}
}
```

User avatar
Joel
Moodkie Staff
Posts: 2827
Joined: Wed Nov 07, 2012 10:32 pm

Re: ArgumentNullException: Value cannot be null

Post by Joel »

Hi there,

This thread is about an entirely different issue in Easy Save 2. However, if you want me to look into your issue further then if you could private message me a script or basic project with instructions to replicate it then I'm happy to take a look.

All the best,
Joel
Joel @ Moodkie Interactive
Twitter - Unity

Post Reply