By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,633 Members | 1,856 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,633 IT Pros & Developers. It's quick & easy.

using System.Windows.Forms in error??

P: n/a
Hi All,

I tried creating a C# Form using Petzold's "Programming MS Windows with C#"
guidance. He recommended using the namespace System.Windows.Forms.

However, VS.NET claims "the type or namespace name 'Windows' does not exist
in the class or namespace 'System'."

But I read it, MSDN seems to think it's fine at
http://msdn.microsoft.com/library/de...classtopic.asp.

Anybody know what's going on here?

Thanks in Advance,
Richard
Nov 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Richard,

Petzold? Who is he? What does he know?

Ok, I'm kidding.

Seriously though, you want to add a reference to
System.Windows.Forms.dll. You need the reference to the assembly in order
to use it.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Richard Lionheart" <No***@Nowhere.net> wrote in message
news:OP**************@tk2msftngp13.phx.gbl...
Hi All,

I tried creating a C# Form using Petzold's "Programming MS Windows with
C#" guidance. He recommended using the namespace System.Windows.Forms.

However, VS.NET claims "the type or namespace name 'Windows' does not
exist in the class or namespace 'System'."

But I read it, MSDN seems to think it's fine at
http://msdn.microsoft.com/library/de...classtopic.asp.

Anybody know what's going on here?

Thanks in Advance,
Richard

Nov 17 '05 #2

P: n/a
> But as I read it, MSDN seems to think it's fine at
http://msdn.microsoft.com/library/de...classtopic.asp.
I just checked that MSDN page again and noted the bottom contains the note:
Syntax based on .NET Framework version 1.1. But my Help | About page for my
VS.NET Pro 2002 installation lists only Framework 1.0.

So my problem is that VS.NET doesn't honor my Framework 1.1 installation.

I've got 1.1 installed correctly, I believe.
-- First, because when I bring up Control Panel | Add/Remove Programs, I
see 1.1 listed as a candidate for removal.
-- Second, and more importantly, in some contexts I see 1.1 listed as a
source of some server-generated web page created in VS.NET.
-- Finally, %HOMEDRIVE%\Program Files\Microsoft.NET\SDK has a ~200MB v1.1
subdirectory.

Anyone got a suggestion as to how I can get VS.NET to recognize that
Framework 1.1 is installed so that hopefully Petzold's stuff will work?
Thanks in Advance,
Richard

Nov 17 '05 #3

P: n/a
Hi Nicholas,

Thank you very much for replying to my question.
Petzold? Who is he? What does he know? He's an awesome guy, isn't he? And I love the founders of Wintellect, too.
Seriously though, you want to add a reference to
System.Windows.Forms.dll. You need the reference to the assembly in order
to use it.
I've got the .dll in %windir%\ServicePackFiles\i386. And I was under the
impression that "using System.Windows.Forms" IS a reference to that dll. So
isn't my real problem that VS.NET isn't looking in that directory to pick up
the .dll.

And that idea seems to be consistent with the problem I outlined in my
1:44am post, which I'll repeat here for your convenience:

==== From previous post
I just checked that MSDN page again and noted the bottom contains the note:
Syntax based on .NET Framework version 1.1. But my Help | About page for my
VS.NET Pro 2002 installation lists only Framework 1.0.

So my problem is that VS.NET doesn't honor my Framework 1.1 installation.

I've got 1.1 installed correctly, I believe.
-- First, because when I bring up Control Panel | Add/Remove Programs, I
see 1.1 listed as a candidate for removal.
-- Second, and more importantly, in some contexts I see 1.1 listed as a
source of some server-generated web page created in VS.NET.
-- Finally, %HOMEDRIVE%\Program Files\Microsoft.NET\SDK has a ~200MB v1.1
subdirectory.

Anyone got a suggestion as to how I can get VS.NET to recognize that
Framework 1.1 is installed so that hopefully Petzold's stuff will work?
==== End of previous post

I checked VS.NET's tools' customize and options menu items but didn't see
anyway to add the name of the directory that houses the dll. (VS 6.0 had a
mechanism for doing that kind of thing. Where is it when we need it?)

If there's another way to reference that .dll, I appreciate learning how to
do it.
Hope this helps.

It certainly does.

Thanks again for replying.
Richard
Nov 17 '05 #4

P: n/a
Richard,

