Hi,
I was trying to compile the following sample code from MSDN
using System;
using System.Collections;
using System.Text;
using System.Management.Automation;
using System.Management.Automation.Host;
using System.Management.Automation.Runspaces;
namespace Microsoft.Samples.Msh.Host
{
class Runspace01
{
static void Main(string[] args)
{
RunspaceInvoke invoker = new RunspaceInvoke();
Console.WriteLine("Process HandleCount");
Console.WriteLine("--------------------------------");
foreach (MshObject result in invoker.Invoke("get-process"))
{
Console.WriteLine("{0,-20} {1}",
result.Members["ProcessName"].Value,
result.Members["HandleCount"].Value);
}
System.Console.WriteLine("Hit any key to exit...");
System.Console.ReadKey();
}
}
}
And I'm getting the following error -
The type or namespace name 'Generic' does not exist in the class or
namespace 'System.Collections' (are you missing an assembly reference?)
The type or namespace name 'Automation' does not exist in the class or
namespace 'System.Management' (are you missing an assembly reference?)
The type or namespace name 'Automation' does not exist in the class or
namespace 'System.Management' (are you missing an assembly reference?)
The type or namespace name 'Automation' does not exist in the class or
namespace 'System.Management' (are you missing an assembly reference?)
I installed the latest .net 2.0 framework. When I try to add the reference
of System.Management.Automation.dll in VS2k3 .net, it does not allow me to
add saying that it is not a valid dll. Am I missing something? I'm new to
.NET. Please help.
Thanks,
Varun
Varun Bansal - 26 Apr 2006 16:46 GMT
Oh Sorry - it was using System.Collections.Generic on the second line and
not using System.Collections.
I cannot find using System.Collections.Generic namespace in
System.Collections.
Varun
> Hi,
>
[quoted text clipped - 45 lines]
> Thanks,
> Varun
Chris Chilvers - 29 Apr 2006 16:34 GMT
Mattias Sjögren - 26 Apr 2006 17:39 GMT
>I installed the latest .net 2.0 framework. When I try to add the reference
>of System.Management.Automation.dll in VS2k3 .net, it does not allow me to
>add saying that it is not a valid dll. Am I missing something? I'm new to
>.NET. Please help.
VS 2003 only supports version 1.1 of the framework. To reference 2.0
assemblies you need VS 2005.
Mattias

Signature
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Varun Bansal - 26 Apr 2006 18:51 GMT
Thanks Mattias for the prompt reply. It worked !
Varun
>>I installed the latest .net 2.0 framework. When I try to add the reference
>>of System.Management.Automation.dll in VS2k3 .net, it does not allow me to
[quoted text clipped - 5 lines]
>
> Mattias