![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Newbie
Join Date: Jan 2005
Posts: 21
Rep Power: 0
![]() |
Referencing External Assemblies
I am just starting to teach myself C#, and have run into a snag, probably with my compiler settings. I am using VS.NET 2003.
Here's the problem. When I try to reference an external assembly, for example "using System.Windows.Forms", the compiler claims that Windows does not exists in the Systems namespace. Can someone explain to me how to fix this issue? I have already downloaded the new .NET SDK version 2.0, I was originally using v. 1.1, and nothing has changed. Thanks in advance. |
|
|
|
|
|
#2 |
|
Newbie
Join Date: Aug 2005
Location: Romania
Posts: 13
Rep Power: 0
![]() |
Referencing assemblies is usually done in the IDE (I don't have VS.NET 2003 so you should read the documentation.). In Visual C# 2005 Express Edition you can use the References entry in the Solution Explorer.
If you compile from the command line, use the /reference argument. In code, "using System.Windows.Forms" makes the types in the namespace available without qualification (you can use "Form" instead of "System.Windows.Forms.Form"). It does not reference the assembly. Another way to use types from an assembly is through Reflection (dynamically load an assembly and invoke its types). So, the compiler is correct. You are probably referencing System.dll, so the System namespace is available. The fact that it cannot find Windows in the System namespace doesn't have anything to do with the version of the .NET Framework you are using. Furthermore, Microsoft states that each VS version targets a specific .NET Framework version. If you want to use 2.0, upgrade to VS 2005 (or just use the Express Editions). |
|
|
|
|
|
#3 |
|
Expert Programmer
|
I had this error a while ago, and what had happened is I actually created an object which hid one of the namespaces, which lead to that error. This means there could be something in your code overriding or hiding the Systems namespace, or any one of them. And to make the matter worse, if I recall correctly it wasn't even Systems or Windows or Forms that was hidden, it was something else.
The other possiblity is that you broke your references in your project. You will need to add the System.Windows.Form reference back by right clicking on References, and adding back the .NET reference corresonding to that namespace. You can also try to recreate your project. I did not ever run into any of these problems until I started using MSVS 2005 Express Editions, than again it could just be coincidence (I would still recommend using 2005).
__________________
Clifford Matthew Roche <geek@cliffordroche.com> Web Hosting: http://www.crd-hosting.com Consulting: http://www.crdev-consulting.com |
|
|
|
|
|
#4 |
|
Programmer
Join Date: Dec 2005
Posts: 53
Rep Power: 3
![]() |
I didn't think it was possible to use the .NET Framework 2.0 with Visual Studio .NET 2003 because the 1.1 framework is so tied in with the IDE. Even though you may have downloaded the .NET 2.0 SDK, that does not imply that you're using the .NET 2.0 SDK with .NET 2003.
edit: Hmm. I did some searching on the issue, and found out that it is possible to use the .NET Framework 2.0 with Visual Studio 2003, but it's highly not recommended. Not only can you not use the features of 2.0, but your programs will likely crash. http://www.dotnet247.com/247referenc...53/268176.aspx |
|
|
|
|
|
#5 |
|
Newbie
Join Date: Jan 2005
Posts: 21
Rep Power: 0
![]() |
Wow! I posted this over a year ago!
If I remember correctly, the solution was as easy as adding the appropriate reference using the solution explorer in VS 2003. Thanks replying though. ![]() |
|
|
|
|
|
#6 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Some people think you've been hanging around your monitor for a year, waiting for the solution
.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|