C# (U3D) read the DLL pit (I think I will continue to encounter this problem in the future)

Reorganize

Insert picture description here
The causes of DLLNotFoundException include:

[DllImport("XXX.dll", EntryPoint = "?Test@@ABBCDDEFF@Z", ...
// "XXX.dll" 应该直接输入"XXX"

Insert picture description hereFailed to load… expected x64 but was x86 The solution is:
3 ways

Insert picture description here
Reasons for EntryPointNotFoundException include:

[DllImport("DLL", EntryPoint = "?Test@@ABBCDDEFF@Z", ...
// "?Test@@ABBCDDEFF@Z" 错误

Insert picture description here
Crash, it means that it has run into the dll. It is a problem with the dll. The reasons are:

  • Path /and \cause problems.
  • The log output in the dll causes an io problem
  • Server-side firewall is not off

================================
Insert picture description here
What I encountered at the beginning was this DllNotFoundException: OuterApi.dll (Do not care about TouchScript , It’s what’s wrong, it’s reported along with it.)
Then I did a Try Catch on the line where the error was reported, and then... From one error to three errors... A
Insert picture description here
new problem appeared, because Failed to load dll expected x64, that is, 64-bit U3D can’t read 32-bit DLLs. Then, among the three methods I found on the Internet , I tried both of the last two. I really have no way to ask my superiors for help. The DLL was replaced with 64-bit.

Change it, delete the try catch, and run it again.

Insert picture description here

From DllNotFoundException: OuterApi.dll to EntryPointNotFoundException... Helpless.
Originally, I felt like I was peeling off the onion layer by layer. Now I think this is a doll...

Then find out that the problem is that the dll is changed to 64-bit and the naming error causes EntryPointNotFoundException.
After solving this problem, no error was reported. It crashed instead.
Insert picture description here
Later investigation a little, or a dll problem there, because the other path /and \that causes problems.
After the solution was solved, everyone thought it was OK, and the result returned to DllNotFound, and this time it must be 64-bit, and after trying try catch, there is still only this problem.
At present, it is suspected that it is a partial compilation problem, try to modify it to full compilation.
There is another possibility that [DllImport("XXX", ...the .dll in it forgot to delete and became [DllImport("XXX.dll",, just fix it.

solve

Xiaofanwai:
Dll has no problems when debugging, but problems occur in the U3D environment, but the console.line in Dll cannot be displayed on U3D. At this time, the solution can specify to print the Dll log in the E:\ folder to generate a new txt.

Guess you like

Origin blog.csdn.net/MikeW138/article/details/105706206