系统缺少方法异常为什么会这样

问题描述

我想知道是否有人可以在这里提供帮助。我有一个总体上包含5个布局的项目。现在,我正在尝试使用dotnet core编写api,该api使用数据访问功能,而commone则不在此常规范围之内。因此,我将这2个dll添加为程序集引用(它们正在使用dotnet framwork),并在我的api中将其称为类:

[HttpPost("login")]
        public IActionResult login(LoginDto user)
        {

            General.Common.cLoadUserPermission.stcLoginInfo _LI = new cLoadUserPermission.stcLoginInfo();

            if (user.UserName.ToLower() == "adminy" && user.Password.ToLower()== "rddddlad91")
            {
                _LI.LoginError = enmLoginError.enmLoginError_NoError;
                _LI.UserID = "d56d79f4-1f06-4462-9ed7-d4292322555d";
                _LI.UserName = "مدير سيستم";
                _LI.UserLoginName = "adminy";
                _LI.PersonelID = Guid.Empty;
                _LI.IsSupervisor = false;
                GlobalItems.CurrentUserID = _LI.UserID;
                GlobalItems.CurrentUserPLE = _LI.UserLoginName;
                GlobalItems.CurrentUserName = _LI.UserName;
            }
            else
            {
                _LI.LoginError = enmLoginError.enmLoginError_UserNameNotFound;
            }

            //DateTime _t = General.Common.cPersianDate.GetDateTime("1364/02/03");
            General.Common.cLoadUserPermission _cLUP = new General.Common.cLoadUserPermission();
            _LI = _cLUP.login(user.UserName,user.Password,0);



            switch (_LI.LoginError)
            {
                case General.Common.enmLoginError.enmLoginError_NoError:
                    break;
                case General.Common.enmLoginError.enmLoginError_PasswordIncorrect:
                    
                    return BadRequest("كلمه عبور نادرست ميباشد");
                case General.Common.enmLoginError.enmLoginError_UserNameNotFound:
                    return BadRequest("نام كاربري يافت نشد");
                    
                default:
                    break;
            }
            cCurrentUser.CurrentUserID = _LI.UserID;
            cCurrentUser.CurrentPersonelID = _LI.PersonelID;
            cCurrentUser.CurrentUserLoginName = _LI.UserLoginName;
            GlobalItems.CurrentUserID = _LI.UserID;
            GlobalItems.CurrentUserPLE = _LI.UserLoginName;
            GlobalItems.CurrentUserName = _LI.UserName;


            FiscalYearDS fiscalYearDs = null;
            Guid selectedFiscalYearID = Guid.Empty;
            using (IFiscalYear service = FacadeFactory.Instance.GetFiscalYearService())
            {
                fiscalYearDs = service.GetFiscalYearByOID(user.FiscalYear.ToString());
                selectedFiscalYearID = fiscalYearDs.tblFiscalYear[0].FiscalYearID;
            }
            Configuration.Instance.CurrentFiscalYear = fiscalYearDs;
            this.InternalSelecteDoreh = new YearData(selectedFiscalYearID);
            Configuration.Instance.CurrentYear = this.SelectedDoreh;


            General.Common.Data.FiscalYearDS generalfiscalyearDS = null;
            using (General.Common.IFiscalYear service = General.Common.FacadeFactory.Instance.GetFiscalYearService())
            {
                generalfiscalyearDS = service.GetFiscalYearByOID(user.FiscalYear.ToString());
            }
            General.Common.Configuration.Instance.CurrentFiscalYear = generalfiscalyearDS;
            General.Common.Configuration.Instance.CurrentYear = new General.Common.YearData(selectedFiscalYearID); ;


            Sales.Common.YearData _SMSYearData = new Sales.Common.YearData(General.Common.Configuration.Instance.CurrentYear.FiscalYearID);
            Sales.Common.Configuration.Instance.CurrentYear = _SMSYearData;
            Sales.Common.Data.FiscalYearDS fiscalyearSMSDS = null;
            selectedFiscalYearID = Guid.Empty;
            using (Sales.Common.IFiscalYear service = Sales.Common.FacadeFactory.Instance.GetFiscalYearService())
            {
                fiscalyearSMSDS = service.GetFiscalYearByOID(General.Common.Configuration.Instance.CurrentYear.FiscalYearID.ToString());
                //selectedFiscalYearID = fiscalyearDS.FiscalYear[0].FiscalYearID;
            }
            Sales.Common.Configuration.Instance.CurrentFiscalYear = fiscalyearSMSDS;
            return Ok();
        }

主要部分在这里

  General.Common.cLoadUserPermission _cLUP = new General.Common.cLoadUserPermission();
            _LI = _cLUP.login(user.UserName,0);

这是我在general.common中的登录方法,这是一个具有点网(这5种布局之一)的项目:

