关于IIS调用Kakasi.NET.Interop库导致进程结束,解决方法

缘起:公司最近的给了个对接任务,需要将用户输入Japanese 转换为 Romaji,因此用到了开源库Kakasi.NET.Interop,在通过IIS调试该库的过程中,出现了进程被无端结束,经咨询,IIS不能直接调用该库,会导致该库中一些重要文件无法被关联到一起,从而致使当前进程被结束,下面这是回复的内容:

/* IMPORTANT:
                The native libkakasi.dll library will look for these 2 dictionary files:
                
                itaijidict
                kanwadict

                When running as a web application, the search path used by the library will be the same as the
                running host process (e.g: iisexpress.exe, w3wp.exe) and not the path of the running web application.
                
                If it can't find any one of these file, the library will exit the running process, which is far from ideal.
                
                It's possible to set 2 environment variables that the native library will use instead of the executing path.
                
                KANWADICTPATH for the full path to the dictionary file: kanwadict
                ITAIJIDICTPATH for the full path to the dictionary file: itaijidict

                Make sure these variables are set in the running host process otherwise it won't work and any call to
                the native library will kill the running process.                
            */

通过配置环境变量的方法未验证,而是采取另一种执行命令行的方式去解决,解决思路如下:
1.更改Kakasi.NET.Interop项目为控制台应用程序,并添加主函数入口,通过将参数注入主函数中
2.翻译注入主函数中的参数,并保存入文件
3.读取文件内容

需要注意的地方:在执行cd命令时注意盘符问题,以及传参问题

string cmd =@"C:&cd C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC&vcvarsall.bat";

string cmd =@"D:&cd D:\Program Files (x86)\Microsoft Visual Studio 10.0\VC&vcvarsall.bat";
string cmd = @"D:&cd D:\Program Files (x86)\Kakasi.NET.Interop\bin&Kakasi.NET.Interop.exe args1 args2";

参考资料:
C#程序调用cmd.exe执行命令

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值