1

我能够在使用 MonoTouch 构建的 iPhone 应用程序的模拟器版本中加载和访问 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>Main Menu.mm;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
  </data>

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

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

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

<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 

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

谢谢,

4

1 回答 1

1

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

提交一个错误

于 2010-01-20T18:50:48.547 回答