aws-sdk-net: [UNITY][ISSUE]Conflict between native System.IO.InvalidDataException & yours

In Unity when we import your package everything is fine but as soon as another script try to access to “System.IO.InvalidDataException” it will create a conflict and the compiler can’t resolve. We are using :

  • Windows 10
  • Unity 2018.3
  • aws-sdk-unity_3.3.421.0 (AWSSDK 3.3.31.0)
  • .NET 4.6 OR .netstandard 2.0
  • VS Community 2017 AND CURRENTLY it’s impossible to compile in Unity.

This is the incriminated script :

/*
 * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License").
 * You may not use this file except in compliance with the License.
 * A copy of the License is located at
 * 
 *  http://aws.amazon.com/apache2.0
 * 
 * or in the "license" file accompanying this file. This file is distributed
 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
 * express or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */

using System;
using System.Runtime.Serialization;

namespace System.IO {
    [Serializable()] 
	public sealed class InvalidDataException  : SystemException
    {
        public InvalidDataException ()
            : base() {
        }
 
        public InvalidDataException (String message)
            : base(message) {
        }
 
        public InvalidDataException (String message, Exception innerException)
            : base(message, innerException) {
        }
  
        internal InvalidDataException (SerializationInfo info, StreamingContext context) : base(info, context) {
        }
 
    }
}

if you called just this script in Unity project, you will generate the issue :

using UnityEngine;

public class Test : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
		throw new System.IO.InvalidDataException();
    }
}

Why are you keeping this, whereas it’s implemented in System.IO C# library ?

You can just removed it no or use at least a custom namespace if you want to have your own InvalidDataException ? But when I see your implementation it seems to be just a complete empty nutshell that could just create issue.

Thanks.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 3
  • Comments: 16 (1 by maintainers)

Most upvoted comments

Any news ?

Hi, I hope I am not too late here. The solution is simple, although not trivial. I’ll write the steps and below an explanation.

  1. Download the package through NuGet (website/rider/visual studio)
  2. If it’s in nupkg format, edit the name and change the extention from .nupckg to .zip, if not, skip to 4.
  3. Extract the files via ZIP, go to the relevant folder (usually 2.0)
  4. Copy the DLL file
  5. Open your unity project on Assets folder, if it contains Plugins folder, open it. If not, create one and open it.
  6. Copy the DLL to the Plugins folder
  7. Test!

Explanation: This will work for any NuGet package, not just AWS. AWS used to have an SDK for Unity, which included missing file definitions. That SDK has been abandoned, and since Unity added the missing files and classes, there is a duplication which is hard to solve. More over, the SDK is not updating so it would be better to download the AWS SDK for .NET which includes all the functionality needed for Unity. In order for Unity to include the package, it’s not enough to import it through the IDE, you need it in your plugins folder so it will be included in the prioject AND in the build. Good luck!