c# - 统一在 iOS 应用程序上发送电子邮件时出错

标签 c# c++ ios email unity3d

我正在做一个学校项目,我正在尝试记录从我在 unity 中制作的游戏中存储的数据。

我的问题是我想通过电子邮件将数据发送到应用程序。一切正常,电子邮件正在发送数据等。但是当我将应用程序构建到 iOS 设备时,它没有发送电子邮件。

我在 unity 中没有任何错误,但是当我构建应用程序时,我在 Xcode 中遇到了这个错误。请参阅下面的错误。我希望有人能帮助我。

问候,

格奥尔基·伊利耶夫

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)

添加了@programmers 解决方案并得到了一个新的混合错误。

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)

最佳答案

这是一个 bugIL2CPP 中。 Unity 短期内没有任何解决此问题的计划,因为有一个临时解决方案来解决它。

在您的 link.xml 中,添加以下内容。

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

它基本上是告诉 Xcode 不要删除这些邮件内容。

如果您没有link.xml,请创建它并将上面的代码放入其中,然后将该文件放入Asset 文件夹中。重建项目。

编辑:

根据 comment下面,现在还需要添加以下行:

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

关于c# - 统一在 iOS 应用程序上发送电子邮件时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36087436/

相关文章:

c++ - C 多行宏问题 : why not use if(1){. ..} 而不是多行宏定义中的 do{...}while(0)

C++ OpenCV 从点 vector 获取边界框

c++ - 同时支持 Tcl 和 Python?

c++ - ObjC++ 中的画外音支持

iphone - 没有崩溃的崩溃日志?

c# - 如何生成动态for循环

c# - 如何在 asp.net core 中获取 .resx 文件字符串

iPhone:将联系人添加到不在设备上工作但在 ABAddressbook 中的模拟器上工作的组

c# - Entity Framework 中的构造函数初始化

c# - .NET 中的这种类型是什么(反射)