抛出异常:'System.MissingMethodException'
Exception thrown: 'System.MissingMethodException'
我在 4 层的 WinForm 应用程序中工作:
- DAL(数据访问)
- BOL(业务对象)
- BAL(业务访问权限)
- INT(中级访问)。
我正在使用中间层 运行 表示层所需的任何操作,试图使其独立,因为我们可以在 WinForm 中使用它,ASP,等等。
我创建了一个 Class 来执行这些操作,如下所示:
// Clase: ProjectStatusMID
using System.Collections.Generic;
namespace Trevo.FrameWork
{
public class ProjectStatusMID
{
#region Propiedades
private ProjectStatusBOL _Data = new ProjectStatusBOL();
private ProjectStatusBAL _Operations = new ProjectStatusBAL();
private Acciones _Action = Acciones.Nada;
#endregion Propiedades
public ProjectStatusBOL Data
{
get { return _Data; }
set
{
_Data = value;
}
}
public ProjectStatusBAL Operations
{
get { return _Operations; }
set
{
_Operations = value;
}
}
public Acciones Action
{
get { return _Action; }
set
{
_Action = value;
}
}
public int IDProject
{
get { return _Data.IDProject; }
set
{
_Data.IDProject = value;
}
}
public List<Codigos> ProjectsList
{
get { return LoadProjects(); }
}
public ProjectStatusMID()
{
//Load();
}
public void Load()
{
Operations.Consultar(Data);
}
public List<Codigos> LoadProjects()
{
List<Codigos> oRet = new List<Codigos>();
MyProjectsBAL _Operations = new MyProjectsBAL();
MyProjectsBOL _Data = new MyProjectsBOL();
List<MyProjectsBOL> _MyList = _Operations.Lista(_Data);
foreach (MyProjectsBOL o in _MyList)
{
oRet.Add(new Codigos(o.IDProject, o.Project));
}
return oRet;
}
}
}
// Clase: ProjectStatusMID
在前端(在本例中是 WinForm),我们将 class 实例化如下:
ProjectStatusMID OO = new ProjectStatusMID();
因此,调用其中一种方法时出现问题:
parProject.DataSource = OO.LoadProjects();
一切都被引用,应用程序编译没有任何问题,包含 class 的项目是单独项目中解决方案的一部分(与任何其他层一样),但我们有以下错误:
System.MissingMethodException发生
HResult=-2146233069
Message=Método no encontrado:'System.Collections.Generic.List`1 Trevo.FrameWork.ProjectStatusMID.LoadProjects()'。
源=工作负载演示
堆栈跟踪:
zh Trevo.FrameWork.PS_ProjectStatus_Datos.CargarListas()
en Trevo.FrameWork.PS_ProjectStatus_Datos.PS_ProjectStatus_Datos_Load(Object sender, EventArgs e) en C:\Users\fbravo\OneDrive\Particular_Sistemas\WorkLoad\WorkLoadPresentation\ProjectStatus\PS_ProjectStatus_Datos.cs:línea 25
内部异常:
我已经尝试使 class 静态化,重新创建整个应用程序,删除 GAC 等等,但是我花了一周的时间尝试不同的事情。
任何帮助将不胜感激
您必须确保在主 Winforms 应用程序中引用了外部项目 dll
可能是几个问题。最常见的一个是您包含了错误版本的 DLL 库(例如,没有缺少的方法)。最简单的做法是在反编译器(例如 Reflector)中打开 exe 并逐步执行它。
另一个问题可能是位数错误(但可能不是)。
我在 4 层的 WinForm 应用程序中工作:
- DAL(数据访问)
- BOL(业务对象)
- BAL(业务访问权限)
- INT(中级访问)。
我正在使用中间层 运行 表示层所需的任何操作,试图使其独立,因为我们可以在 WinForm 中使用它,ASP,等等。
我创建了一个 Class 来执行这些操作,如下所示:
// Clase: ProjectStatusMID
using System.Collections.Generic;
namespace Trevo.FrameWork
{
public class ProjectStatusMID
{
#region Propiedades
private ProjectStatusBOL _Data = new ProjectStatusBOL();
private ProjectStatusBAL _Operations = new ProjectStatusBAL();
private Acciones _Action = Acciones.Nada;
#endregion Propiedades
public ProjectStatusBOL Data
{
get { return _Data; }
set
{
_Data = value;
}
}
public ProjectStatusBAL Operations
{
get { return _Operations; }
set
{
_Operations = value;
}
}
public Acciones Action
{
get { return _Action; }
set
{
_Action = value;
}
}
public int IDProject
{
get { return _Data.IDProject; }
set
{
_Data.IDProject = value;
}
}
public List<Codigos> ProjectsList
{
get { return LoadProjects(); }
}
public ProjectStatusMID()
{
//Load();
}
public void Load()
{
Operations.Consultar(Data);
}
public List<Codigos> LoadProjects()
{
List<Codigos> oRet = new List<Codigos>();
MyProjectsBAL _Operations = new MyProjectsBAL();
MyProjectsBOL _Data = new MyProjectsBOL();
List<MyProjectsBOL> _MyList = _Operations.Lista(_Data);
foreach (MyProjectsBOL o in _MyList)
{
oRet.Add(new Codigos(o.IDProject, o.Project));
}
return oRet;
}
}
}
// Clase: ProjectStatusMID
在前端(在本例中是 WinForm),我们将 class 实例化如下:
ProjectStatusMID OO = new ProjectStatusMID();
因此,调用其中一种方法时出现问题:
parProject.DataSource = OO.LoadProjects();
一切都被引用,应用程序编译没有任何问题,包含 class 的项目是单独项目中解决方案的一部分(与任何其他层一样),但我们有以下错误:
System.MissingMethodException发生 HResult=-2146233069 Message=Método no encontrado:'System.Collections.Generic.List`1 Trevo.FrameWork.ProjectStatusMID.LoadProjects()'。 源=工作负载演示 堆栈跟踪: zh Trevo.FrameWork.PS_ProjectStatus_Datos.CargarListas() en Trevo.FrameWork.PS_ProjectStatus_Datos.PS_ProjectStatus_Datos_Load(Object sender, EventArgs e) en C:\Users\fbravo\OneDrive\Particular_Sistemas\WorkLoad\WorkLoadPresentation\ProjectStatus\PS_ProjectStatus_Datos.cs:línea 25 内部异常:
我已经尝试使 class 静态化,重新创建整个应用程序,删除 GAC 等等,但是我花了一周的时间尝试不同的事情。
任何帮助将不胜感激
您必须确保在主 Winforms 应用程序中引用了外部项目 dll
可能是几个问题。最常见的一个是您包含了错误版本的 DLL 库(例如,没有缺少的方法)。最简单的做法是在反编译器(例如 Reflector)中打开 exe 并逐步执行它。
另一个问题可能是位数错误(但可能不是)。