-
-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When the path contains Chinese characters, the application fails to run. #232
Comments
Could you give me some examples. |
thanks for your reply. My Code: static void Main(string[] args)
{
var data = new { a = 1, b = 2 };
Console.WriteLine(JsSum(data).Result);
Console.ReadLine();
}
static async Task<int> JsSum(dynamic data)
{
string jsCode = $"function sum(a,b){{\r\n return a+b;\r\n}}\r\nreturn function (data, callback) {{\r\n var result = sum(data.a, data.b);\r\n callback(null, result);\r\n }}";
Func<object, Task<object>> ExecJs = Edge.Func(jsCode);
int result = Convert.ToInt32(await ExecJs(data));
return result;
} If the path does not contain any English characters, it can output correctly. Otherwise, the application will exit directly. When I run it using CMD, it outputs the following content. This issue appears to be caused by Chinese character encoding problems. I have debugged the code in your EdgeJs.cs and found no issues. The problem seems to occur when calling libnode.dll during NodeStar execution, leading to encoding issues. |
I thought this issue was already fixed by one of old PRs, let me take a closer look. |
I am getting a different exception, what version of nuget are you using? Old one is called
|
Found PR that was supposed to fix the problem: tjanczuk/edge#555. Maybe it did not fix all the issues and some characters are still not supported. |
Depending on what kind of non-english characters I use in path it blows up with different exceptions. Not sure it can be fixed very easily. |
The project framework is .NET Framework 4.8, and the Edge.js version is 9.3.0.0. I have also tried integrating the latest code directly into the project, but the same issue persists. I believe that solving this problem might require recompiling libnode.dll. Here is the relevant code: The argv parameters print correctly, so the issue must be with the nodeStart function. |
I am using EdgeJs 20.12.3 - this is the nuget package from if (IntPtr.Size == 4)
{
LoadLibrary(AssemblyDirectory + @"\edge\x86\libnode.dll");
nodeStart = NodeStartx86;
}
else if (IntPtr.Size == 8)
{
LoadLibrary(AssemblyDirectory + @"\edge\x64\libnode.dll");
nodeStart = NodeStartx64;
} Possible fix for that particular issue changing [DllImport("kernel32.dll", EntryPoint = "LoadLibrary")]
static extern int LoadLibrary([MarshalAs(UnmanagedType.LPStr)] string lpLibFileName);` to [DllImport("kernel32.dll", EntryPoint = "LoadLibrary")]
static extern int LoadLibrary( [MarshalAs(UnmanagedType.LPUTF8Str)] string lpLibFileName);` |
This is the file you should be looking at: https://github.com/agracio/edge-js/blob/master/src/double/Edge.js/dotnet/EdgeJs.cs |
Let me know if you encounter the same problem as I did when using EdgeJs 20.12.3 |
Could you tell me what exception you getting when using 20.12.3. Looks like you right about |
I encountered this issue when using version 20.12.3. |
I encountered this issue when using chinese characters that you provided: #232 (comment) |
I don't know if you can't see the images, so I'll copy the error message for you.
You can see that the word "测试" is garbled |
This should happen on earlier versions before tjanczuk/edge#555 was merged, very strange. |
Since this is a client-side application, I cannot guarantee where the users will place the program. In China, folders are commonly named using Chinese characters. |
This is a complicated issue to resolve, so not sure when or if I am able to figure it out. |
Could you start a fresh project using 20.12.3 and confirm that you getting This is especially strange as I am not able to go past |
I'm not entirely clear about the logic in the code, but is it possible to use a method similar to SetAssemblyDirectory to set edgeDirectory to point to a different path? This way, I could achieve the desired functionality by copying files. I have tried directly assigning a value to edgeDirectory in SetAssemblyDirectory, but the program does not run correctly. The error I sent you was generated from a new project that only uses Edge.js. After building the project successfully, placing the debug/release folder in a Chinese-named directory causes this issue. It took me a long time to figure out that this was the cause of the error. I can bypass the |
Why do you think that the issue is Try recompiling Edge.dll without the patch and just using |
I tried this method yesterday. Even after removing the patch and using the original values, the same issue persists. I believe the issue might be with how libnode.dll handles Chinese characters |
It is almost impossible for me to troubleshoot since we are getting different errors on our systems.
But then the error would be different. libnode.dll is not compiled using any of You can compile your own libnode.dll by downloading Node.js source from https://nodejs.org/en/download/source-code and then running |
edgeDirectory is not the issue. I just want to try another approach to solve this problem. Specifically, I plan to copy all Edge.js-related files to a temporary directory, which will not contain any Chinese characters. Then, I can load and use these files from the temporary directory. Both assemblyDirectory and edgeDirectory will cause the program to crash if they contain any Chinese characters. |
The issue has been resolved. Using relative paths when passing parameters works fine. argv.Add(@"edge\double_edge.js");
argv.Add("-EdgeJs:EdgeJs.dll");
nodeStart(argv.Count, argv.ToArray()); |
I am happy it is resolved for you however I am not sure introducing this into the main repo would not cause problems for other people. |
When the path contains Chinese characters, the application fails to run.
The text was updated successfully, but these errors were encountered: