- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我有一个用户报告了这个异常。我在这里和其他地方的研究表明这是一个静态构造函数错误。有关的类包含许多已初始化的静态字段。我认为它是其中之一,但我不确定如何找到它。该建议似乎是在静态构造函数中包含一个 try/catch block 。如所写,没有明确的静态构造函数。
我在想我应该写一个显式静态构造函数,将静态字段的初始化移到其中并将它们包装在 try/catch block 中。我知道我可以尝试这个,但我不会出现错误,我想向用户发送一个修改后的可执行文件来尝试。我的应用程序确实记录了错误,所以如果在静态构造函数中捕获到异常,我应该从他那里得到一个日志。
类的相关(我希望)部分在这里(它实际上不是我的代码,但我可以根据需要修改它):
[Serializable]
public class PText : PNode, ISerializable {
//comments elided by edit for brevity
#region Fields
public const int PROPERTY_CODE_FONT = 1 << 18;
public const int PROPERTY_CODE_TEXT = 1 << 17;
public static Font DEFAULT_FONT = new Font("Arial", 12);
protected static readonly object PROPERTY_KEY_FONT = new object();
protected static readonly object PROPERTY_KEY_TEXT = new object();
private static Graphics GRAPHICS = Graphics.FromImage(new Bitmap(1, 1));
[NonSerialized]
private Color brushColor;
private bool constrainHeightToTextHeight = true;
private bool constrainWidthToTextWidth = true;
private Font font;
[NonSerialized]
private Color penColor;
[NonSerialized]
private StringFormat stringFormat = new StringFormat();
private String text;
[NonSerialized]
private Brush textBrush;
#endregion Fields
#region Constructors
public PText() {
textBrush = Brushes.Black;
}
public PText(String aText)
: this() {
Text = aText;
}
protected PText(SerializationInfo info, StreamingContext context)
: base(info, context) {
textBrush = PUtil.ReadBrush(info, "textbrush");
TextAlignment = (StringAlignment)info.GetValue("alignment", typeof(int));
}
#endregion Constructors
.......
最佳答案
回答你的问题,你的想法很好。在可能抛出的行周围放置一个 try/catch,然后在它变成 TypeInitializationException 之前记录错误。
或者,更改为使用 Lazy - 这会将异常更改为首次访问的位置。这可能对您有用,也可能没有用,但它帮助我调试了类似的问题。
关于c# - 如何最好地调试 "The type initializer for xx class threw an exception",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9006926/
我住在荷兰,货币是用逗号 (,) 而不是点 (.)即 14.95 的 feeds 被解释为数字而不是 14.95 欧元 有没有可以解决这个问题的LINUX命令(sed?)?所以14.95变成了14,9
我想问: 我有两个表employee,其中包含字段ID、Fullname、email...和表task 包含字段 name_task、list_employee... 使用字段list_employe
请看下面的测试数据。我想获取 avgtime (=timeonsite/visits) 并在 mysql 中显示为“xx:xx:xx”结果。我怎样才能得到它? SET FOREIGN_KEY_CHEC
我必须处理一个大文件(几 MB)并从中删除带有时间标记的注释。一个例子: blablabla 12:10:40 I want to remove this blablabla some more e
所以我有这些数据直接从 iTunes 复制/粘贴: Excel 具有“XX:XX:00”格式,即“hh:mm:ss”,但您可以想象,它更像“mm:ss:00”。音乐时间不长! 由于这不是直接的单元格格
我有一个对象列表,我想使用 Option.Numero_Reference 属性对其进行排序。 Numero_reference 是一个 xx.xx.xx 格式的字符串 有没有办法按 xx 组排序?
我正在尝试部署 nginx - ingress kubectl run nginx --image=nginx kubectl get pod NAME
我有一个日期“2014-07-02 20:57:38 +0000”,我想将它的格式设置为“今天晚上 8:57”。我希望如果一个字符串是昨天,则将其显示为“昨天上午 9:00”。如果既不是今天也不是昨天
目前我使用的是Apache http components client V4.3.5。在我的例子中,我可以上传小文件(1kb),但是当我运行代码并得到异常“org.apache.http.NoHtt
我在 Linux (RHEL 7) 中运行 HTTPS 服务器。我一启动服务器就收到以下错误。 2019/09/04 15:46:16 http: TLS handshake error from x
我正在参加 CTF 挑战赛,该挑战赛有一个链接,如下所示:46.XXX.XX.XX:8008/ 如果我打开该页面中的开发者工具,我可以找到一个小程序,其属性代码值为“mPage.class”
你好 我想每隔 X 小时在我的程序中运行一个方法,该怎么做?我正在谷歌搜索,但什么也没有:/ 最佳答案 你可以考虑Quartz . 它是在 java 中运行的某种 cron。不过我承认,如果您只想安排
我正在尝试检查 NSString 是否为特定格式。 日:日:日。我在想 NSRegularExpression。有点像 /^(\d)\d:\d\d:\d\d)$/? 最佳答案 你有没有试过这样的事情:
我收到错误 git 存储库的 RSA 主机 key 不在已知主机列表中。当我使用存储库 URL 作为我的 git 克隆 URL 运行 jenkins 作业时。 我尝试在运行作业的主机中克隆相同的存储库
我有一个计数器,每 1 秒计数一次,并将 1 添加到 int。 问题 如何格式化我的字符串,使计数器看起来像这样: 00:01:23 代替: 123 我尝试过的事情 到目前为止我尝试过的事情: for
ERROR 2003 (HY000): Can't connect to MySQL server on 'xx.xx.xx.xx.' (60) 我在尝试远程连接到此服务器时收到此错误。我最近硬重启了
我正在尝试将一些数据从客户端浏览器插入到 AWS 服务器上的 MySQL 数据库。 该代码在 godaddy 上运行,因此看起来像是权限/安全问题。 $servername = "xx.xx.xx.x
我想知道是否有标准方法可以以“UTC+XX:XX”或“UTC-XX:XX”格式返回设备的当前时区? 基于格式化 NSDate 我知道可以在“ZZZZ”的帮助下获得当前时区,它给出“GMT-08:00”
我的 JVM 有 -server 选项,我相信它使 JVM 能够使用 C2 编译器,这意味着用于服务器应用程序,这些应用程序往往比客户端应用程序运行时间更长。但是,GRAAL JIT(由 -XX:+U
public void colortemperatureJSliderStateChanged(ChangeEvent event) { fahrenheitdegree = colortemp
我是一名优秀的程序员,十分优秀!