HTTP WebRequest with iOS Stripping

httpWebRequest works fine for me on iOS device until I turn on code stripping.

I have seen conflicting posts, some of them admittedly quite old, as to whether this can be made to work.

I have tried to identify and and add required types and namespace to the link.xml file. But haven’t managed to get this to work yet. It might just be my syntax or chosen namespaces.

Can anybody confirm if they have managed to get this to work.

The error I am getting is

System.TypeInitializationException: An exception was thrown by the type initializer for System.Net.WebRequest —> System.Exception: Error Initializing the configuration system. —> System.Exception: Method not found: ‘Default constructor not found…ctor() of System.Configuration.ExeConfigurationHost’.
at System.Activator.CreateInstance (System.Type type, Boolean nonPublic) [0x00000] in :0
at System.Activator.CreateInstance (System.Type type) [0x00000] in :0
at System.Configuration.InternalConfigurationSystem.Init (System.Type typeConfigHost, System.Object hostInitParams) [0x00000] in :0
at System.Configuration.InternalConfigurationFactory.Create (System.Type typeConfigHost, System.Object hostInitConfigurationParams) [0x00000] in :0
at System.Configuration.ConfigurationManager.OpenExeConfigurationInternal (ConfigurationUserLevel userLevel, System.Reflection.Assembly calling_assembly, System.String exePath) [0x00000] in :0
at System.Configuration.ClientConfigurationSystem.get_Configuration () [0x00000] in :0
— End of inner exception stack trace —
at System.Configuration.ClientConfigurationSystem.get_Configuration () [0x00000] in :0
at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection (System.String configKey) [0x00000] in :0
at System.Configuration.ConfigurationManager.GetSection (System.String sectionName) [0x00000] in :0
at System.Net.WebRequest…cctor () [0x00000] in :0
— End of inner exception stack trace —

My link.xml currently contains the following, but event that is throwing the error above.

   <assembly fullname="mscorlib">
   			<namespace fullname="System.Security.Cryptography" preserve="all"/>
   			<namespace fullname="System.Threading" preserve="all"/>
   			<namespace fullname="System.Activator" preserve ="all"/>
   			<namespace fullname="System.Activator.CreateInstance" preserve ="all"/>
   </assembly>
   <assembly fullname="System">
   		   <namespace fullname="System.Threading" preserve="all"/>
           <namespace fullname="System.Net.Configuration.WebRequestModuleHandler" preserve="all"/>
           <namespace fullname="System.Net.HttpRequestCreator" preserve="all"/>
           <namespace fullname="System.Net.FileWebRequestCreator" preserve="all"/>
           <namespace fullname="System.Net" preserve="all"/>
           <namespace fullname="System.Net.WebRequest" preserve="all"/>
           <namespace fullname="System.Collections" preserve="all"/>
           <namespace fullname="System.Collections.Generic" preserve="all"/>
           <namespace fullname="System.Runtime.ConstrainedExecution.CriticalFinaliserObject" preserve="all"/>
           <namespace fullname="System.IO" preserve="all"/>
           <namespace fullname="System.Text" preserve="all"/> 
           <namespace fullname="System.Runtime.InteropServices" preserve="all"/>
           <namespace fullname="System.Runtime.Serialization.ISerializable" preserve="all"/>
           <namespace fullname="System.Activator.CreateInstance" preserve ="all"/>
           <namespace fullname="System.Configuration" preserve="all"/>
   </assembly>
   <assembly fullname="System.Web.Services">
           <type fullname="System.Web.Services.Protocols.SoapTypeStubInfo" preserve="all"/>
           <type fullname="System.Web.Services.Configuration.WebServicesConfigurationSectionHandler" preserve="all"/>
   </assembly>
   <assembly fullname="System.Configuration">
   		<namespace fullname="System.Configuration.ExeConfigurationHost" preserve="all"/>
   		<namespace fullname="System.Configuration.ClientConfigurationSystem" preserve="all"/>
   		<namespace fullname="System.Configuration.ConfigurationManager.GetSection" preserve="all"/>
   		<namespace fullname="System.Configuration" preserve="all"/>
   </assembly>

Hi there LaurieMcC, I cannot confirm whether the appropriate link.xml file references will allow System.Net.* stuff to work alongside stripping, but I can confirm that Unity’s inbuilt WWW class can, in almost all instances, replace any System.Web or System.Net functionality. We started stripping our app to reduce file size and just ended up replacing all instances of .Net calls with WWW and now it works fine.

Well… except for this nasty System.Web.Extensions reference in our serialiser :frowning:

Good luck