Unity is not recognizing System.IO.Ports (I am not in .Net 2.0 subset)


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.

Here is solution:


Change in Api Compatibility Level* to .Net 2.0

Change in Api Compatibility Level* to .Net4.x
This has worked for me.