none
error CS0246: The type or namespace name 'Serializable' could not be found (are you missing a using directive or an assembly reference?)

    Question

  • Hi first let me say the code pasted below compiles on a computer I have with the non team suite addition of Visual Studio 2005.  I have put visual studio 2005 team suite on two other computers and I get the following error. 
    error CS0246: The type or namespace name 'Serializable' could not be found (are you missing a using directive or an assembly reference?)

    It's been so long since I got the project working on the first computer.  I can barely remember if there was somethng I had to do special to make this work such as a service pack or something. 

    The line that generates the error is
    [Serializable] 

    In fact it is not turning color in the project environment like any symbol would if it was not defined. In the first project that works on the first computer it appears to be defined in the System namespace. On the other 2 computers with the team suit visual studio 2005 it does not appear to be defined in the system namespace.  Can some advise?

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Xml.Serialization;
    using System.IO;
    namespace MotionLibErrorControl
    {

    public class Error

    {

    [Serializable]

     

    public enum ErrorCodes{

     

    //TANG_KNIFE_SEEK_FAILED = 61,

    TOOL_TOO_LONG = 104,

    TOOL_TOO_SHORT = 105,

    Z_OUT_OF_RANGE = 300,

    FUNCTION6_TOO_LARGE = 330,

    JOB_TOO_LARGE = 331,

    UNKNOWN_TOOL = 401,

    NO_TOOL = 402,

    NO_TOOL_HEIGHT = 403,

    INVALID_ARGUMENT = 404,

    INVALID_TOOL = 405,

    Z_LOST_POSITION = 601,

    X_LOST_POSITION = 602,

    Y_LOST_POSITION = 603,

    TANG_LOST_POSITION = 604,

    MODBUS_TOOLCHANGE_FAILED = 700,

    MODBUS_SPINDLE_FAILED = 701,

    MODBUS_TOOLCHANGE_INDEX_ERROR = 702,

    MODBUS_TOOLCHANGE_CYLINDER_ERROR = 703,

    MODBUS_TOOLCHANGE_CLAMP_ERROR = 704,

    MODBUS_TOOLCHANGE_TOOL_ERROR = 705,

    MODBUS_TOOLCHANGE_LOW_PRESSURE = 706,

    MODBUS_TOOLCHANGE_RESET = 801,

    MACHINE_BOOT_INFORMATION=802,

    }


    }

     

     


    Don
    • Edited by DonJuna Thursday, October 08, 2009 1:44 PM formatting
    Thursday, October 08, 2009 1:37 PM

Answers

  • Serializable as defined here: http://msdn.microsoft.com/en-us/library/system.serializableattribute.aspx  is in the System namespace of mscorlib.

    In the example code you provided you're missing a closing } for the namespace.  Adding that in allows the code to compile.  If it doesn't compile for you then your project or your installation is bad.  Try creating a new console app and pasting the code into it. If it works then it is your project if it doesn't then it is your installation.

    Michael Taylor - 10/8/09
    http://p3net.mvps.org

    • Proposed as answer by Geert van Horrik Friday, October 09, 2009 5:38 AM
    • Marked as answer by Roahn Luo Monday, October 12, 2009 10:00 AM
    Thursday, October 08, 2009 1:58 PM
    Moderator