HoloLens模拟器中含SharingService的网络应用无法运行求助
Troubleshooting NetworkingHololens App Crash on HoloLens Simulator
Let’s walk through diagnosing and fixing this crash issue with your NetworkingHololens app (and other network-enabled apps) that fails right after the "Made with Unity" screen. Since non-network apps run fine, the problem is almost certainly tied to network-related configuration or your SharingService implementation.
First, Dig Into Your Crash Logs (You mentioned updating logs—let’s use them)
- Scan logs for keywords like
SharingService,NetworkException,Socket, orPermissionDenied. You can access HoloLens simulator logs via the Device Portal: connect to the simulator’s IP, navigate to System > Event Viewer > Applications and Services Logs > Unity. - If you spot
Access Deniederrors, this is likely a missing capability issue—Unity’s SharingService needs specific network permissions to run.
Verify UWP Capabilities in Unity
Your app requires the right network permissions to use SharingService. Here’s how to check:
- In Unity, go to Edit > Project Settings > Player > Windows > Publishing Settings > Capabilities.
- Make sure these are checked:
InternetClient(required for outgoing network connections)PrivateNetworkClientServer(critical if you’re using local network sharing, which is standard for HoloLens collaboration)- Add
BluetoothorProximityif your setup uses those local protocols.
- Rebuild your UWP project after enabling these—capabilities only take effect when you generate the package.
Audit SharingService Initialization Code
Common missteps here cause crashes:
- Initialize the SharingService after the app fully loads (avoid
Awake()—useStart()or a coroutine that waits for network readiness). - Don’t run blocking network calls on the main thread—wrap them in
async/awaitor use Unity’s non-blocking patterns. - Example of safe initialization:
async void Start() { // Wait for network connectivity to stabilize while (!(NetworkReachability.ReachableViaLocalAreaNetwork || NetworkReachability.ReachableViaInternet)) { await Task.Delay(1000); } try { SharingService.Instance.Initialize(); // Add your cube control logic here } catch (Exception ex) { Debug.LogError($"SharingService init failed: {ex.Message}"); } }
Simulator-Specific Checks
HoloLens simulator has unique network quirks to address:
- Ensure the simulator is on the same network as your development machine, or enable "Shared Networking" in the simulator’s settings.
- Temporarily disable firewalls on your dev machine—they often block traffic to/from the simulator.
- Reset the simulator if state corruption is suspected: Go to HoloLens Simulator > Settings > System > Recovery > Reset This PC (choose to keep your files).
Test with a Minimal Reproducible Project
If the above steps don’t resolve the issue, create a tiny test app:
- A blank Unity project with only SharingService initialized and a simple cube.
- Build and run it on the simulator. If it crashes, the problem lies with your Unity/HoloLens SDK setup. If it works, the issue is in your main app’s code (likely conflicting scripts or misconfigured SharingService settings).
Update Your Tools
- Make sure you’re using the latest versions of Unity Hub, HoloLens SDK, and Visual Studio 2022. Outdated tools often have known network-related bugs that are fixed in newer releases.
内容的提问来源于stack exchange,提问作者Abhijit S
相关产品推荐
相关产品推荐

