Search Unity

I have a problem with link.xml

Discussion in 'iOS and tvOS' started by c&c&z&z, May 6, 2013.

  1. c&c&z&z

    c&c&z&z

    Joined:
    Aug 1, 2012
    Posts:
    12
    It's my link.xml info:
    Code (csharp):
    1. <linker>
    2.   <assembly fullname="System">
    3.     <type fullname="System.Net" preserve="all"/>
    4.     <type fullname="System.Threading" preserve="all"/>
    5.     <type fullname="System.Net.Sockets" preserve="all"/>
    6.     <type fullname="System.IO" preserve="all"/>
    7.     <type fullname="System.Text" preserve="all"/>
    8.     <type fullname="System.Collections" preserve="all"/>
    9.     <type fullname="System.Collections.Generic" preserve="all"/>
    10.     <type fullname="System.Net.WebRequest" preserve="all"/>
    11.     <type fullname="System.Configuration.ExeConfigurationHost" preserve="all"/>
    12.     <type fullname="System.Configuration" preserve="all"/>
    13.   </assembly>
    14. </linker>
    It's the problem(for xcode throw):
    Code (csharp):
    1. Loading /var/mobile/Applications/5A35737D-ECB3-4C4E-9219-6E18D5D87D63/COD0506t2.app/Data/Managed/System.Data.dll
    2.  
    3. into Unity Child Domain
    4. - Completed reload, in  0.171 seconds
    5. -> applicationDidBecomeActive()
    6.  
    7. Unhandled Exception: System.TypeInitializationException: An exception was thrown by the type initializer for
    8. System.Net.WebRequest ---> System.Configuration.ConfigurationErrorsException: Error Initializing the configuration system. ---> System.MissingMethodException: Method not found: 'Default constructor not found...ctor() of System.Configuration.ExeConfigurationHost'.
    9.   at System.Activator.CreateInstance (System.Type type, Boolean nonPublic) [0x00000] in <filename unknown>:0
    10.   at System.Activator.CreateInstance (System.Type type) [0x00000] in <filename unknown>:0
    11.   at System.Configuration.InternalConfigurationSystem.Init (System.Type typeConfigHost, System.Object[] hostInitParams) [0x00000] in <filename unknown>:0
    12.   at System.Configuration.InternalConfigurationFactory.Create (System.Type typeConfigHost, System.Object[] hostInitConfigurationParams) [0x00000] in <filename unknown>:0
    13.   at System.Configuration.ConfigurationManager.OpenExeConfigurationInternal (ConfigurationUserLevel userLevel, System.Reflection.Assembly calling_assembly, System.String exePath) [0x00000] in <filename unknown>:0
    14.   at System.Configuration.ClientConfigurationSystem.get_Configuration () [0x00000] in <filename unknown>:0
    15.   --- End of inner exception stack trace ---
    16.   at System.Configuration.ClientConfigurationSystem.get_Configuration () [0x00000] in <filename unknown>:0
    17.   at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection (System.String configKey) [0x00000] in <filenameunknown>:0
    18.   at System.Configuration.ConfigurationManager.GetSection (System.String sectionName) [0x00000] in <filename unknown>:0
    19.   at System.Net.WebRequest..cctor () [0x00000] in <filename unknown>:0
    20.   --- End of inner exception stack trace ---
    21.   at Net.Http.HttpUtil.GetHttp (System.String httpUrl) [0x00000] in <filename unknown>:0
    22.   at Net.NetManager.ExecuteGetHttp () [0x00000] in <filename unknown>:0
    23. Clark
    24.  
    25. (Filename: /Applications/buildAgent/work/14194e8ce88cdf47/Runtime/ExportGenerated/iPhonePlayer-armv7/UnityEngineDebug.cpp Line: 43)
    26.  
    27. -> force accelerometer registration
    The game I'm working on using several classes from the System.Net.Sockets package. If I run it on a normal build it works perfectly, but if I try to strip it using either StrippingLevel.StripAssemblies or StrippingLevel.StripByteCode stripping levels, it crashes with a*exception (above...).

    But, why?

    Additional Information:
    1, I have implemented Http using System.Net.Sockets.
    2, When I use my link.xml, the size of System.dll is increased (259kb).
    3, When I only use [StrippingLevel.StripByteCode], the size of System.dll is small (252kb).
    4, When I disable the [strip function], the size of System.dll is biggest (1.7m).
     
    Last edited: May 7, 2013
  2. c&c&z&z

    c&c&z&z

    Joined:
    Aug 1, 2012
    Posts:
    12
    If I want to ignore all classes of System.dll , How can I do?
    Because, I only need to strip my Assembly-CSharp.dll

    en... Is this right?
    Code (csharp):
    1.  
    2. <linker>
    3.     <assembly fullname="System">
    4.         <type fullname="System.*" preserve="all"/>
    5.     </assembly>
    6.     <assembly fullname="mscorlib">
    7.         <namespace fullname="System.*" preserve="all"/>
    8.     </assembly>
    9. </linker>
    10.  
     
    Last edited: May 7, 2013
  3. aren372

    aren372

    Joined:
    Apr 2, 2010
    Posts:
    38
    Exactly the same issue, someone please help!
     
  4. jite

    jite

    Joined:
    Aug 19, 2012
    Posts:
    6
    1. Discover the name of the assembly for excluding

    • Build project for windows (or just looking for any dlls in project)
    • Got .NET SomeAssemblyBrowser (ILspy or something like this)
    • Open in SomeAssemblyBrowser suspected dll libraries (BuildFolder\Managed, BuildFolder\Plugins etc)
    • Figure out assembly name by searching for desired namespace
    For example you found SomeAssemblyName and SomeNamespaceName within it.
    2. Make the file Assets\link.xml:
    Code (csharp):
    1. <linker>
    2.        <assembly fullname="SomeAssemblyName">
    3.                <namespace fullname="SomeNamespaceName" preserve="all"/>
    4.        </assembly>
    5. </linker>
    6.  
    3. Build project for iOS with this file, set strip level different values and verify that the corresponding BuildFolder/Libraries/SomeLibraryName.dll.s size is changing (also "Other/SystemExecutableAndDll" size in Profiler.Memory.Detailed Take Sample)
     
    Last edited: Nov 13, 2013
    kayy likes this.
  5. tnqiang

    tnqiang

    Joined:
    Jan 27, 2015
    Posts:
    3
    I encountered the same problem when used HttpWebRequest.
    Following link.xml helps:
    <linker>
    <assembly fullname="System">
    <type fullname="System.Net.HttpWebRequest" preserve="all"/>
    <type fullname="System.Net.WebResponse" preserve="all"/>
    <type fullname="System.Net.HttpRequestCreator" preserve="all"/>
    </assembly>
    </linker>
    But I don't know what's the reason and how to find the corrected type name, anybody can help?
     
  6. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    Okay, a little help for those searching for some instructions on how this works. This is based on trial and error.

    "type" can be either a class name (with full namespace) or just a namespace and every class within that namespace will be excluded.
    Child namespaces will not be excluded just by adding the parent namespace. In order to exclude namespaces recursively, use *

    Code (csharp):
    1. <linker>
    2.    <assembly fullname="MyAssemblyName"> // the name of the assembly
    3.        <type fullname="MyNamespace" preserve="all"/> // excludes all classes that are direct children of MyNamespace
    4.        <type fullname="MyNamespace.*" preserve="all"/> // excludes all namespaces and classes recursively under MyNamespace
    5.        <type fullname="MyNamespace*" preserve="all"/> // excludes all namespaces and classes recursively under MyNamespace. Would also exclude the namespace MyNamespaceABC
    6.        <type fullname="My*" preserve="all"/> // excludes all namespaces and classes that start with My and all children of those namespaces
    7.        <type fullname="*" preserve="all"/> // excludes all namespaces and classes in the assembly
    8.    </assembly>
    9. </linker>
    Essentially, it seems to be just a simple string comparison.

    Also, using the namespace element also works. I haven't tested this but I assume it excludes everything within that namespace. Not sure about child namespaces within the parent.

    Code (csharp):
    1. <linker>
    2.    <assembly fullname="MyAssemblyName">
    3.        <namespace fullname="MyNamespace" preserve="all"/>
    4.    </assembly>
    5. </linker>
     
    Last edited: Aug 2, 2015