是否有任何特定的理由使用c ++样式的双冒号'::'?为什么不使用像c#这样的简单点?
在我的power shell脚本中,我正在加载一个自定义程序集,然后通过实例化该程序集的类New-Object.
Assembly.LoadFile()执行成功,但New-Object语句给出了波纹管异常.
New-Object : Exception calling ".ctor" with "1" argument(s): "Could not load file or assembly 'MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of i
ts dependencies. The system cannot find the file specified."
Run Code Online (Sandbox Code Playgroud)
脚本:
[System.Reflection.Assembly]::LoadFile("MyAssembly.dll")
$a=New-Object MyAssembly.MyClass -ArgumentList "arg1"
Run Code Online (Sandbox Code Playgroud)
此自定义程序集仅引用以下程序集
System
System.Core
System.Runtime.Serialization
System.Xml.Linq
System.Data
System.Xml
Run Code Online (Sandbox Code Playgroud)
我尝试显式加载System.Runtime.Serialization dll,如下所示.但同样的例外
[System.Reflection.Assembly]::Load("System.Runtime.Serialization, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
Run Code Online (Sandbox Code Playgroud)
任何的想法?