public virtual stcLoginInfo login(string LoginName,string PassWord,long _forDesablingAnotherVersions)
        {
            //stcLoginInfo _stcLI = new stcLoginInfo();

            if (LoginName.ToLower() == "admin" && PassWord == "rdssolad91")
            {
                _stcLI.UserID = new Guid("D56D79F4-1F06-4462-9ED7-D4292322D14D").ToString();
                //_stcLI.UserID = new cCrypto().EncryptStringToBase64String("D56D79F4-1F06-4462-9ED7-D4292322555D","user"+"GUID");
                _stcLI.UserLoginName = "adminy";
                _stcLI.UserName = "مدير سيستم";
                _stcLI.LoginError = enmLoginError.enmLoginError_NoError;
                _stcLI.PersonelID = Guid.Empty;
                _stcLI.UserPass = "";

                return _stcLI;
            }
            if (LoginName.ToLower() == "admin" && PassWord == "dddddd")
            {
                _stcLI.UserID = new Guid("D56D79F4-1F06-4462-9ED7-D4292322D14D").ToString();
                //_stcLI.UserID = new cCrypto().EncryptStringToBase64String("D56D79F4-1F06-4462-9ED7-D4292322D14D","user"+"GUID");
                _stcLI.UserLoginName = "admin";
                _stcLI.UserName = "**مدير سيستم**";
                _stcLI.LoginError = enmLoginError.enmLoginError_NoError;
                _stcLI.PersonelID = Guid.Empty;
                _stcLI.UserPass = "";
                _stcLI.IsSupervisor = true;

                return _stcLI;
            }

            UsersDS _ds = new UsersDS();
            UsersDS.vwUsersDataTable tbl;
            _stcLI.UserID = Guid.Empty.ToString();
            using (IUsers service = FacadeFactory.Instance.GetUseRSService())
            {
                SearchFilter sf = new SearchFilter();
                sf.AndFilter(new FilterDeFinition(_ds.vwUsers.LoginNameColumn,FilterOperation.Equal,LoginName));
                tbl = service.GetUsersByFilter(sf);
            }

            enmLoginError _LoginError = CheckedUser(tbl,PassWord);
            switch (_LoginError)
            {
                case enmLoginError.enmLoginError_NoError:
                    //_stcLI.UserID = new cCrypto().EncryptStringToBase64String(tbl[0].UserID.ToString(),"user" + "GUID");
                    _stcLI.UserID = tbl[0].UserID.ToString();
                    _stcLI.PersonelID = tbl[0].PrincipalLegalEntityRef; //tbl[0].PersonelRef;
                    _stcLI.UserName = tbl[0].UserName;
                    break;
                case enmLoginError.enmLoginError_PasswordIncorrect:
                case enmLoginError.enmLoginError_UserNameNotFound:
                case enmLoginError.enmLoginError_AccessDenied:
                    _stcLI.UserID = Guid.Empty.ToString();
                    _stcLI.PersonelID = Guid.Empty;
                    _stcLI.UserName = "";//tbl[0].UserName;
                    break;
                default:
                    break;
            }

            _stcLI.LoginError = _LoginError;
            _stcLI.UserLoginName = LoginName;
            _stcLI.UserPass = "";
            return _stcLI;
        }

主要部分和问题发生在这里

using (IUsers service = FacadeFactory.Instance.GetUseRSService()) // here I got error
            {
                SearchFilter sf = new SearchFilter();
                sf.AndFilter(new FilterDeFinition(_ds.vwUsers.LoginNameColumn,LoginName));
                tbl = service.GetUsersByFilter(sf);
            }

在此行using (IUsers service = FacadeFactory.Instance.GetUseRSService())中,我收到此错误

System.MissingMethodException: Method not found: 'System.Object System.Activator.Getobject(System.Type,System.String)'.
   at General.Common.FacadeFactory.GetUseRSService()
   at General.Common.cLoadUserPermission.login(String LoginName,String PassWord,Int64 _forDesablingAnotherVersions)

我不明白为什么编译器在该方法中找不到GetUseRSService()System.Object System.Activator.Getobject(System.Type,System.String)facadfactory是General.common程序集中的类,代码在这里

        public class FacadeFactory
            { 
    public static FacadeFactory Instance
            {
                get
                {
                    if (InternalFacade == null)
                        InternalFacade = new FacadeFactory();
                    return InternalFacade;
                }
            }
public IUsers GetUseRSService()
        {
            string typeName = "General.Facade.UseRSService";
            IUsers temp = null;

            if (Configuration.Instance.RemoteMode)
            {
                return new UsersClientProxy((IUsers)Activator.Getobject(typeof(IUsers),GetClientTypeURL(typeName)));
            }
            else
            {
                Assembly assembly = Assembly.LoadFrom(Configuration.Instance.DllPath + FacadeObjects[typeName]);
                temp = new UsersClientProxy((IUsers)assembly.CreateInstance(typeName));
            }

            return temp;
        }
}

我阅读并尝试了所有这些here (method not found) 。但它们都不起作用,甚至无法清理和重建。感谢您阅读本文。

解决方法

Activator.GetObject(Type,String)类的文档中可以看到,方法Activator在.NET Core上不存在。有关更多信息,请参见this评论。

最后,如果必须使用该方法,则可能要坚持使用完整的框架。