简体   繁体   English

访问器和MissingMethodException

[英]Accessors and MissingMethodException

I am referencing an automatically generated DLL in my code which I can not really control. 我在代码中引用了我无法真正控制的自动生成的DLL。

This file has tons of class-definitions like the one below: 该文件具有大量的类定义,如下所示:

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();
    }
}

This is how I try to use the above class: 这就是我尝试使用以上类的方法:

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

But then I get the following exception: 但是然后我得到以下异常:

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

This whole issue started when we received a new library which the DLLs are generated from. 当我们收到一个生成DLL的新库时,整个问题就开始了。 I really have no idea where to look! 我真的不知道在哪里看! I have regenerated the DLLs and made sure those are the ones actually references in my solution. 我已经重新生成了DLL,并确保这些是我的解决方案中实际引用的那些DLL。

Does anyone have any other idea? 还有其他想法吗? When we run the exact same code on other machines (exact same hw, sw, .NET and windows as I can see) we get no issues. 当我们在其他机器上运行完全相同的代码(如我所见,具有相同的硬件,软件,.NET和Windows)时,我们没有任何问题。 What could that mean? 那是什么意思?

Instance is declared as static . Instance被声明为static Thus it will not show up when you use the instance. 因此,当您使用实例时,它不会显示。

Try this instead when referencing it's code (used TypedValue as sample property): 引用它的代码时,请尝试以下方法(将TypedValue用作示例属性):

DoorDrvrSts.Instance.TypedValue

instead of: 代替:

DoorDrvrSts.TypedValue

Patrick, your answer was certainly helpful but my problem was that wrong DLL was actually being used. 帕特里克(Patrick),您的回答当然有用,但我的问题是实际上使用了错误的DLL。 I used Ms process explorer to find out was what DLL was being used, then I removed that file (which should not have been used in the first place) and generated a new one in the right location och it solved my issues. 我使用Ms process explorer来查找正在使用的DLL,然后删除了该文件(最初不应该使用该文件),并在正确的位置生成了一个新文件,以解决我的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM