![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
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.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | ResolveEventHandler and PowerShell I am attempting to write some PowerShell scripts to help reflect over some ..NET assemblies. In order to enumerate the types of the loaded assemblies I need to be able to handle the AppDomain.ReflectionOnlyAssemblyResolve event which is of the delegate ResolveEventHandler with the following signature: public Assembly ResolveEventHandler(object sender, ResolveEventArgs $e) I know that $_ contains the ResolveEventArgs, but I can't seem to find a suitable syntax to bind a script block to this delegate. I can only assume that the problem is due to the return value of the delegate. I have tried the following syntaxes: $handler = [ResolveEventHandler] { return $null; } $handler = [ResolveEventHandler] { return [Reflection.Assembly]$null; } $handler = [ResolveEventHandler] { return [Reflection.Assembly]::GetCurrentAssembly() } All three fail that the script block could not be bound to the target method. Is there an appropriate syntax for handling this kind of event that I am missing? Thanks, Justin |
| | #2 (permalink) | ||||||||||||
| Guest | Re: ResolveEventHandler and PowerShell On Mar 15, 2:29*pm, Justin Spindler <jspind...@xxxxxx> wrote:
Unfortunately this syntax is not supported. The event support in v1 is very basic, and can only handle void type delegates, and synchronous events at that. The AssemblyResolve event is async and non-void as you can see. Because async events are invoked on a non-powershell thread, there is no runspace available to run the script because the default runspace is kept in thread-local storage (TLS). I wrote an eventing snapin for v1 that can handle async and sync events by using background queue, but unfortunately it cannot handle non-void delegates either. - Oisin | ||||||||||||
| |
| |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Installing PowerShell dependent features on W2K8 with PowerShell CTP | Greg Wojan | PowerShell | 14 | 05-16-2008 08:15 AM |
| when run powershell script as windows service ,powershell fail | powershell fail on winodws 2008 | PowerShell | 6 | 01-15-2008 03:20 PM |
| Powershell Plus - Free for non commercial Use and Powershell Analyzer1.0 released | Karl Prosser[MVP] | PowerShell | 2 | 12-12-2007 12:43 PM |
| Automatic PowerShell Error Parsing in PowerShell Analyzer and PowerShellPlus | Karl Prosser[MVP] | PowerShell | 0 | 11-14-2007 02:32 AM |
| PowerShell Leaders Join Forces and offer a pre-release version of PowerShell for 50% off the retail value | klumsy@xtra.co.nz | PowerShell | 0 | 06-19-2007 02:42 PM |