- Home /
Unity is not recognizing System.IO.Ports (I am not in .Net 2.0 subset)
Hello,
I have a project where I have this code:
using UnityEngine; using
System.Collections; using System.IO;
using System.IO.Ports;
...
That last line is giving problems in only one of my machines that shows this error message:
Assets/TouchMotion/Scripts/TouchMotionController.cs(5,17): error CS0234: The type or namespace name `Ports' does not exist in the namespace `System.IO'. Are you missing an assembly reference?
I've seen such message before when in Player Settings I have the Api Compatibility Level set to .NET 2.0 Subset instead of .NET 2.0. But in this case, I have already done that change and I continue seeing the message.
I'm compiling the project fine in another machine, so I know it's not a typo. Do you know what could be causing the problem?
Things I've tried:
Restarting Unity
Removing the Library, obj and ProjectSettings folders
Some final details in case they are useful:
I'm using Unity 5.3.2f1
The computer where it works is where I created the project. Then I copied it to the computer where it doesn't work.
What's your target platform? If it's web player (the default since 5.3 for some insane reason), you won't have access to a bunch of things - like IO.
You change the target platform in File->Build Settings. If your platform is missing, run the Unity Download Assistant again to grab it.
Answer by ismaelnascimento01 · May 27, 2018 at 09:45 PM
Change in Api Compatibility Level* to .Net 2.0
Answer by samra2494 · Jun 10, 2020 at 07:58 AM
Change in Api Compatibility Level* to .Net4.x This has worked for me.
Your answer
Follow this Question
Related Questions
System.IO.Ports with .Net Standard 2.0? 1 Answer
Screenshots Not Working Saving 1 Answer
How to edit a specific line or change a line in a stream asset 0 Answers
Use player imported songs? 1 Answer