How to use add-type with -path and also -language csharpversion3?
问题 I've been using add-type in Powershell to dynamically compile in some C# classes I want to use. Works great except it's 2.0 only. I just discovered the -language csharpversion3 option, but it does not work with -path . How can I work around this? [Edit: removed bit about ReadAllText - I was mistaken.] 回答1: Here's the workaround: read the file as text. $script = [io.file]::readalltext($scriptpath) add-type $script -lang csharpversion3 I might as well paste in the rest and make this answer