![](/img/trans.png)
[英]System.TypeLoadException in System.Windows.Forms.OpenFileDialog (C#)
[英]System.TypeLoadException in System.Windows.Forms.dll
我收到System.Windows.Forms.dll中发生的“ System.TypeLoadException”。 这是错误消息的其余部分。
附加信息:由于方法'.ctor'没有实现(没有RVA),因此无法从程序集'DataTeamMailerCSharp,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = null'中加载类型'DataTeamMailerCSharp.NewReport'。
这是正在发生的课程。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace DataTeamMailerCSharp
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new mainGUI());
}
}
}
错误发生在这里:
Application.Run(new mainGUI());
为了回应此评论,我最近在我的一门课上做了更改。 我正在尝试XML序列化,在无参数构造函数中,它告诉我它需要主体或外部,局部和其他东西。 这是类代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataTeamMailerCSharp
{
[Serializable] class NewPerson
{
public string personName { get; set; }
public string personEmail { get; set; }
public string personReports { get; set; }
public NewPerson(string name, string email, string reports)
{
personName = name;
personEmail = email;
personReports = reports;
}
private extern NewPerson();
}
}
可以是private extern NewPerson();
这是现在造成的吗?
使用XmlSerializer
进行序列化/反序列化时,需要一个公共的,无参数的默认构造函数。 加一个...
namespace DataTeamMailerCSharp
{
[Serializable]
public class NewPerson
{
public string personName { get; set; }
public string personEmail { get; set; }
public string personReports { get; set; }
public NewPerson(string name, string email, string reports)
{
personName = name;
personEmail = email;
personReports = reports;
}
public NewPerson() { } // for serialization
// private extern NewPerson(); -- not needed
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.