Search Unity

IOS/Xcode error when using System.net.mail

Discussion in 'iOS and tvOS' started by Axcell_Hunt, Jun 20, 2015.

  1. Axcell_Hunt

    Axcell_Hunt

    Joined:
    Jun 23, 2014
    Posts:
    7
    Hey all, I've stumbled upon an issue with sending smtp mail via my apps. The Android and desktop versions work fine however IOS does not. It also doesn't crash, it simply does nothing. So I debugged it in Xcode and found it outputting the following error report. I have no idea why this is and what it means.
    Has anyone else encountered anything like this and know what may be causing it? Any help/ advice would be a huge help as I really don't know what to do next. I can provide more information if required. Thanks in advance

    (Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 65)



    MissingMethodException: Method not found: 'Default constructor not found...ctor() of System.Net.Configuration.MailSettingsSectionGroup'.

    at Mono.Security.Uri.HexEscape (Char character) [0x00000] in <filename unknown>:0

    at System.Activator.CreateInstance (System.Type type, Boolean nonPublic) [0x00000] in <filename unknown>:0

    at System.Configuration.ConfigInfo.CreateInstance () [0x00000] in <filename unknown>:0

    at iTween.easeInOutElastic (Single start, Single end, Single value) [0x00000] in <filename unknown>:0

    at System.Configuration.Configuration.GetSectionGroupInstance (System.Configuration.SectionGroupInfo group) [0x00000] in <filename unknown>:0

    at System.Configuration.ConfigurationSectionGroupCollection.get_Item (System.String name) [0x00000] in <filename unknown>:0

    at System.Configuration.Configuration.GetSection (System.String path) [0x00000] in <filename unknown>:0

    at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection (System.String configKey) [0x00000] in <filename unknown>:0

    at System.MonoInternalNoteAttribute..ctor (System.String comment) [0x00000] in <filename unknown>:0

    at System.Configuration.ConfigurationManager.GetSection (System.String sectionName) [0x00000] in <filename unknown>:0

    at System.Net.Mail.SmtpClient..ctor (System.String host, Int32 port) [0x00000] in <filename unknown>:0

    at System.Net.Mail.SmtpClient..ctor (System.String host) [0x00000] in <filename unknown>:0

    at mono_gmail.SendCableDesignMail (System.String email, System.String cableLength, System.String colorCode) [0x00000] in <filename unknown>:0

    at PostSubmissionData+<TrySubmitCableDelayed>c__Iterator0.MoveNext () [0x00000] in <filename unknown>:0

    at System.Collections.Generic.Dictionary`2+Transform`1[System.Int32,UnityEngine.EventSystems.PointerEventData,System.Collections.Generic.KeyValuePair`2[System.Int32,UnityEngine.EventSystems.PointerEventData]].EndInvoke (IAsyncResult result) [0x00000] in <filename unknown>:0

    System.Collections.Generic.Transform`1:EndInvoke(IAsyncResult)


    (Filename: currently not available on il2cpp Line: -1)
     
  2. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,931
    @Axcell_Hunt

    My suspicion is that the constructor for the System.Net.Configuration.MailSettingsSectionGroup is being stripped out, since it is accessed via reflection. With the IL2CPP scripting backend, stripping is always enabled, so this might happen.

    You can attempt to require this type to not be stripped by using a link.xml file, as described here:

    http://docs.unity3d.com/Manual/iphone-playerSizeOptimization.html
     
  3. danieltranca

    danieltranca

    Joined:
    Jan 9, 2015
    Posts:
    10
    I get the same error when trying to send an email from iOS(works great on Android and Unity Editor).

    I tried Josh's solution but it's not working. Have you solved this problems somehow? Thanks!
     
  4. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,931
    @danieltranca

    You might be experiencing this bug:

    http://issuetracker.unity3d.com/issues/il2cpp-crashes-when-using-smtpclient

    Note that we do have a more complex work around than I one I suggested earlier on this thread. You can use this link.xml file:

    <linker>
    <assembly fullname="System">
    <type fullname="System.Net.Configuration.MailSettingsSectionGroup" preserve="all"/>
    <type fullname="System.Net.Configuration.SmtpSection" preserve="all"/>
    <type fullname="System.Net.Configuration.SmtpNetworkElement" preserve="all"/>
    </assembly>
    </linker>

    Once we correct this issue, you won't need this link.xml file, but we've not been able to complete the fix yet.
     
    TomSantoro and coeing like this.
  5. coeing

    coeing

    Joined:
    Mar 17, 2011
    Posts:
    271
    Quick addition for devs getting here via search: In newer versions of Unity you have to add an additional line to link.xml:

     
    matiasjaure, TomSantoro and dorukeker like this.
  6. dorukeker

    dorukeker

    Joined:
    Dec 6, 2016
    Posts:
    37
    I also need to add the namespace to my c# script
    Code (CSharp):
    1. using System.Net.Configuration
     
  7. TomSantoro

    TomSantoro

    Joined:
    Oct 17, 2015
    Posts:
    9
    You guys in this thread are the best. <3


    Just incase anyone else comes here, when I pasted this additional line into xcode it gave me a weird character, which when I built meant the fix didn't work, you have to select the character and delete that and nothing else, then the fix will work.

    Thanks for all the info guys, I'm gonna look into stripping now (engine stripping that is...) godspeed to all of you!

    Tom
     
  8. Fonefen

    Fonefen

    Joined:
    Dec 30, 2012
    Posts:
    9
    [QUOTE = "JoshPeterson, publicación: 2389645, miembro: 660077"] [USER = 748491] @danieltranca [/ USER]

    Es posible que esté experimentando este error:

    http://issuetracker.unity3d.com/issues/il2cpp-crashes-when-using-smtpclient

    Tenga en cuenta que tenemos un trabajo más complejo que el que sugerí anteriormente en este hilo. Puedes usar este archivo link.xml:

    <linker>
    <assembly fullname = "Sistema">
    <type fullname = "System.Net.Configuration.MailSettingsSectionGroup" preserve = "all" />
    <type fullname = "System.Net.Configuration.SmtpSection" preserve = "all" />
    <type fullname = "System.Net.Configuration.SmtpNetworkElement" preserve = "all" />
    </ assembly>
    </ linker>

    Una vez que corrijamos este problema, no necesitará este archivo link.xml, pero aún no hemos podido completar la corrección. [/ QUOTE]
     
  9. Fonefen

    Fonefen

    Joined:
    Dec 30, 2012
    Posts:
    9
    Greetings. I have the problem of not being able to send email on the iOS platform, I see that in this thread you comment that creating a link.xml with the references that you indicate is solved, I have created the file and I have placed it in the asset folder but I compile the project and still not send, I have to save it in another folder? or select some spices configuration so that link.xml does its function ?, thanks.
     
  10. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,931
    The link.xml file should work when it is placed in the Assets folder. You can find all of the details in the documentation here: https://docs.unity3d.com/Manual/IL2CPP-BytecodeStripping.html

    When the mail does not send, do you see an error message? If not, this might be a different issue from the one originally mentioned in this thread.
     
    unnanego likes this.
  11. unnanego

    unnanego

    Joined:
    May 8, 2018
    Posts:
    199
    same issue here, didn't see it at first since xcode wasn't showing the symbol.
     
  12. unnanego

    unnanego

    Joined:
    May 8, 2018
    Posts:
    199
    It's working when stripping set only to low, which makes the size of the app ridiculously large. When setting stripping to higher level, the mail does not send, there are no errors, and the success callback is sent, but nothing arrives in the mail. Is there a way to investigate this issue?
     
  13. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,931
    I'm not familiar enough with the class library mail code to venture a guess, unfortunately. You could try to debug the generated C++ code - but without an understanding of how the C# code should work, that might be difficult.

    Another option is to diff the stripped assemblies in the case that works and the case that does not work - maybe something in the mail code in the class libraries will jump out as missing. Then you could use a link.xml to preserve that.