Search Feedback

20
votes

[BUG] .NET 4.0 throwing exception

Networking

-

-

Please run this code in the empty scene. In Player Settings .Net 3.5 it works ok, when switching to .Net 4.0 the same code throws exception. This bug doesn't allow us to import a third-party library because it's throwing an exception in this exact method:
ipProps.GetIPv4Properties();
Please note that on some machines, the code works in 3.5 and 4.0. There might be some adapter settings that break this code on 4.0.

The code:

using System.Collections;
using System.Collections.Generic;
using System.Net;
using System.Net.NetworkInformation;
using System.Net.Sockets;
using UnityEngine;

public class NetworkTest : MonoBehaviour {

// Use this for initialization
void Start()
{
NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface ni in nics)
{
Debug.Log("CI");
IPInterfaceProperties ipProps = ni.GetIPProperties();
foreach (UnicastIPAddressInformation uni in ipProps.UnicastAddresses)
{
IPv4InterfaceProperties ipv4Props = ipProps.GetIPv4Properties();
if (ipv4Props != null)
{
Debug.Log(ipv4Props.Index);
}
}
}
}
}

Comments (1)

  1. F99091e743edf355221ebb6639d7a107?d=mm

    desdief

    Dec 13, 2018 17:31

    I'm having the same issue. When I run in the Unity player it works fine, but when I do a build and run it I get a null object exception on GetIPv4Properties().

Your opinion counts

Help us make things better. Share your great idea for improving Unity or vote for other people’s.

Log in to post a new idea

Categories

All

(10889)

2D

(287)

Ads

(57)

AI & Navigation

(81)

Analytics

(130)

Animation

(406)

Asset Store

(364)

Asset Store Publisher

(19)

Assets

(551)

Audio

(185)

Cloud Build

(148)

Collaborate

(68)

Docs & Tutorials

(247)

Editor

(2545)

Everyplay

(17)

Game Performance Reporting

(21)

General

(987)

Graphics

(894)

GUI

(442)

Input

(173)

Licensing

(93)

Networking

(190)

Physics

(387)

Platforms

(445)

Profiling & Optimization

(84)

Runtime

(185)

Scripting

(1141)

Terrain

(174)

WebGL

(142)