Georgi Iliev
Georgi Iliev

Reputation: 3

Error while sending email on iOS app with unity

I'm working on a school project and I'm trying to log data that is stored from a game that I made in unity.

My problem is that I want to email the data true the app. Everything works fine, email is sending with the data etc. But when I build the app to an iOS device it is not sending the email.

I do not have any errors in unity but I get this error in Xcode when I build the app.See the error below. I hope someone can help me.

Greetings,

Georgi Iliev

MissingMethodException: Method not found: 'Default constructor not found...ctor() of System.Net.Configuration.MailSettingsSectionGroup'.
  at Mono.Security.Authenticode.AuthenticodeBase.GetSecurityEntry () [0x00000] in <filename unknown>:0 
  at System.Activator.CreateInstance (System.Type type, System.Object[] args) [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.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 MonoGmail.Start () [0x00000] in <filename unknown>:0 

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

added @programmers solution and got a new mixed error.

MissingMethodException: Method not found: 'Default constructor not found...ctor() of System.Net.Configuration.MailSettingsSectionGroup'.
  at StartMenu.CloseApp () [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 System.Collections.Generic.Comparer`1[T].get_Default () [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.MonoTODOAttribute..ctor () [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.Start () [0x00000] in <filename unknown>:0 
  at System.Array.GetGenericValueImpl[T] (Int32 pos, .T& value) [0x00000] in <filename unknown>:0 
  at System.Array.GetGenericValueImpl[T] (Int32 pos, .T& value) [0x00000] in <filename unknown>:0 
  at System.Array.GetGenericValueImpl[T] (Int32 pos, .T& value) [0x00000] in <filename unknown>:0 
  at System.Array.GetGenericValueImpl[T] (Int32 pos, .T& value) [0x00000] in <filename unknown>:0 
System.Array:GetGenericValueImpl(Int32, T&)
System.Array:GetGenericValueImpl(Int32, T&)
System.Array:GetGenericValueImpl(Int32, T&)
System.Array:GetGenericValueImpl(Int32, T&)

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

Upvotes: 0

Views: 1510

Answers (1)

Programmer
Programmer

Reputation: 125455

This is a bug in IL2CPP. Unity does not have any plan to fix this issue any time soon because there is a temporary solution to fix it.

In your link.xml, add the following to it.

<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>

It is basically telling Xcode to not strip these mail stuff out.

If you don't have link.xml, create it and put the code above in it then place the file in the Asset folder. Rebuild the project.

EDIT:

According to a comment below, it is now required to add the line below too:

<type fullname="System.Net.Configuration.SmtpSpecifiedPickupDirectoryElement" preserve="all"/>

Upvotes: 4

Related Questions