English 中文(简体)
Powerhell 2.0 停机坪例外;不能装载文件或组装[复制]
原标题:Powershell 2.0 Runtime exception; could not load file or assembly [duplicate]

我试图纠正的情景是,在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?

问题回答

。 NET组件没有装上这条路。 app子是电壳安装了ir子,你真的不想复制你在那里的集会。 我建议打上主角。 大会续会。 当《刑法》委员会能够找到一个集会时,就开始举行这一活动,此时,你可以为有关集会提供全部途径。 查阅SO post,用于更多的信息。





相关问题
handling exceptions IN Action Filters

Is there a better way to handle exceptions that occur inside an Action Filter itself in ASP .NET MVC? There re 2 ways I can think of at the moment. Using a try catch and setting the HTTP Status ...

既可捕获,又可举出例外。

我有一种办法,可以进入亚洲开发银行,因此,我国的亚行在多瑙河航道中的所有 st子都位于一个试捕区。 它正在追捕Kexception

Cross compiler exception handling - Can it be done safely?

I am doing some maintenance on a C++ windows dll library that is required to work with different VC++ compilers (as I don’t want to address different mangling schemes). I have already eliminated any ...

File Handling Issue

I am developing a tool in c#, at one instance I start writing into a xml file continuously using my tool,when i suddenly restart my machine the particular xml file gets corrupted, what is the reason ...

Watch a memory location/install data breakpoint from code?

We have a memory overwrite problem. At some point, during the course of our program, a memory location is being overwritten and causing our program to crash. the problem happens only in release mode. ...

Unit Test for Exceptions Message

Is there a simple (Attribute-driven) way to have the following test fail on the message of the exception. [TestMethod()] [ExpectedException(typeof(ArgumentException))] public void ExceptionTestTest() ...

热门标签