That's the thing, the using statement does not mean that you are setting
a reference. It is just a way of allowing you to use the
non-namespace-qualified names of a class. In other words, it allows you to
do this:

TextBox textBox;

Instead of:

System.Windows.Forms.TextBox textBox;

If you want to add a reference, go to your project, and right click on
the folder in your project labeled "references" and select "Add reference".
Then select System.Windows.Forms.dll from the dialog that appears.

Also, the location you specified is a backup due to an OS patch. The
true location is something like:

c:\windows\microsoft.net\<version>\System.Windows. Forms.dll

However, you shouldn't have to pick that, as VS.NET will show you the
correct version in the add reference dialog.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Richard Lionheart" <No***@Nowhere.net> wrote in message
news:ca********************@adelphia.com...
Hi Nicholas,

Thank you very much for replying to my question.
Petzold? Who is he? What does he know?

He's an awesome guy, isn't he? And I love the founders of Wintellect,
too.
Seriously though, you want to add a reference to
System.Windows.Forms.dll. You need the reference to the assembly in
order to use it.


I've got the .dll in %windir%\ServicePackFiles\i386. And I was under the
impression that "using System.Windows.Forms" IS a reference to that dll.
So isn't my real problem that VS.NET isn't looking in that directory to
pick up the .dll.

And that idea seems to be consistent with the problem I outlined in my
1:44am post, which I'll repeat here for your convenience:

==== From previous post
I just checked that MSDN page again and noted the bottom contains the
note:
Syntax based on .NET Framework version 1.1. But my Help | About page for
my
VS.NET Pro 2002 installation lists only Framework 1.0.

So my problem is that VS.NET doesn't honor my Framework 1.1 installation.

I've got 1.1 installed correctly, I believe.
-- First, because when I bring up Control Panel | Add/Remove Programs, I
see 1.1 listed as a candidate for removal.
-- Second, and more importantly, in some contexts I see 1.1 listed as a
source of some server-generated web page created in VS.NET.
-- Finally, %HOMEDRIVE%\Program Files\Microsoft.NET\SDK has a ~200MB v1.1
subdirectory.

Anyone got a suggestion as to how I can get VS.NET to recognize that
Framework 1.1 is installed so that hopefully Petzold's stuff will work?
==== End of previous post

I checked VS.NET's tools' customize and options menu items but didn't see
anyway to add the name of the directory that houses the dll. (VS 6.0 had
a mechanism for doing that kind of thing. Where is it when we need it?)

If there's another way to reference that .dll, I appreciate learning how
to do it.
Hope this helps.

It certainly does.

Thanks again for replying.
Richard

Nov 17 '05 #5

P: n/a
Hi Nicholas,

Success!! Many thanks for your mentoring.
It is just a way of allowing you to use the non-namespace-qualified names
of a class.
Now that you tell me, I remember reading this before. But this time it
will stick in my feeble brain :-)
right click on the folder in your project labeled "references"
If I may be so bold as to criticize my mentor, I would say "look in the
Solution Explorer pane in VS.NET ...". I wasted a few minutes looking at my
project in Windows Explorer, but those few minutes were well worth the
price of reaching that nugget that got my project moving.
Also, the location you specified is a backup due to an OS patch. So I should keep it in case an uninstall (of a Framework version I suppose)
becomes necessary
The true location is ...: Right on! I've got "%windir%\Microsoft.NET\Framework"
with subdirectories v1.0.3705 and v1.1.4322.
However, you shouldn't have to pick that, as VS.NET will show you the
correct version in the add reference dialog.

It turned out that the Add Reference dialog *did* list
System.Windows.Forms.dll, but the OK button was disabled.

When I opened the Select Component dialog, it positioned itself at
"%windir%\ServicePackFiles\i386" which had the .DLL created/mod'd July 19,
2004, 5:54:22 PM and sized 2,002,944 bytes.

On the other hand I navigated to
"%windir%\Microsoft.NET\Framework\v1.1.4322",
the .DLL was created/mod'd earlier July 15, 2004, 1:32:02 PM but was
larger: 2,052,096 bytes.

I went with default (ServicePackFiles) directory. VS.NET indicated, as I
understand it, that it was adjusting the other references in this project to
the versions from the same directory. I checked the paths for all the
references and the were indeed set to ServicePackFiles, save one: System.

That's the approach I going with hereafter. Does that sound right to you?

Best wishes and many thanks,
Richard

Nov 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.