http://csharpening.net/?p=989#comment-583 Someone posted that he cant compiled successfully, but after I corrected his code, it works!! The changes are marked as yellow. $da = [System.AppDomain]::CurrentDomain.DefineDynamicAssembly((New-Object System.Reflection.AssemblyName(“dyn”)), [System.Reflection.Emit.AssemblyBuilderAccess]::Save) $dm = $da.DefineDynamicModule(“dyn_mod”, “dyn.dll”) $tokens = $null $compiledBlock = $ast.GetScriptBlock() $SMA = [SYstem.Reflection.Assembly]::LoadWithPartialName(“System.Management.Automation”) $CompiledScriptBlockType.GetMethod(“Compile”, $BindingFlags).Invoke($compiledBlock, @($true)) $lambda.CompileToMethod($method) |
D2I | Anibal.Yeh > D2I | NEWS >