我试图纠正的情景是,在C#编成时发现有lls,但在执行C#码时没有发现。 这就是第2号权力。 我们的政策是不要使用全球艾滋病理事会。 单体功能中的c#代码类似:
function functionDef
{
[System.Reflection.Assembly]::LoadFrom("c:myDirfunc1.dll")
[System.Reflection.Assembly]::LoadFrom("c:myDirfunc2.dll")
$ref = @("c:myDirfunc1.dll","c:myDirfunc2.dll")
$cCode = @"
using System;
using func1;
using func2;
namespace serializedDef
{
public class defSerialization
{
public defSerialization () {}
<#
method and properyty defs not included
#>
public double setSpec {
set { computeDef(value)}
get {return spefDef}
}
private double computeDef ( double value)
{
<# calls to methods in DLLS loaded above
#>
}
}
}
"@
add-type -ReferencedAssemblies $ref -TypeDefinition $cCode -passthru - Language CSharpVersion3 | out-null
}
援引这一职能时,将编成单法,其错误之处不一。
我在两份参考数字中加上“最低收入标准”的路面值。 在另一个地点安装了第3条“DLL”路面,这条路也添加到“env:path”。 这两条道路上的许可对每个人开放,以供测试。
我然后将C#代码视为一个新目标:
$myObject = new-object serializedDef.defSerialization
当我援引职能时:
$myObject.setSpec = 35.5
我发现错误:
Exception setting "setSpec": "Could not load file or assmbly
func1 , Version=1.0.0.0, Culture=neutral, PublicKeyToken=f0a7c34216660f47 or one of its dependencies. The system cannot find the file specified."
At line:1 char:11
+ $myObject. <<< setSpec = 35.5
+ CategogyInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifedErrorId : PropertyAssignmentException
My understanding is that the error is likely is related to a method or the like that one of the DLLs is referencing which can not be found. How do I track this down?