|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Compilation error - missing assembly or referenceI 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 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 Show quote "Varun Bansal" <varun_b***@yahoo.com> wrote in message news:OV32zOUaGHA.4752@TK2MSFTNGP02.phx.gbl... > 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 > > > It sounds like the project you are trying to compile was created in VS2005,
instead of VS2003. You will have to compile using VS2005. -- Show quoteBrad "Software is like melted pudding..." "Varun Bansal" wrote: > 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" <varun_b***@yahoo.com> wrote in message > news:OV32zOUaGHA.4752@TK2MSFTNGP02.phx.gbl... > > 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 > > > > > > > > > Thanks Brad for the prompt reply. It worked !
Varun Show quote "Brad Roberts" <BradRoberts56noj***@hotmail.com> wrote in message news:AB36CC2D-3DCD-48CE-AE6B-690104E643C8@microsoft.com... > 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" wrote: > >> 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" <varun_b***@yahoo.com> wrote in message >> news:OV32zOUaGHA.4752@TK2MSFTNGP02.phx.gbl... >> > 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 >> > >> > >> > >> >> >> |
|||||||||||||||||||||||