日期:2014-05-20  浏览次数:20814 次

怎么解决这个错误 ?"An object reference is required for the nonstatic field"
下面是   Vendor.cs文件的内容

开始在开始处声明
private     AcmeReaderLayer   reader1;
//   AcmeReaderLayer   是一个类文件

函数里的一段代码:

byte[]   aa   =   new   byte[36];
                                ApplyPropertyProfileCommand   applyPropertyProfileCommand   =   (ApplyPropertyProfileCommand)command;
                              if   (null   !=   applyPropertyProfileCommand.PropertyProfile)
                                {
                                foreach   (KeyValuePair <PropertyKey,   object>   property   in   applyPropertyProfileCommand.PropertyProfile)
                                {
                                        bool   error   =   false;                                        
                                        try
                                        {
                                              aa= setAppProperty((AcmeReaderLayer)reader1,   (string)property.Key.PropertyName,   (string)property.Value);
  在这错误:     “   Error 3 An   object   reference   is   required   for   the   nonstatic   field,   method,orproperty   Microsoft.Rfid.Reader.Driver.Acme.VendorHelper.setAppProperty(Microsoft.Rfid.Reader.Driver.Acme.Framework.AcmeReaderLayer,   string,   string) ' “
                                        }
                                        catch   (Exception   e)
                                        {
                                                throw   new   ConnectionFailedException( "SetProperty   to   reader   failed ",   e,   " ",   null);
                                        }
                                }

setAppProperty函数声明如下:
internal     byte[]   setAppProperty(AcmeReaderLayer   reader1,   string   propertyName,   string   propertyValue)