WinUI 3如何发布为独立可执行文件

  1. 选择工程模板;
  2. 修改工程文件csproject,加入三行:
    • <WindowsPackageType>None</WindowsPackageType>
    • <WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
    • <EnableMsixTooling>true</EnableMsixTooling>
  3. 命令行生成publish文件夹(注意是在工程目录而不是解决方案目录):
    • dotnet publish -c Release -r win-x64 --self-contained true /p:PublishReadyToRun=true /p:TrimUnusedDependencies=true
  4. 在Windows Sandbox测试。

注意:直接在 Visual Studio 中运行要选 Unpacked 配置。

阅读:0

Vultr 主机端口设置

如果 Vultr 自带的 Firewall 设置不起作用,可采用如下命令行方式:

apt-get install firewalld

#Web server
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --zone=public --add-port=443/tcp --permanent

#允许ping
firewall-cmd --permanent --add-icmp-block-inversion
firewall-cmd --permanent --add-icmp-block=echo-reply
firewall-cmd --permanent --add-icmp-block=echo-request
firewall-cmd --reload

最后注意删除 Vultr 的 Firewall group。

阅读:54

Android Studio编译错误:clang++: error: no such file or directory

Android Studio版本升级后编译原有工程,出现错误:clang++: error: no such file or directory: 'CMakeFiles/native.dir/src/main/cpp/native.cpp.o',尝试过网上建议的修改工程设置等各种方法均无效,最终解决办法:

$ rm -Rf .externalNativeBuild/

阅读:92

强制Android Studio使用本地文档

使用Android Studio时发现一个怪现象,即使下载了SDK对应的文档,每次按F1时也会出现Fetching Documentation...,等待很久才能看到文档。研究后在Stack Overflow找到了答案,经测试可行:

Delete all javadoc paths from jdk.table.xml. Path to this file on OS X: /Users/.../Library/Preferences/AndroidStudio.../options/jdk.table.xml
--> Delete all of these and all occurrences -->

<javadocPath>
<root type="composite">
<root type="simple" url="http://developer.android.com/reference/" />
</root>
</javadocPath>

继续阅读强制Android Studio使用本地文档

阅读:110

Unity UI的ScrollRect中的Button点击不灵敏的问题

大家有没有发现使用uGUI的游戏发布到手机后,点击放在ScrollRect中的按钮有时候会不起作用?这个问题的原因是因为ScrollRect滚动阈值设置得过于灵敏,一旦手指点击时轻微移动导致了滚动,就不会触发OnClick事件了。 继续阅读Unity UI的ScrollRect中的Button点击不灵敏的问题

阅读:124

mysql数据库故障修复一例

某线上服务器的mysql突然崩溃后,重启一直失败。查看mysql的error.log发现如下错误信息:

InnoDB: Serious error! InnoDB is trying to free page 716
InnoDB: though it is already marked as free in the tablespace!
InnoDB: The tablespace free space info is corrupt.
InnoDB: You may need to dump your InnoDB tables & recreate the whole
InnoDB: database!

尝试了各种修复方法均告失败,看来只能重建数据库了。

首先解决无法启动的问题(参见http://dev.mysql.com/doc/refman/5.5/en/forcing-innodb-recovery.html的说明):

先添加如下设置到my.cnf:

# vi /etc/mysql/my.cnf

[mysqld]
innodb_force_recovery = 1

保存my.cnf退出vi后重启mysql:

# service mysql start

但重启依然失败。

按上述官方文档提示,尝试提高recovery级别到2:

[mysqld]
innodb_force_recovery = 2

这次重启成功了,并且可以正常查询,但此时mysql处于只读状态,无法做update、delete等写操作。下面开始尝试先备份再恢复全部数据库。

1、备份全部数据库

mysqldump -uroot -p -AER > /root/recovery_dump.sql

2、删除全部数据库

mysql> SET FOREIGN_KEY_CHECKS=0;
mysql> DROP DATABASE db1;
mysql> DROP DATABASE db2;
...

如果数据库太多,可使用如下命令批量删除。注意:<password>应该替换为真实密码。

# mysql -uroot -p<password>  -e "show databases" | grep -v Database | grep -v mysql| grep -v information_schema| grep -v test | grep -v OLD |gawk '{print "drop database " $1 ";select sleep(0.1);"}' | mysql -uroot -p<password>

3、停止mysql。注意应该禁用innodb_fast_shutdown,确保mysql完全停止。

# mysql -uroot -p -e "SET GLOBAL innodb_fast_shutdown = 0"
# service mysql stop

继续阅读mysql数据库故障修复一例

阅读:83

C#中的抽象基类(Abstract Base Class)和接口(Interface)

抽象基类和接口有很多类似的地方,那么我们在软件架构的过程中如何决定该用抽象基类还是接口呢?Stack Overfollow上有一个回答总结得比较好,虽然只有短短几十个字:

Abstract classes and interfaces are semantically different, although their usage can overlap.

An abstract class is generally used as a building basis for similar classes. Implementation that is common for the classes can be in the abstract class.

An interface is generally used to specify an ability for classes, where the classes doesn't have to be very similar.

可以这么理解:基类是爹,接口是能力。爹只能有一个,而且他决定了你是什么,但能力可以有多个。

应该考虑使用抽象基类的场景:

  • 逻辑上是同一类的东西(is a...);
  • 有需要实现的公共方法或属性;
  • 需要序列化的成员类型(因为接口无法序列化);

阅读:144