473,473 Members | 1,974 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

'OptionalField' could not be found

Hello,

This is the first time I try to use [OptionalField] thingy. I think I
use it in a proper way. But, I have following code:
using System;
using System.Collections;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters;
using System.Runtime.Serialization.Formatters.Binary;

namespace LanguageSystem {
[...]
[Serializable]
public class LangLanguage {
public enum Orient {LeftToRight, RightToLeft};

public string Name;
public ArrayList alphabet;
public Orient orientation;
[OptionalField]
public int wordNumber;

And it produces following error:

C:\[...]\LangLanguage.cs(19): The type or namespace name
'OptionalField' could not be found (are you missing a using directive or
an assembly reference?)

What could possibly be the problem?

--
"Now the storm has passed over me
I'm left to drift on a dead calm sea
And watch her forever through the cracks in the beams
Nailed across the doorways of the bedrooms of my dreams"
Dec 23 '06 #1
5 3227
Hi,

OptionalFieldAttribute is under the System.Runtime.Serialization namespace.
It's defined in the mscorlib assembly just like SerializableAttribute, which
you are using as well. The code you have posted looks fine to me, but the
error is definitely indicating that you're missing the using directive or a
reference to mscorlib, which is doubtful. If you remove [OptionalField]
from your code does it compile?

If you're using VS 2005 you should notice that the color of OptionalField
changes to teal (if you haven't defined a different color) to indicate that
it's a type. If the color doesn't change then you haven't add the using
System.Runtime.Serialization directive as in your example or you actually
are missing a reference to mscorlib.

--
Dave Sexton

"Nikola Skoric" <ni*******@net4u.hrwrote in message
news:MP************************@news.t-com.hr...
Hello,

This is the first time I try to use [OptionalField] thingy. I think I
use it in a proper way. But, I have following code:
using System;
using System.Collections;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters;
using System.Runtime.Serialization.Formatters.Binary;

namespace LanguageSystem {
[...]
[Serializable]
public class LangLanguage {
public enum Orient {LeftToRight, RightToLeft};

public string Name;
public ArrayList alphabet;
public Orient orientation;
[OptionalField]
public int wordNumber;

And it produces following error:

C:\[...]\LangLanguage.cs(19): The type or namespace name
'OptionalField' could not be found (are you missing a using directive or
an assembly reference?)

What could possibly be the problem?

--
"Now the storm has passed over me
I'm left to drift on a dead calm sea
And watch her forever through the cracks in the beams
Nailed across the doorways of the bedrooms of my dreams"

Dec 23 '06 #2
In article <eF**************@TK2MSFTNGP06.phx.gbl>, dave@jwa
[remove.this]online.com says...
Hi,

OptionalFieldAttribute is under the System.Runtime.Serialization namespace.
It's defined in the mscorlib assembly just like SerializableAttribute, which
you are using as well. The code you have posted looks fine to me, but the
error is definitely indicating that you're missing the using directive or a
reference to mscorlib, which is doubtful. If you remove [OptionalField]
from your code does it compile?
Yes, it does.
If you're using VS 2005 you should notice that the color of OptionalField
changes to teal (if you haven't defined a different color) to indicate that
it's a type. If the color doesn't change then you haven't add the using
System.Runtime.Serialization directive as in your example or you actually
are missing a reference to mscorlib.
I have VS 2002m, therefore no teal :-) But, as you see, I did use
System.Runtime.Serialization and I can compile the code with
[Serializable], but can't with [OptionalField]. [OptionalField] is the
problem here. Could it be something with [OptionalField] being added to
standard later, so my version of framework and/or compiler doesn't
recognise it?

--
"Now the storm has passed over me
I'm left to drift on a dead calm sea
And watch her forever through the cracks in the beams
Nailed across the doorways of the bedrooms of my dreams"
Dec 23 '06 #3
Hi Nikola,
Could it be something with [OptionalField] being added to
standard later, so my version of framework and/or compiler doesn't
recognise it?
Yes! (Sorry I didn't think of that :)

OptionalFieldAttribute was added to the 2.0 framework.

--
Dave Sexton
http://davesexton.com/blog

"Nikola Skoric" <ni*******@net4u.hrwrote in message
news:MP************************@news.t-com.hr...
In article <eF**************@TK2MSFTNGP06.phx.gbl>, dave@jwa
[remove.this]online.com says...
>Hi,

OptionalFieldAttribute is under the System.Runtime.Serialization
namespace.
It's defined in the mscorlib assembly just like SerializableAttribute,
which
you are using as well. The code you have posted looks fine to me, but
the
error is definitely indicating that you're missing the using directive or
a
reference to mscorlib, which is doubtful. If you remove [OptionalField]
from your code does it compile?

Yes, it does.
>If you're using VS 2005 you should notice that the color of OptionalField
changes to teal (if you haven't defined a different color) to indicate
that
it's a type. If the color doesn't change then you haven't add the using
System.Runtime.Serialization directive as in your example or you actually
are missing a reference to mscorlib.

I have VS 2002m, therefore no teal :-) But, as you see, I did use
System.Runtime.Serialization and I can compile the code with
[Serializable], but can't with [OptionalField]. [OptionalField] is the
problem here. Could it be something with [OptionalField] being added to
standard later, so my version of framework and/or compiler doesn't
recognise it?

--
"Now the storm has passed over me
I'm left to drift on a dead calm sea
And watch her forever through the cracks in the beams
Nailed across the doorways of the bedrooms of my dreams"

Dec 23 '06 #4
In article <OY**************@TK2MSFTNGP04.phx.gbl>, dave@jwa
[remove.this]online.com says...
Hi Nikola,
Could it be something with [OptionalField] being added to
standard later, so my version of framework and/or compiler doesn't
recognise it?

Yes! (Sorry I didn't think of that :)

OptionalFieldAttribute was added to the 2.0 framework.
Can I then just install 2.0 framework and everything's fine or do I have
to upgrade the VS too?

--
"Now the storm has passed over me
I'm left to drift on a dead calm sea
And watch her forever through the cracks in the beams
Nailed across the doorways of the bedrooms of my dreams"
Dec 23 '06 #5
Hi Nikola,

Well you could download Visual C# 2005 Express Edition:

http://msdn.microsoft.com/vstudio/ex...p/default.aspx

It's not as fully featured as VS Pro, for example, but it's free :)

--
Dave Sexton
http://davesexton.com/blog

"Nikola Skoric" <ni*******@net4u.hrwrote in message
news:MP************************@news.t-com.hr...
In article <OY**************@TK2MSFTNGP04.phx.gbl>, dave@jwa
[remove.this]online.com says...
>Hi Nikola,
Could it be something with [OptionalField] being added to
standard later, so my version of framework and/or compiler doesn't
recognise it?

Yes! (Sorry I didn't think of that :)

OptionalFieldAttribute was added to the 2.0 framework.

Can I then just install 2.0 framework and everything's fine or do I have
to upgrade the VS too?

--
"Now the storm has passed over me
I'm left to drift on a dead calm sea
And watch her forever through the cracks in the beams
Nailed across the doorways of the bedrooms of my dreams"

Dec 23 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Rutger Claes | last post by:
Code and problem are from PHP5: When I execute the following piece of code, the DomException is thrown with a message: Not Found Exception. I assume this means that the node I extracted from the...
4
by: amywolfie | last post by:
I would like to put code behind a Find button on a form which: 1) Performs a find based on a field on the form 2) If NO RECORDS ARE FOUND, then displays a custom "No Records Found" message box. ...
2
by: Kevin R. | last post by:
I have been ignoring this problem for a few weeks now, but it's becoming a bit annoying not to mention unproductive. Here it goes: I compile my project with no errors. Then after I debug/run it,...
14
by: NormD | last post by:
We have a client-server app using Web Services on an IIS machine. The trace below shows that .NET is searching around for some things (e.g., SystemDrawing.DLL and System.Drawing.EXE) and taking a...
4
by: rich.quackenbush | last post by:
I was very excited when version 2.0 of the framework came out... it looked as though the OptionalField atribute would help me sort out my serialization woes. So far, it hasn't through. All I'm...
0
by: cwho.work | last post by:
Hi! We are using apache ibatis with our MySQL 5.0 database (using innodb tables), in our web application running on Tomcat 5. Recently we started getting a number of errors relating to...
5
by: Amit_Basnak | last post by:
Dear Friends I have been getting the following error Error 185: "WorkFlow_dce.cpp", line 58 # Left side of '->' requires a pointer to class; type found was 'struct WF_SEARCH_WU'....
1
Dököll
by: Dököll | last post by:
Greetings, Good buddies! I am for the first time, since I started learning VB, going to build an application I wanted to build for my first son, a language and activities program that will allow...
1
by: sora | last post by:
Hi, I've developed a MFC program under VS 6.0. My debugger *was* working fine and I've used it often for my project. Then, one day, the errors below appear and they prevent me from using the...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.