MonoTouch:在iPhone版本上使用嵌入式resx文件 [英] MonoTouch: using embedded resx files on iPhone build

查看:64
本文介绍了MonoTouch:在iPhone版本上使用嵌入式resx文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我能够在使用MonoTouch构建的iPhone应用程序的Simulator版本中加载和访问resx文件。 csproj文件中的resx文件条目看起来像:

 < ItemGroup> 
< EmbeddedResource Include = MapMenu\Resources\MapMenu.resx>
< Generator> ResXFileCodeGenerator< / Generator>
< LastGenOutput> MapMenu.Designer.cs< / LastGenOutput>
< / EmbeddedResource>
< / ItemGroup>

.resx文件本身具有这样的条目:

 < data name = Main_Menu type = System.Resources.ResXFileRef,System.Windows.Forms> 
< value>主菜单.mm; System.String,mscorlib,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089; Windows-1252< / value>
< / data>

,生成的MapMenu.Designer.cs文件具有以下内容:

 内部静态字符串Main_Menu {
get {
return ResourceManager.GetString( Main_Menu,resourceCulture);
}
}

如上所述,调用Main_Menu访问器可以在模拟器。但是,在设备上,它会产生:

 < Notice> ;:未处理的异常:System.MissingMethodException:未找到系统的构造函数.Resources.RuntimeResourceSet ::。ctor(System.IO.UnmanagedMemoryStream)
< Notice> ;: at System.Activator.CreateInstance(System.Type类型,BindingFlags bindingAttr,System.Reflection.Binder活页夹,System.Object [ ] args,System.Globalization.CultureInfo文化,System.Object [] ActivationAttributes)[0x00000]在<文件名未知> :: 0
< Notice>中:在System.Activator.CreateInstance(System.Type类型,System .Object [] args,System.Object [] ActivationAttributes)[0x00000]在<文件名未知>:0
< Notice>中:在System.Activator.CreateInstance(System.Type类型,System.Object [] args)[0x00000]在<文件名未知>:0
< Notice>中:在System.Resources.ResourceManager.InternalGetResourceSet(System.Globalization.CultureInfo文化,布尔createIfNotExists,布尔tryParents )<文件名未知>:0中的[0x00000]:0
< Notice> ;:在System.Resources.ResourceManager.GetString(System.String名称,System.Globalization.CultureInfo文化)在<文件名未知>中的[0x00000] ;:0
< Notice> ;:在<文件名未知>:0中的MapMenu.Resources.MapMenu.get_Main_Menu()[0x00000]:0 >

做了一些健全性检查,并想知道这是否真的缺少Monotouch的功能。



谢谢,

解决方案

它看起来像链接器中的错误,该错误删除了仅由资源加载器代码通过反射调用的构造函数。解决方法是,可以禁用链接器(如果直接使用mtouch,则可以使用-nolink,也可以在MonoDevelop中指定链接器选项。



提交错误


I'm able to load and access resx files in Simulator builds of my iPhone app built using MonoTouch. The resx file entry in the csproj file looks like:

  <ItemGroup>
    <EmbeddedResource Include="MapMenu\Resources\MapMenu.resx">
      <Generator>ResXFileCodeGenerator</Generator>
      <LastGenOutput>MapMenu.Designer.cs</LastGenOutput>
    </EmbeddedResource>
  </ItemGroup>

The .resx file itself has an entry like this:

  <data name="Main_Menu" type="System.Resources.ResXFileRef, System.Windows.Forms">
    <value>Main Menu.mm;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
  </data>

and the generated MapMenu.Designer.cs file has this:

    internal static string Main_Menu {
        get {
            return ResourceManager.GetString("Main_Menu", resourceCulture);
        }
    }

As mentioned above, calling the Main_Menu accessor works fine on the simulator. On the device, however, it produces:

<Notice>: Unhandled Exception: System.MissingMethodException: No constructor found for System.Resources.RuntimeResourceSet::.ctor(System.IO.UnmanagedMemoryStream)
<Notice>:   at System.Activator.CreateInstance (System.Type type, BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes) [0x00000] in <filename unknown>:0 
<Notice>:   at System.Activator.CreateInstance (System.Type type, System.Object[] args, System.Object[] activationAttributes) [0x00000] in <filename unknown>:0 
<Notice>:   at System.Activator.CreateInstance (System.Type type, System.Object[] args) [0x00000] in <filename unknown>:0 
<Notice>:   at System.Resources.ResourceManager.InternalGetResourceSet (System.Globalization.CultureInfo culture, Boolean createIfNotExists, Boolean tryParents) [0x00000] in <filename unknown>:0 
<Notice>:   at System.Resources.ResourceManager.GetString (System.String name, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0  
<Notice>:   at MapMenu.Resources.MapMenu.get_Main_Menu () [0x00000] in <filename unknown>:0 

Did a few sanity checks, and am wondering at this point if this really is missing functionality in Monotouch.

Thanks,

解决方案

It looks like a bug in the linker that removes a constructor that is only called through reflection by the resource loader code. As a workaround, you can disable the linker (either using -nolink if you use mtouch directly, or by specifying the linker options in MonoDevelop.

Please file a bug.

这篇关于MonoTouch:在iPhone版本上使用嵌入式resx文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