Serializable could not be found name could not be found problem

  • Thread starter Thread starter Jared Parsons [MSFT]
  • Start date Start date
J

Jared Parsons [MSFT]

Try adding "using System;" to you other using entries.

--
Jared Parson [MSFT]
(e-mail address removed)

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
 
The Serializable attribute cannot be applied to a struct since all value
types (including structs) are automatically serializable.

Ken
 
The Serializable attribute cannot be applied to a struct since all value
types (including structs) are automatically serializable.

Ken

How about:

public struct ABC {
public Hashtable myHashtable;
}

There's a perfectly valid struct. How's it going to serialise tha Hashtable?
And you can apply the attribute to it.

Simon Smith
simon dot s at ghytred dot com
www.ghytred.com/NewsLook - NNTP Client for Outlook

Ben Terry said:
I get the following compilation error:
"The type or namespace name 'Serializable' could not be found (are you
missing a using directive or an assembly reference?)"

Can anyone tell me why the following code will not compile? I thought the
"Serializable" attribute was located in the System.Runtime.Serialization
assembly. I'm trying to stream this structure to/from a byte array.

using System.Runtime.InteropServices;
using System.Runtime.Serialization;

namespace PetToolTCPLib
{
[Serializable]
public struct MIX_CompleteIllumStateMsg
{
public MIX_MISC_ENUMS som; // start of message sentinel always set
to 0xC0DEF00D
public uint length; // total message length in bytes
public MIX_MessageId msgId; // message id
public MESSAGE_LOG_HEADER_STRUCT theHeader;
public MESSAGE_LOG_RUN_PERIODIC_STRUCT theRealTimeInfo;
}
}
 
I get the following compilation error:
"The type or namespace name 'Serializable' could not be found (are you
missing a using directive or an assembly reference?)"

Can anyone tell me why the following code will not compile? I thought the
"Serializable" attribute was located in the System.Runtime.Serialization
assembly. I'm trying to stream this structure to/from a byte array.

using System.Runtime.InteropServices;
using System.Runtime.Serialization;

namespace PetToolTCPLib
{
[Serializable]
public struct MIX_CompleteIllumStateMsg
{
public MIX_MISC_ENUMS som; // start of message sentinel always set
to 0xC0DEF00D
public uint length; // total message length in bytes
public MIX_MessageId msgId; // message id
public MESSAGE_LOG_HEADER_STRUCT theHeader;
public MESSAGE_LOG_RUN_PERIODIC_STRUCT theRealTimeInfo;
}
}
 
You're right -- my bad. Thanks for the correction.

Ken


Simon Smith said:
The Serializable attribute cannot be applied to a struct since all value
types (including structs) are automatically serializable.

Ken

How about:

public struct ABC {
public Hashtable myHashtable;
}

There's a perfectly valid struct. How's it going to serialise tha Hashtable?
And you can apply the attribute to it.

Simon Smith
simon dot s at ghytred dot com
www.ghytred.com/NewsLook - NNTP Client for Outlook

Ben Terry said:
I get the following compilation error:
"The type or namespace name 'Serializable' could not be found (are you
missing a using directive or an assembly reference?)"

Can anyone tell me why the following code will not compile? I thought the
"Serializable" attribute was located in the System.Runtime.Serialization
assembly. I'm trying to stream this structure to/from a byte array.

using System.Runtime.InteropServices;
using System.Runtime.Serialization;

namespace PetToolTCPLib
{
[Serializable]
public struct MIX_CompleteIllumStateMsg
{
public MIX_MISC_ENUMS som; // start of message sentinel always set
to 0xC0DEF00D
public uint length; // total message length in bytes
public MIX_MessageId msgId; // message id
public MESSAGE_LOG_HEADER_STRUCT theHeader;
public MESSAGE_LOG_RUN_PERIODIC_STRUCT theRealTimeInfo;
}
}
 
Thanks, Jared. That adding "using System;" did the trick.

Jared Parsons said:
Try adding "using System;" to you other using entries.

--
Jared Parson [MSFT]
(e-mail address removed)

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

Ben Terry said:
I get the following compilation error:
"The type or namespace name 'Serializable' could not be found (are you
missing a using directive or an assembly reference?)"

Can anyone tell me why the following code will not compile? I thought the
"Serializable" attribute was located in the System.Runtime.Serialization
assembly. I'm trying to stream this structure to/from a byte array.

using System.Runtime.InteropServices;
using System.Runtime.Serialization;

namespace PetToolTCPLib
{
[Serializable]
public struct MIX_CompleteIllumStateMsg
{
public MIX_MISC_ENUMS som; // start of message sentinel always set
to 0xC0DEF00D
public uint length; // total message length in bytes
public MIX_MessageId msgId; // message id
public MESSAGE_LOG_HEADER_STRUCT theHeader;
public MESSAGE_LOG_RUN_PERIODIC_STRUCT theRealTimeInfo;
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top