简体   繁体   English

UWP的Unity:指定了无效的句柄

[英]Unity for UWP: An invalid handle was specified

I built my game for UWP with Il2Cpp. 我使用Il2Cpp为UWP构建了游戏。 When it tries to connect to the internet I get this error: 当它尝试连接到互联网时,出现此错误:

Exception thrown at 0x2121FE8A in game.exe: 0xC0000008: An invalid handle was specified. game.exe中的0x2121FE8A抛出异常:0xC0000008:指定了无效的句柄。

Since the C# source turned into a C++ project I've no idea what's wrong in my code. 由于C#源代码变成了C ++项目,所以我不知道我的代码有什么问题。 it works errorless when I play in Unity. 当我在Unity中玩游戏时,它可以正常工作。

How can I find a clue on what's going wrong? 如何找到发生问题的线索?

Screenshot: 截图:

在此处输入图片说明

I would not directly debug in the c++ generated code ... it is very intransparent and hard to interpret (also the Manual doesn't really help here) 我不会直接在c++生成的代码中调试...它是非常不透明的,很难解释(而且《 手册》在这里并没有帮助)

Rather build and deploy the app with the option Wait for Managed Debugger enabled and connect a Debugger in the c# VisualStudio solution ( source ) 而是在启用了“ Wait for Managed Debugger ”选项的情况下构建和部署应用程序,并在c#VisualStudio解决方案中连接调试器(

  1. Set up your Unity project build settings and enable Development Build , Script Debugging and Wait for managed debugger 设置您的Unity项目构建设置并启用“ Development Build ,“ Script Debugging和“ Wait for managed debugger

    在此处输入图片说明

  2. Build in Unity, open the solution in VisualStudio instance and deploy it to a remote device 在Unity中构建,在VisualStudio实例中打开解决方案并将其部署到远程设备

  3. The build and deploy takes considerably longer and once deployed you're asked to attach the debugger 构建和部署需要相当长的时间,并且一旦部署,系统会要求您附加调试器

    在此处输入图片说明

  4. Open any script in VisualStudio from within Unity (so you have the entire solution loaded correctly) and select Attach Unity Debugger from the drop down 在Unity Visual Studio中打开任何脚本(这样您就可以正确加载整个解决方案),然后从下拉菜单中选择“ Attach Unity Debugger

    在此处输入图片说明

  5. You should be prompted with a window that allows you to select the lens. 应该提示您一个允许您选择镜头的窗口。 (It should also work when the lens is attached via USB, but you might need to enable inbound UDP communication for devenv.exe) (当通过USB连接镜头时,它也应该起作用,但是您可能需要为devenv.exe启用入站UDP通信)

    在此处输入图片说明

On this way you can debug your normal c# code, set breakpoints etc. while it is actually running the Il2CPP generated c++ code. 这样,您就可以在实际运行Il2CPP生成的c++代码时调试常规的c#代码,设置断点等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM