Quantcast
Channel: Questions in topic: "code stripping"
Viewing all articles
Browse latest Browse all 6

How to use System.Net with code stripping?

$
0
0
Setting Unity's stripping level to Strip Assemblies or Strip ByteCode from Player Settings -> Optimization causes (at least) some of the System.Net functionality fail. To test the issue, I created a simple project that only tries to use System.Net.WebRequest.Create(): using UnityEngine; using System.Net; public class NetworkAccessTest : MonoBehaviour { void Start() { bool succeeded = false; try { WebRequest.Create("http://www.google.com"); succeeded = true; } catch (System.Exception e) { Debug.Log(string.Format("Exception: {0}", e)); succeeded = false; } Debug.Log(string.Format("Web request creation succeeded: {0}", succeeded)); } } It works fine without stripping. But without sripping:

Exception: System.NotSupportedException: http://www.google.com/
  at System.Net.WebRequest.GetCreator (System.String prefix) [0x00000] in :0 
  at System.Net.WebRequest.Create (System.Uri requestUri) [0x00000] in :0 
  at System.Net.WebRequest.Create (System.String requestUriString) [0x00000] in :0 
  at NetworkAccessTest.Start () [0x00000] in :0 
The questions: 1. Is it possible to use WebRequest and other networking classes from System.Net with code stripping? 2. And if it's possible, how? It's possible to list types that shouldn't be stripped: [docs.unity3d.com/Documentation/Manual/iphone-playerSizeOptimization.html][1]. Would that solve the issue? How would I conveniently find out which types to list there? I can only think of reading the Mono source code and trying to deduce the missing types that could cause the expections. [1]: http://docs.unity3d.com/Documentation/Manual/iphone-playerSizeOptimization.html

Viewing all articles
Browse latest Browse all 6

Latest Images

Trending Articles





Latest Images