Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Computer Certification > MCAD > c#

Reply
 
 
Guest
Posts: n/a
 
      02-07-2004
please tell me how to add a class to a project.thanx in
advance.
 
Reply With Quote
 
 
 
 
Ken Onweller \(.NET MCSD\)
Guest
Posts: n/a
 
      02-08-2004
right click on the project name in the solution explorer and select Add and
then select Add Class.


<(E-Mail Removed)> wrote in message
news:c67901c3ed85$f6489110$(E-Mail Removed)...
> please tell me how to add a class to a project.thanx in
> advance.



 
Reply With Quote
 
 
 
 
Guest
Posts: n/a
 
      02-09-2004
hi,
i did the same but i am getting errors. my project
is ....
using System;
using System.Windows.Forms;

namespace MyForm {
public class CreatedForm :
System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox
txtvendorname;
public CreatedForm()
{
InitializeComponent();
}

// THIS METHOD IS MAINTAINED BY THE FORM
DESIGNER
// DO NOT EDIT IT MANUALLY! YOUR CHANGES
ARE LIKELY TO BE LOST
void InitializeComponent() {
this.txtvendorname = new
System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// txtvendorname
//
this.txtvendorname.Location = new
System.Drawing.Point(48, 24);
this.txtvendorname.Name
= "txtvendorname";
this.txtvendorname.Size = new
System.Drawing.Size(176, 20);
this.txtvendorname.TabIndex = 0;
this.txtvendorname.Text = "";
//
// CreatedForm
//
this.AutoScaleBaseSize = new
System.Drawing.Size(5, 13);
this.ClientSize = new
System.Drawing.Size(292, 266);
this.Controls.Add
(this.txtvendorname);
this.Name = "CreatedForm";
this.Load += new
System.EventHandler(this.CreatedFormLoad);
this.ResumeLayout(false);
}
//Vendor avendors = new Vendor[3];
private void CreatedFormLoad(object
sender, System.EventArgs e)
{
Vendor avendors = new Vendor[3];
avendors[0] = new Venor
("Microsoft");
avendors[1] = new Venor
("Rational");
avendors[2] = new Venor("Premia");
txtvendorname.DataBindings.Add
("Text",avendors,"Vendorname");
}
static void Main()
{
Application.Run(new CreatedForm
());
}

}
}
for this project i added this class
using System;

