C# 库开发记录

  json转化编码设置 return JsonConvert.SerializeObject(th […]

 

json转化编码设置

return JsonConvert.SerializeObject(this, new JsonSerializerSettings()
{
    StringEscapeHandling = StringEscapeHandling.EscapeNonAscii // 此处可更改编码
});

 

 

字符串编码转换

string str = "";
byte[] utf8Bytes = Encoding.UTF8.GetBytes(str);  // 将字符串按UTF-8编码方式转换为字节数组
string utf8Str = Encoding.UTF8.GetString(utf8Bytes);  // 将字节数组按UTF-8编码方式转换为字符串

 

string转换为Intptr

var bytes = Encoding.UTF8.GetBytes(ToJson());
IntPtr ptr = Marshal.AllocHGlobal(bytes.Length);
Marshal.Copy(bytes, 0, ptr, bytes.Length);

 

 

 

无法加载 DLL“xxx.dll”: 找不到指定的模块 (异常来自 HRESULT:0x8007007E)

用depends工具查看dll依赖那些库,将库文件拷贝到运行目录。(我的解决方式)

一般情况是库的版本不匹配的原因。

其他解决方式

https://blog.csdn.net/m0_56651882/article/details/129672344

1、 dll生成的平台(x64/x86/AnyCpu),与我们的工程的平台不符合;
2、 所引用的dll所在路径不对,尝试放在.exe所在目录;
3、 所引用的dll也引用了其他dll,但是在本次引入中并未引入。

 

C#回调函数定义

public delegate string HttpRequestHandler(string data);

 

版权声明
文章标题:C# 库开发记录
文章链接:https://blog.chiyuba.com/houduanjishu/483.html
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布,转载或引用请注明出处。
温馨提示:本文最后更新于 2023年6月12日,部分内容可能存在时效性,请注意甄别。

相关推荐

更多教程
C++操作SQLite数据库操作实例:查询、增加、修改、删除 后端技术 C++操作SQLite数据库操作实例:查询、增加、修改、删除

  简介:在C++中使用SQL...

51 浏览
electron开发:throw new Error(‘Electron failed to install correctly, please delete node_modules/electron and try installing again’); 后端技术 electron开发:throw new Error(‘Electron failed to install correctly, please delete node_modules/electron and try installing again’);

前言 最近开发QQ机器人遇到electr...

61 浏览
github中文项目最新榜单大全 其他 github中文项目最新榜单大全

中文榜单 https://github....

23 浏览

评论