C# script file name, Class name issue

“Script file name does not match the name of the class defined in script”

In the first time, I successfully dragged the C# script to my object, but “C# Help, Script file name does not match the name of the class defined in script” appeared in the debug box while running.Then when I tried dragging again, the error box popped.
My class name and the script name are identical.BTW I’m using c# to try SerialPorts
Here is the code:

using UnityEngine;
using System.Collections;
using System;
using System.IO;
using System.IO.Ports;

namespace System.IO.Ports

{

public class mySerial : MonoBehaviour {

SerialPort sp;

// Use this for initialization

void Start () {

sp = new SerialPort ();

}

// Update is called once per frame

void Update () {

print(sp.PortName);

}

}

}

Lose the namespace. Unity cares not for such things.

See http://docs.unity3d.com/Documentation/ScriptReference/index.Writing_Scripts_in_Csharp_26_Boo.html , Section 5.

I tried again by removing the namespace, and it works well . It didn’t work last time I tried this and I don’t know why.
Anyway thank you a lot!

Hey

Just make sure that the script name dose not have any spaces in it!