开发者

MonoTouch: using embedded resx files on iPhone build

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