2014-06-10 148 views
1

我在自己生成的代码中引用了一个我无法真正控制的代码。访问器和MissingMethodException

这个文件吨的类定义,像下面这样:

namespace _Outputs.CEEM 
{ 
    public sealed class DoorDrvrSts : SystemVariableBase, ITypedRuntimeValue<int>, IRuntimeValue 
    { 
     public const int Clsd_DoorDrvrSts = 2; 
     public const int Opend_DoorDrvrSts = 1; 
     public const int Ukwn_DoorDrvrSts = 0; 

     public static DoorDrvrSts Instance { get; } 
     public int TypedValue { get; set; } 
     public static int Value { get; set; } 

     protected override void DoInvalidateInstance(); 

     public delegate void ValueChanged(); 
    } 
} 

这是我尝试使用上面的类:

_Outputs.CEEM.DoorDrvrSts.Value = _Outputs.CEEM.DoorDrvrSts.Ukwn_DoorDrvrSts; 

但后来我得到下面的异常:

A .NET exception (MissingMethodException) occured in the module PowerManagement 
Error message: Method not found: 'Void _Outputs.CEEM.DoorDrvrSts.set_Value(Int32)'. 
Throwing method: PowerManagement.DoTest 

当我们收到一个由DLL生成的新库时,整个问题就开始了。 我真的不知道在哪里看!我已经重新生成了DLL,并确保这些实际上是我的解决方案中的参考。

有没有人有任何其他的想法? 当我们在其他机器上运行完全相同的代码时(我可以看到完全相同的hw,sw,.NET和windows),我们没有任何问题。这意味着什么?

回答

0

帕特里克,你的答案是一定的帮助,但我的问题是错误的DLL实际上正在使用。我用Ms process explorer找出是什么DLL被使用,然后我删除该文件(不应该在第一个地方使用),并在正确的位置生成一个新的文件,并解决了我的问题。

1

Instance被宣布为static。因此在使用实例时它不会显示出来。

引用时,试试这个,而不是它的代码(使用TypedValue作为样本属性):中

DoorDrvrSts.Instance.TypedValue 

代替:

DoorDrvrSts.TypedValue 
+0

这是自动生成的代码作为我不能改变的DLL。我只能改变我的使用方式。 – theAlse

+0

@theAlse:检查更新后的答案。 –

+0

@theAlse:需要更多帮助?希望这个答案是足够的。 –

相关问题