Compilation error - missing assembly or reference

V

Varun Bansal

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
 
V

Varun Bansal

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
 
G

Guest

It sounds like the project you are trying to compile was created in VS2005,
instead of VS2003. You will have to compile using VS2005.
--
Brad

"Software is like melted pudding..."


Varun Bansal said:
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

Varun Bansal said:
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
 
V

Varun Bansal

Thanks Brad for the prompt reply. It worked !

Varun

Brad Roberts said:
It sounds like the project you are trying to compile was created in
VS2005,
instead of VS2003. You will have to compile using VS2005.
--
Brad

"Software is like melted pudding..."


Varun Bansal said:
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

Varun Bansal said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top