namespace _316c05
{

public class Vendor
{
private string vendorName;
public string VendorName
{
get
{
return vendorName;
}
set
{
vendorName = value;
}
}
public Vendor(string strVendorName)
{
this.VendorName = strVendorName;
}
}
}
when i run the projet i will get these errors:
[C# Error] WinForm.cs(89): The type or namespace
name 'Vendor' could not be found (are you missing a using
directive or an assembly reference?)
[C# Error] WinForm.cs(90): The name 'avendors' does not
exist in the class or namespace 's1.WinForm'
[C# Error] WinForm.cs(91): The name 'avendors' does not
exist in the class or namespace 's1.WinForm'
[C# Error] WinForm.cs(92): The name 'avendors' does not
exist in the class or namespace 's1.WinForm'
[C# Error] WinForm.cs(93): The name 'avendors' does not
exist in the class or namespace 's1.WinForm'
[C# Error] WinForm.cs(89): The type or namespace
name 'Vendor' could not be found (are you missing a using
directive or an assembly reference?)
[C# Error] WinForm.cs(90): The name 'avendors' does not
exist in the class or namespace 's1.WinForm'
[C# Error] WinForm.cs(91): The name 'avendors' does not
exist in the class or namespace 's1.WinForm'
[C# Error] WinForm.cs(92): The name 'avendors' does not
exist in the class or namespace 's1.WinForm'
[C# Error] WinForm.cs(93): The name 'avendors' does not
exist in the class or namespace 's1.WinForm'
[C# Error] WinForm.cs(89): The type or namespace
name 'Vendor' could not be found (are you missing a using
directive or an assembly reference?)
[C# Error] WinForm.cs(90): The name 'avendors' does not
exist in the class or namespace 's1.WinForm'
[C# Error] WinForm.cs(91): The name 'avendors' does not
exist in the class or namespace 's1.WinForm'
[C# Error] WinForm.cs(92): The name 'avendors' does not
exist in the class or namespace 's1.WinForm'
[C# Error] WinForm.cs(93): The name 'avendors' does not
exist in the class or namespace 's1.WinForm'
[C# Error] WinForm.cs(89): The type or namespace
name 'Vendor' could not be found (are you missing a using
directive or an assembly reference?)
[C# Error] WinForm.cs(90): The name 'avendors' does not
exist in the class or namespace 's1.WinForm'
[C# Error] WinForm.cs(91): The name 'avendors' does not
exist in the class or namespace 's1.WinForm'
[C# Error] WinForm.cs(92): The name 'avendors' does not
exist in the class or namespace 's1.WinForm'
[C# Error] WinForm.cs(93): The name 'avendors' does not
exist in the class or namespace 's1.WinForm'
[C# Fatal Error] Unexpected error creating debug
information file 'c:\Documents and Settings\Vini\My
Documents\Borland Studio Projects\s1\bin\Debug\s1.PDB' --
'c:\Documents and Settings\Vini\My Documents\Borland
Studio Projects\s1\bin\Debug\s1.pdb: The process cannot
access the file because it is being used by another
process.
[C# Error] WinForm.cs(89): The type or namespace
name 'Vendor' could not be found (are you missing a using
directive or an assembly reference?)
[C# Error] WinForm.cs(90): The name 'avendors' does not
exist in the class or namespace 's1.WinForm'
[C# Error] WinForm.cs(91): The name 'avendors' does not
exist in the class or namespace 's1.WinForm'
[C# Error] WinForm.cs(92): The name 'avendors' does not
exist in the class or namespace 's1.WinForm'
[C# Error] WinForm.cs(93): The name 'avendors' does not
exist in the class or namespace 's1.WinForm'
[C# Error] WinForm.cs(89): The type or namespace
name 'Vendor' could not be found (are you missing a using
directive or an assembly reference?)
[C# Error] WinForm.cs(90): The name 'avendors' does not
exist in the class or namespace 's1.WinForm'
[C# Error] WinForm.cs(91): The name 'avendors' does not
exist in the class or namespace 's1.WinForm'
[C# Error] WinForm.cs(92): The name 'avendors' does not
exist in the class or namespace 's1.WinForm'
[C# Error] WinForm.cs(93): The name 'avendors' does not
exist in the class or namespace 's1.WinForm'

THANX IN ADVANCE.


>-----Original Message-----
>right click on the project name in the solution explorer

and select Add and
>then select Add Class.
>
>
><(E-Mail Removed)> wrote in message
>news:c67901c3ed85$f6489110$(E-Mail Removed)...
>> please tell me how to add a class to a project.thanx in
>> advance.

>
>
>.
>

 
Reply With Quote
 
Ken Onweller \(.NET MCSD\)
Guest
Posts: n/a
 
      02-09-2004
Looking thru your code I noticed that your main form is defined thus:

MyForm.CreatedForm

Whereas, the class you wish to use is defined:

_316c05.Vendor

When you try to instantiate _316c05.Vendor from MyForm.CreatedForm you are
getting this error:

The type or namespace name 'Vendor' could not be found (are you missing a
using
directive or an assembly reference?)

In .NET your class is defined not just with the classname, but also with the
name of the namespace
containing it. You have your Form and your Class defined in two separate
namespaces (MyForm
and _316c05). So to solve your problem you could either put both files into
the same namespace [1];
add a using clause to MyForm, referencing the class's namespace [2]; or, you
can explicitly reference
Vendor from CreatedForm using the namespace.classname syntax[3].

[1]

change:

namespace _316c05
{
public class Vendor

to:

namespace MyForm
{
public class Vendor

[2]

change:

namespace MyForm
{
public class CreatedForm : System.Windows.Forms.Form
{

to:

namespace MyForm
{
using _316c05;

public class CreatedForm : System.Windows.Forms.Form
{

[3]

change:

private void CreatedFormLoad(object sender, System.EventArgs e)
{
Vendor avendors = new Vendor[3];

to:

private void CreatedFormLoad(object sender, System.EventArgs e)
{
_316c05.Vendor avendors = new _316c05.Vendor[3];



Hope this helps...





<(E-Mail Removed)> wrote in message
news:d10301c3eef8$fa77c840$(E-Mail Removed)...
> hi,
> i did the same but i am getting errors. my project
> is ....
> using System;
> using System.Windows.Forms;
>
> namespace MyForm {
> public class CreatedForm :
> System.Windows.Forms.Form
> {
> private System.Windows.Forms.TextBox
> txtvendorname;
> public CreatedForm()
> {
> InitializeComponent();
> }
>
> // THIS METHOD IS MAINTAINED BY THE FORM
> DESIGNER
> // DO NOT EDIT IT MANUALLY! YOUR CHANGES
> ARE LIKELY TO BE LOST
> void InitializeComponent() {
> this.txtvendorname = new
> System.Windows.Forms.TextBox();
> this.SuspendLayout();
> //
> // txtvendorname
> //
> this.txtvendorname.Location = new
> System.Drawing.Point(48, 24);
> this.txtvendorname.Name
> = "txtvendorname";
> this.txtvendorname.Size = new
> System.Drawing.Size(176, 20);
> this.txtvendorname.TabIndex = 0;
> this.txtvendorname.Text = "";
> //
> // CreatedForm
> //
> this.AutoScaleBaseSize = new
> System.Drawing.Size(5, 13);
> this.ClientSize = new
> System.Drawing.Size(292, 266);
> this.Controls.Add
> (this.txtvendorname);
> this.Name = "CreatedForm";
> this.Load += new
> System.EventHandler(this.CreatedFormLoad);
> this.ResumeLayout(false);
> }
> //Vendor avendors = new Vendor[3];
> private void CreatedFormLoad(object
> sender, System.EventArgs e)
> {
> Vendor avendors = new Vendor[3];
> avendors[0] = new Venor
> ("Microsoft");
> avendors[1] = new Venor
> ("Rational");
> avendors[2] = new Venor("Premia");
> txtvendorname.DataBindings.Add
> ("Text",avendors,"Vendorname");
> }
> static void Main()
> {
> Application.Run(new CreatedForm
> ());
> }
>
> }
> }
> for this project i added this class
> using System;
>
> namespace _316c05
> {
>
> public class Vendor
> {
> private string vendorName;
> public string VendorName
> {
> get
> {
> return vendorName;
> }
> set
> {
> vendorName = value;
> }
> }
> public Vendor(string strVendorName)
> {
> this.VendorName = strVendorName;
> }
> }
> }
> when i run the projet i will get these errors:
> [C# Error] WinForm.cs(89): The type or namespace
> name 'Vendor' could not be found (are you missing a using
> directive or an assembly reference?)
> [C# Error] WinForm.cs(90): The name 'avendors' does not
> exist in the class or namespace 's1.WinForm'
> [C# Error] WinForm.cs(91): The name 'avendors' does not
> exist in the class or namespace 's1.WinForm'
> [C# Error] WinForm.cs(92): The name 'avendors' does not
> exist in the class or namespace 's1.WinForm'
> [C# Error] WinForm.cs(93): The name 'avendors' does not
> exist in the class or namespace 's1.WinForm'
> [C# Error] WinForm.cs(89): The type or namespace
> name 'Vendor' could not be found (are you missing a using
> directive or an assembly reference?)
> [C# Error] WinForm.cs(90): The name 'avendors' does not
> exist in the class or namespace 's1.WinForm'
> [C# Error] WinForm.cs(91): The name 'avendors' does not
> exist in the class or namespace 's1.WinForm'
> [C# Error] WinForm.cs(92): The name 'avendors' does not
> exist in the class or namespace 's1.WinForm'
> [C# Error] WinForm.cs(93): The name 'avendors' does not
> exist in the class or namespace 's1.WinForm'
> [C# Error] WinForm.cs(89): The type or namespace
> name 'Vendor' could not be found (are you missing a using
> directive or an assembly reference?)
> [C# Error] WinForm.cs(90): The name 'avendors' does not
> exist in the class or namespace 's1.WinForm'
> [C# Error] WinForm.cs(91): The name 'avendors' does not
> exist in the class or namespace 's1.WinForm'
> [C# Error] WinForm.cs(92): The name 'avendors' does not
> exist in the class or namespace 's1.WinForm'
> [C# Error] WinForm.cs(93): The name 'avendors' does not
> exist in the class or namespace 's1.WinForm'
> [C# Error] WinForm.cs(89): The type or namespace
> name 'Vendor' could not be found (are you missing a using
> directive or an assembly reference?)
> [C# Error] WinForm.cs(90): The name 'avendors' does not
> exist in the class or namespace 's1.WinForm'
> [C# Error] WinForm.cs(91): The name 'avendors' does not
> exist in the class or namespace 's1.WinForm'
> [C# Error] WinForm.cs(92): The name 'avendors' does not
> exist in the class or namespace 's1.WinForm'
> [C# Error] WinForm.cs(93): The name 'avendors' does not
> exist in the class or namespace 's1.WinForm'
> [C# Fatal Error] Unexpected error creating debug
> information file 'c:\Documents and Settings\Vini\My
> Documents\Borland Studio Projects\s1\bin\Debug\s1.PDB' --
> 'c:\Documents and Settings\Vini\My Documents\Borland
> Studio Projects\s1\bin\Debug\s1.pdb: The process cannot
> access the file because it is being used by another
> process.
> [C# Error] WinForm.cs(89): The type or namespace
> name 'Vendor' could not be found (are you missing a using
> directive or an assembly reference?)
> [C# Error] WinForm.cs(90): The name 'avendors' does not
> exist in the class or namespace 's1.WinForm'
> [C# Error] WinForm.cs(91): The name 'avendors' does not
> exist in the class or namespace 's1.WinForm'
> [C# Error] WinForm.cs(92): The name 'avendors' does not
> exist in the class or namespace 's1.WinForm'
> [C# Error] WinForm.cs(93): The name 'avendors' does not
> exist in the class or namespace 's1.WinForm'
> [C# Error] WinForm.cs(89): The type or namespace
> name 'Vendor' could not be found (are you missing a using
> directive or an assembly reference?)
> [C# Error] WinForm.cs(90): The name 'avendors' does not
> exist in the class or namespace 's1.WinForm'
> [C# Error] WinForm.cs(91): The name 'avendors' does not
> exist in the class or namespace 's1.WinForm'
> [C# Error] WinForm.cs(92): The name 'avendors' does not
> exist in the class or namespace 's1.WinForm'
> [C# Error] WinForm.cs(93): The name 'avendors' does not
> exist in the class or namespace 's1.WinForm'
>
> THANX IN ADVANCE.
>
>
> >-----Original Message-----
> >right click on the project name in the solution explorer

> and select Add and
> >then select Add Class.
> >
> >
> ><(E-Mail Removed)> wrote in message
> >news:c67901c3ed85$f6489110$(E-Mail Removed)...
> >> please tell me how to add a class to a project.thanx in
> >> advance.

> >
> >
> >.
> >



 
Reply With Quote
 
Guest
Posts: n/a
 
      02-09-2004
thanks a lot ken.
>-----Original Message-----
>Looking thru your code I noticed that your main form is

defined thus:
>
>MyForm.CreatedForm
>
>Whereas, the class you wish to use is defined:
>
>_316c05.Vendor
>
>When you try to instantiate _316c05.Vendor from

MyForm.CreatedForm you are
>getting this error:
>
>The type or namespace name 'Vendor' could not be found

(are you missing a
>using
>directive or an assembly reference?)
>
>In .NET your class is defined not just with the

classname, but also with the
>name of the namespace
>containing it. You have your Form and your Class

defined in two separate
>namespaces (MyForm
>and _316c05). So to solve your problem you could either

put both files into
>the same namespace [1];
>add a using clause to MyForm, referencing the class's

namespace [2]; or, you
>can explicitly reference
>Vendor from CreatedForm using the namespace.classname

syntax[3].
>
>[1]
>
>change:
>
>namespace _316c05
>{
> public class Vendor
>
>to:
>
>namespace MyForm
>{
> public class Vendor
>
>[2]
>
>change:
>
>namespace MyForm
>{
> public class CreatedForm : System.Windows.Forms.Form
> {
>
>to:
>
>namespace MyForm
>{
> using _316c05;
>
> public class CreatedForm : System.Windows.Forms.Form
> {
>
>[3]
>
>change:
>
>private void CreatedFormLoad(object sender,

System.EventArgs e)
>{
> Vendor avendors = new Vendor[3];
>
>to:
>
>private void CreatedFormLoad(object sender,

System.EventArgs e)
>{
> _316c05.Vendor avendors = new _316c05.Vendor[3];
>
>
>
>Hope this helps...
>
>
>
>
>
><(E-Mail Removed)> wrote in message
>news:d10301c3eef8$fa77c840$(E-Mail Removed)...
>> hi,
>> i did the same but i am getting errors. my project
>> is ....
>> using System;
>> using System.Windows.Forms;
>>
>> namespace MyForm {
>> public class CreatedForm :
>> System.Windows.Forms.Form
>> {
>> private System.Windows.Forms.TextBox
>> txtvendorname;
>> public CreatedForm()
>> {
>> InitializeComponent();
>> }
>>
>> // THIS METHOD IS MAINTAINED BY THE FORM
>> DESIGNER
>> // DO NOT EDIT IT MANUALLY! YOUR CHANGES
>> ARE LIKELY TO BE LOST
>> void InitializeComponent() {
>> this.txtvendorname = new
>> System.Windows.Forms.TextBox();
>> this.SuspendLayout();
>> //
>> // txtvendorname
>> //
>> this.txtvendorname.Location = new
>> System.Drawing.Point(48, 24);
>> this.txtvendorname.Name
>> = "txtvendorname";
>> this.txtvendorname.Size = new
>> System.Drawing.Size(176, 20);
>> this.txtvendorname.TabIndex = 0;
>> this.txtvendorname.Text = "";
>> //
>> // CreatedForm
>> //
>> this.AutoScaleBaseSize = new
>> System.Drawing.Size(5, 13);
>> this.ClientSize = new
>> System.Drawing.Size(292, 266);
>> this.Controls.Add
>> (this.txtvendorname);
>> this.Name = "CreatedForm";
>> this.Load += new
>> System.EventHandler(this.CreatedFormLoad);
>> this.ResumeLayout(false);
>> }
>> //Vendor avendors = new Vendor[3];
>> private void CreatedFormLoad(object
>> sender, System.EventArgs e)
>> {
>> Vendor avendors = new Vendor[3];
>> avendors[0] = new Venor
>> ("Microsoft");
>> avendors[1] = new Venor
>> ("Rational");
>> avendors[2] = new Venor("Premia");
>> txtvendorname.DataBindings.Add
>> ("Text",avendors,"Vendorname");
>> }
>> static void Main()
>> {
>> Application.Run(new CreatedForm
>> ());
>> }
>>
>> }
>> }
>> for this project i added this class
>> using System;
>>
>> namespace _316c05
>> {
>>
>> public class Vendor
>> {
>> private string vendorName;
>> public string VendorName
>> {
>> get
>> {
>> return vendorName;
>> }
>> set
>> {
>> vendorName = value;
>> }
>> }
>> public Vendor(string strVendorName)
>> {
>> this.VendorName = strVendorName;
>> }
>> }
>> }
>> when i run the projet i will get these errors:
>> [C# Error] WinForm.cs(89): The type or namespace
>> name 'Vendor' could not be found (are you missing a

using
>> directive or an assembly reference?)
>> [C# Error] WinForm.cs(90): The name 'avendors' does not
>> exist in the class or namespace 's1.WinForm'
>> [C# Error] WinForm.cs(91): The name 'avendors' does not
>> exist in the class or namespace 's1.WinForm'
>> [C# Error] WinForm.cs(92): The name 'avendors' does not
>> exist in the class or namespace 's1.WinForm'
>> [C# Error] WinForm.cs(93): The name 'avendors' does not
>> exist in the class or namespace 's1.WinForm'
>> [C# Error] WinForm.cs(89): The type or namespace
>> name 'Vendor' could not be found (are you missing a

using
>> directive or an assembly reference?)
>> [C# Error] WinForm.cs(90): The name 'avendors' does not
>> exist in the class or namespace 's1.WinForm'
>> [C# Error] WinForm.cs(91): The name 'avendors' does not
>> exist in the class or namespace 's1.WinForm'
>> [C# Error] WinForm.cs(92): The name 'avendors' does not
>> exist in the class or namespace 's1.WinForm'
>> [C# Error] WinForm.cs(93): The name 'avendors' does not
>> exist in the class or namespace 's1.WinForm'
>> [C# Error] WinForm.cs(89): The type or namespace
>> name 'Vendor' could not be found (are you missing a

using
>> directive or an assembly reference?)
>> [C# Error] WinForm.cs(90): The name 'avendors' does not
>> exist in the class or namespace 's1.WinForm'
>> [C# Error] WinForm.cs(91): The name 'avendors' does not
>> exist in the class or namespace 's1.WinForm'
>> [C# Error] WinForm.cs(92): The name 'avendors' does not
>> exist in the class or namespace 's1.WinForm'
>> [C# Error] WinForm.cs(93): The name 'avendors' does not
>> exist in the class or namespace 's1.WinForm'
>> [C# Error] WinForm.cs(89): The type or namespace
>> name 'Vendor' could not be found (are you missing a

using
>> directive or an assembly reference?)
>> [C# Error] WinForm.cs(90): The name 'avendors' does not
>> exist in the class or namespace 's1.WinForm'
>> [C# Error] WinForm.cs(91): The name 'avendors' does not
>> exist in the class or namespace 's1.WinForm'
>> [C# Error] WinForm.cs(92): The name 'avendors' does not
>> exist in the class or namespace 's1.WinForm'
>> [C# Error] WinForm.cs(93): The name 'avendors' does not
>> exist in the class or namespace 's1.WinForm'
>> [C# Fatal Error] Unexpected error creating debug
>> information file 'c:\Documents and Settings\Vini\My
>> Documents\Borland Studio Projects\s1

\bin\Debug\s1.PDB' --
>> 'c:\Documents and Settings\Vini\My Documents\Borland
>> Studio Projects\s1\bin\Debug\s1.pdb: The process cannot
>> access the file because it is being used by another
>> process.
>> [C# Error] WinForm.cs(89): The type or namespace
>> name 'Vendor' could not be found (are you missing a

using
>> directive or an assembly reference?)
>> [C# Error] WinForm.cs(90): The name 'avendors' does not
>> exist in the class or namespace 's1.WinForm'
>> [C# Error] WinForm.cs(91): The name 'avendors' does not
>> exist in the class or namespace 's1.WinForm'
>> [C# Error] WinForm.cs(92): The name 'avendors' does not
>> exist in the class or namespace 's1.WinForm'
>> [C# Error] WinForm.cs(93): The name 'avendors' does not
>> exist in the class or namespace 's1.WinForm'
>> [C# Error] WinForm.cs(89): The type or namespace
>> name 'Vendor' could not be found (are you missing a

using
>> directive or an assembly reference?)
>> [C# Error] WinForm.cs(90): The name 'avendors' does not
>> exist in the class or namespace 's1.WinForm'
>> [C# Error] WinForm.cs(91): The name 'avendors' does not
>> exist in the class or namespace 's1.WinForm'
>> [C# Error] WinForm.cs(92): The name 'avendors' does not
>> exist in the class or namespace 's1.WinForm'
>> [C# Error] WinForm.cs(93): The name 'avendors' does not
>> exist in the class or namespace 's1.WinForm'
>>
>> THANX IN ADVANCE.
>>
>>
>> >-----Original Message-----
>> >right click on the project name in the solution

explorer
>> and select Add and
>> >then select Add Class.
>> >
>> >
>> ><(E-Mail Removed)> wrote in message
>> >news:c67901c3ed85$f6489110$(E-Mail Removed)...
>> >> please tell me how to add a class to a

project.thanx in
>> >> advance.
>> >
>> >
>> >.
>> >

>
>
>.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments