473,372 Members | 1,331 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,372 software developers and data experts.

Where is System.Collections when using csc.exe

I've got some C# code to create a custom PowerShell cmdlet with these
statements:

....
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
....

My compile fails using csc.exe:
PSHcsc /t:library /r:$ref testweather2.cs
Microsoft (R) Visual C# 2005 Compiler version 8.00.50727.1378
for Microsoft (R) Windows (R) 2005 Framework version 2.0.50727
Copyright (C) Microsoft Corporation 2001-2005. All rights reserved.

testweather2.cs(65,13): error CS0246: The type or namespace name
'Collection' could not be found (are you missing a
using directive or an assembly reference?)
testweather2.cs(69,13): error CS1579: foreach statement cannot operate
on variables of type
'Collection<System.Management.Automation.PSObject> ' because
'Collection<System.Management.Automation.PSObject> '
does not contain a public definition for 'GetEnumerator'
PSH>

PSH$ref
C:\WINDOWS\assembly\GAC_MSIL\System.Management.Aut omation\1.0.0.0__31bf3856ad364e35\System.Managemen t.Automation.dll
So I'm figuring I need to add a couple of references. I'm assuming I
need to go and find the DLLs for:
1. System.Collections
2. System.Collections.Generic
3. System.Collections.ObjectModel

Are they normally hidden? I can't seem to find them.

Visual Studio C# Express 2005 doesn't have a problem with them though,
and can compile my code without errors.

That also brings up another point, if the path has spaces, I've not been
able to figure out how to add a reference with spaces to csc.exe. Tried
quotes, casting it to a string... I can't figure it out.

--
----------------
PowerGadgets MVP
http://www.powergadgets.com/mvp

Blog:
http://marcoshaw.blogspot.com
Sep 22 '07 #1
3 16117
Marco,

Namespaces are not required to have their types completely contained
within an assembly, so asking where the types for a namespace are located
doesn't make much sense.

However, the Collection<Tclass is in mscorlib.dll. By default, csc
should make a reference to mscorlib.dll automatically, so it seems like it
should work to me.

If you compile this from the command line yourself, does it work? What
about in VS.NET?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Marco Shaw" <marco.shaw@_NO_SPAM_gmail.comwrote in message
news:ur**************@TK2MSFTNGP05.phx.gbl...
I've got some C# code to create a custom PowerShell cmdlet with these
statements:

...
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
...

My compile fails using csc.exe:
PSHcsc /t:library /r:$ref testweather2.cs
Microsoft (R) Visual C# 2005 Compiler version 8.00.50727.1378
for Microsoft (R) Windows (R) 2005 Framework version 2.0.50727
Copyright (C) Microsoft Corporation 2001-2005. All rights reserved.

testweather2.cs(65,13): error CS0246: The type or namespace name
'Collection' could not be found (are you missing a
using directive or an assembly reference?)
testweather2.cs(69,13): error CS1579: foreach statement cannot operate on
variables of type
'Collection<System.Management.Automation.PSObject> ' because
'Collection<System.Management.Automation.PSObject> '
does not contain a public definition for 'GetEnumerator'
PSH>

PSH$ref
C:\WINDOWS\assembly\GAC_MSIL\System.Management.Aut omation\1.0.0.0__31bf3856ad364e35\System.Managemen t.Automation.dll

So I'm figuring I need to add a couple of references. I'm assuming I need
to go and find the DLLs for:
1. System.Collections
2. System.Collections.Generic
3. System.Collections.ObjectModel

Are they normally hidden? I can't seem to find them.

Visual Studio C# Express 2005 doesn't have a problem with them though, and
can compile my code without errors.

That also brings up another point, if the path has spaces, I've not been
able to figure out how to add a reference with spaces to csc.exe. Tried
quotes, casting it to a string... I can't figure it out.

--
----------------
PowerGadgets MVP
http://www.powergadgets.com/mvp

Blog:
http://marcoshaw.blogspot.com
Sep 22 '07 #2
"Marco Shaw" <marco.shaw@_NO_SPAM_gmail.comwrote in message
news:ur**************@TK2MSFTNGP05.phx.gbl...
I've got some C# code to create a custom PowerShell cmdlet with these
statements:

...
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
...

My compile fails using csc.exe:
PSHcsc /t:library /r:$ref testweather2.cs
Microsoft (R) Visual C# 2005 Compiler version 8.00.50727.1378
for Microsoft (R) Windows (R) 2005 Framework version 2.0.50727
Copyright (C) Microsoft Corporation 2001-2005. All rights reserved.

testweather2.cs(65,13): error CS0246: The type or namespace name
'Collection' could not be found (are you missing a
using directive or an assembly reference?)
The "Collection" type is in the System.Collections.ObjectModel namespace
which is part of the mscorlib assembly, this assembly is implicitely
referenced, so above should work.
testweather2.cs(69,13): error CS1579: foreach statement cannot operate on
variables of type
'Collection<System.Management.Automation.PSObject> ' because
'Collection<System.Management.Automation.PSObject> '
does not contain a public definition for 'GetEnumerator'
PSH>

PSH$ref
C:\WINDOWS\assembly\GAC_MSIL\System.Management.Aut omation\1.0.0.0__31bf3856ad364e35\System.Managemen t.Automation.dll
You should not reference assemblies in the GAC, the PS assemblies (like
System.Management.Automation.dll)
should be found in "x:\Program Files\Reference
Assemblies\Microsoft\WindowsPowerShell\v1.0", where x is your system drive.
So you need to add a reference to x:\Program Files\Reference
Assemblies\Microsoft\WindowsPowerShell\v1.0\System .Management.Automation.dll).
>
So I'm figuring I need to add a couple of references. I'm assuming I need
to go and find the DLLs for:
1. System.Collections
2. System.Collections.Generic
3. System.Collections.ObjectModel

Are they normally hidden? I can't seem to find them.
This are namespaces, not assemblies, these namespaces are part of
mscorlib.dll.
Visual Studio C# Express 2005 doesn't have a problem with them though, and
can compile my code without errors.

That also brings up another point, if the path has spaces, I've not been
able to figure out how to add a reference with spaces to csc.exe. Tried
quotes, casting it to a string... I can't figure it out.
Paths containing spaces need to be enclosed by quotes, like : /r:"path
containing spaces"
Willy.

Sep 22 '07 #3
Marco Shaw wrote:
I've got some C# code to create a custom PowerShell cmdlet with these
statements:

...
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
...
Turns out I was missing the last "using" statement above in my code I
was actually testing.

Sorry!
--
----------------
PowerGadgets MVP
http://www.powergadgets.com/mvp

Blog:
http://marcoshaw.blogspot.com
Sep 23 '07 #4

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

Similar topics

3
by: Bob | last post by:
Is there an interface or events in the system that occurs pre and post garbage collection that one of my objects can attach to? I need to know in my application when garbage collection is about to...
4
by: emma middlebrook | last post by:
Hi Straight to the point - I don't understand why System.Array derives from IList (given the methods/properties actually on IList). When designing an interface you specify a contract. Deriving...
2
by: Howard Swope | last post by:
Could someone help explain thread safety issues in the System.Collections classes? The documentation states:...
2
by: ljlevend | last post by:
I've noticed that in VS.NET 2.0 Beta 1 that none of the methods in System.Collections.Generic.List are overridable. In my app I currently have over 50 strongly typed ArrayLists that inherit from...
4
by: nhmark64 | last post by:
Hi, Does System.Collections.Generic.Queue not have a Synchronized method because it is already in effect synchronized, or is the Synchronized functionality missing from...
2
by: Justin Drerup | last post by:
I'm tryng to return a custom object that contains a collection of MembershipUsers through a web service however I receive the following error when trying to return the object through a web method:...
10
by: Paul Cheetham | last post by:
Hi, I am developing an application that needs to store some machine-specific settings. The application is going to be published on the network in order to keep the clients on the latest version....
2
by: =?Utf-8?B?TWluIFlvbmc=?= | last post by:
I'm not sure if I've just lost it but, I no longer see the property SyncRoot on a Queue. I see that it's a member of the ICollection Base Object, but it's not exposed. Was this intended? Besides...
2
by: Fred Heida | last post by:
Hi, i'm trying to (using managed C++) implment the IEnumerable<Tinterface on my class.. but have a problem with the 2 GetEnumerator method required.... what i have done is... ...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.