![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | referencing system.management.automation DLL (or other Gac'd ones) How do you reference DLLs in the gac dynamically? Is there a method to find a link to the gac'd items? Currently the only way I can seem to reference this one dynamically to pass to CSharpCodeProvider is by looking at the location of the currently loaded one with $(([appdomain]::currentdomain.getassemblies() |where {($_.fullname -match "system.management.automation")}).location) $ClassSystem.CSharpCodeProvider = new-object Microsoft.CSharp.CSharpCodeProvider $ClassSystem.StandardParams = new-object System.CodeDom.Compiler.CompilerParameters $ClassSystem.StandardParams.GenerateInMemory = $True $private:refs = "System.DLL","System.management.dll", $(([appdomain]::currentdomain.getassemblies() |where {($_.fullname -match "system.management.automation")}).location) $ClassSystem.StandardParams.ReferencedAssemblies.AddRange($refs) -Karl |
My System Specs![]() |
| | #2 (permalink) |
| | Re: referencing system.management.automation DLL (or other Gac'd ones) The following command will load assemblies from the GAC, you can experiment with the various static "Load*" methods on the Assembly class to get the exact file/version that you need (i.e. if you're ever looking for a particular revision of System.Management.Automation.dll instead of just the most recent one). PS> [System.Reflection.Assembly]::LoadWithPartialName("System.Management.Automation") GAC Version Location --- ------- -------- True v2.0.50727 C:\WINDOWS\assembly\GAC_MSIL \System.Management.Automation\1.0.0.0__31bf3856ad364e35\System.Man... On Mar 13, 2:27 pm, klu...@xtra.co.nz wrote: > How do you reference DLLs in the gac dynamically? Is there a method to > find a link to the gac'd items? Currently the only way I can seem to > reference this one dynamically to pass to CSharpCodeProvider is by > looking at the location of the currently loaded one with > > $(([appdomain]::currentdomain.getassemblies() |where {($_.fullname > -match "system.management.automation")}).location) > > $ClassSystem.CSharpCodeProvider = new-object > Microsoft.CSharp.CSharpCodeProvider > $ClassSystem.StandardParams = new-object > System.CodeDom.Compiler.CompilerParameters > $ClassSystem.StandardParams.GenerateInMemory = $True > > $private:refs = "System.DLL","System.management.dll", > $(([appdomain]::currentdomain.getassemblies() |where {($_.fullname > -match "system.management.automation")}).location) > > $ClassSystem.StandardParams.ReferencedAssemblies.AddRange($refs) > > -Karl |
My System Specs![]() |
| | #3 (permalink) |
| | Re: referencing system.management.automation DLL (or other Gac'd ones) For System.Management.Automation explicitly, this is what I do: [PsObject].Assembly.Location -- Lee Holmes [MSFT] Windows PowerShell Development Microsoft Corporation This posting is provided "AS IS" with no warranties, and confers no rights. <aaronlerch@gmail.com> wrote in message news:1173834362.309215.180130@y80g2000hsf.googlegroups.com... > The following command will load assemblies from the GAC, you can > experiment with the various static "Load*" methods on the Assembly > class to get the exact file/version that you need (i.e. if you're ever > looking for a particular revision of System.Management.Automation.dll > instead of just the most recent one). > > PS> > [System.Reflection.Assembly]::LoadWithPartialName("System.Management.Automation") > > GAC Version Location > --- ------- -------- > True v2.0.50727 C:\WINDOWS\assembly\GAC_MSIL > \System.Management.Automation\1.0.0.0__31bf3856ad364e35\System.Man... > > > On Mar 13, 2:27 pm, klu...@xtra.co.nz wrote: >> How do you reference DLLs in the gac dynamically? Is there a method to >> find a link to the gac'd items? Currently the only way I can seem to >> reference this one dynamically to pass to CSharpCodeProvider is by >> looking at the location of the currently loaded one with >> >> $(([appdomain]::currentdomain.getassemblies() |where {($_.fullname >> -match "system.management.automation")}).location) >> >> $ClassSystem.CSharpCodeProvider = new-object >> Microsoft.CSharp.CSharpCodeProvider >> $ClassSystem.StandardParams = new-object >> System.CodeDom.Compiler.CompilerParameters >> $ClassSystem.StandardParams.GenerateInMemory = $True >> >> $private:refs = "System.DLL","System.management.dll", >> $(([appdomain]::currentdomain.getassemblies() |where {($_.fullname >> -match "system.management.automation")}).location) >> >> $ClassSystem.StandardParams.ReferencedAssemblies.AddRange($refs) >> >> -Karl > > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| System.Management.Automation.dll missing | PowerShell | |||
| RC2 - where has System.Management.Automation.dll gone? | PowerShell | |||
| Re: System.Management.Automation.dll missing? | PowerShell | |||
| -is [System.Management.Automation.PSCustomObject] | PowerShell | |||
| Getting Exception System.Management.Automation.PSArgumentException | PowerShell | |||