Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

referencing system.management.automation DLL (or other Gac'd ones)

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 03-13-2007   #1 (permalink)
klumsy@xtra.co.nz
Guest


 

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 SpecsSystem Spec
Old 03-13-2007   #2 (permalink)
aaronlerch@gmail.com
Guest


 

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 SpecsSystem Spec
Old 03-23-2007   #3 (permalink)
Lee Holmes [MSFT]
Guest


 

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 SpecsSystem Spec
Closed Thread
Update your Vista Drivers Update Your Drivers Now!!

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
RC2 - where has System.Management.Automation.dll gone? =?Utf-8?B?QW5kcmV3IFdlYmI=?= PowerShell 5 01-10-2008 12:43 AM
Re: System.Management.Automation.dll missing? Oisin Grehan PowerShell 2 11-25-2007 09:14 PM
Where can I find System.management.automation.resources.dll Joe G PowerShell 8 09-06-2007 12:34 PM
-is [System.Management.Automation.PSCustomObject] Doug PowerShell 3 04-04-2007 06:36 PM
Getting Exception System.Management.Automation.PSArgumentException Sushil Kumar PowerShell 0 11-14-2006 08:06 AM


Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51