Quantcast

Using resx resources on monotouch

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Using resx resources on monotouch

Felix Collins
I'm trying to use resources embedded from resx files in monotouch. I can see the various resources dlls for the different languages in the .app file but I get a MissingManifestResourceException when I try to use one. In the debugger I checked what assemblies are loaded and none of the resource ones are. Do I need to do something else to get this working on touch? I have the build set to debug and not link at the moment.

Regards,
Felix
_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Using resx resources on monotouch

Rolf Bjarne Kvinge
Hi,

Which version of MonoTouch are you using? This should be working in the 5.2 release (but it wasn't in earlier releases).

Rolf

On Thu, Mar 8, 2012 at 2:32 AM, Felix Collins <[hidden email]> wrote:
I'm trying to use resources embedded from resx files in monotouch. I can see the various resources dlls for the different languages in the .app file but I get a MissingManifestResourceException when I try to use one. In the debugger I checked what assemblies are loaded and none of the resource ones are. Do I need to do something else to get this working on touch? I have the build set to debug and not link at the moment.

Regards,
Felix
_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch


_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Using resx resources on monotouch

Felix Collins


On 9/03/2012 2:10 a.m., Rolf Bjarne Kvinge wrote:
> Which version of MonoTouch are you using? This should be working in the 5.2 release (but it wasn't in earlier releases).
Monotouch 5.2.5
_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Using resx resources on monotouch

Felix Collins
Just to expand.  I can see the strings from my default resource file in in the main DLL.  The strings from the other localised rsource files are in dlls that reside in sub folders (in the.app file) named for the locale and with ".resources" appended to the root name of the main dll. I assume that arrangement is correct (I've never had to dig into how this all works before - it just worked on other platforms!).

What was the problem previously (prior to 5.2)? Issue number?  I may be able to track down what is going wrong if I have a clue.

Cheers,
Felix

_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Using resx resources on monotouch

Rolf Bjarne Kvinge
Hi,

I'm pretty sure there was a bug about it, but now I can't find it.

In any case there is a test project in this bug: https://bugzilla.xamarin.com/show_bug.cgi?id=3708 you can use to see how it's done there: just make sure you apply the workaround mentioned in the first comment in the bug (so you don't run into the issue that bug's about).

Rolf

On Thu, Mar 8, 2012 at 9:16 PM, Felix Collins <[hidden email]> wrote:
Just to expand.  I can see the strings from my default resource file in in the main DLL.  The strings from the other localised rsource files are in dlls that reside in sub folders (in the.app file) named for the locale and with ".resources" appended to the root name of the main dll. I assume that arrangement is correct (I've never had to dig into how this all works before - it just worked on other platforms!).

What was the problem previously (prior to 5.2)? Issue number?  I may be able to track down what is going wrong if I have a clue.

Cheers,
Felix


_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch


_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Using resx resources on monotouch

Felix Collins

On 9/03/2012 11:46 a.m., Rolf Bjarne Kvinge wrote:
> Hi,
>
> I'm pretty sure there was a bug about it, but now I can't find it.
>
> In any case there is a test project in this bug: https://bugzilla.xamarin.com/show_bug.cgi?id=3708 you can use to see how it's done there: just make sure you apply the workaround mentioned in the first comment in the bug (so you don't run into the issue that bug's about).
>
Thanks for that. That test project worked fine for me so I knew it should all work and it lead me to figure out what was wrong.  Unfortunately now I'm in a bind caught between two limitations of the system.

My situation is this:

The project is cross platform for droid and touch with a test version on console for .net and mono. The resource strings are considered to be a cross platform part of the project and so are in the cross platform project (call it xplatform for arguments sake). To build xplatform for the three different platforms in the same solution I have three projects in the solution called xplatform, xplatform.MT and xplatform.MD with identical files but referencing different mono libs and targeting different platforms for the output.

To get the resources to load properly it looks as though the output files from the three projects should all be called xplatform.dll. If I call one of them xplatform.MT.dll then the resourcemanager need to load that file for the base resources ad so the resources are no longer handled in a cross platform way. It is possible in the project options to have the dll filename set differently from the project name so I tried that. For xplatform.MT I set the output file to xplatform.dll. I reset the iOS simulator and did a rebuild all. Unfortunately there seems to be a bug in monodevelop or monotouch somewhere because now when the application tries to load it crashes on loading.  So it seems that the project name and it's dll filename must be the same in monotouch.

Does anyone have a good idea for working around this? At the moment I'm considering moving the resources into the platform specific parts of the application despite the fact that they will all use the same files and this will preclude using string resources in the cross platform code (not ideal).

The crash info from the application output window is below... (note that the executable is also called xplatform) When I change the output .dll name back to xplatform.MT.dll and rebuild/reset simulator then the exception goes away. Oh, another thing I checked was that the xplatform.dll that is deployed to the simulator really is the one that is targeted to monotouch (the files are different sizes and output to different directories to avoid overwriting).

Launching application
Application launched. PID = 4903
Loaded assembly: /Developer/MonoTouch/usr/lib/mono/2.1/monotouch.dll [External]
Loaded assembly: /Developer/MonoTouch/usr/lib/mono/2.1/System.Core.dll [External]
Loaded assembly: /Developer/MonoTouch/usr/lib/mono/2.1/System.dll [External]
Thread started:
Stacktrace:

   at (wrapper managed-to-native) System.Reflection.Assembly.GetTypes (System.Reflection.Assembly,bool) <IL 0x0002e, 0xffffffff>
   at System.Reflection.Assembly.GetTypes () [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Reflection/Assembly.cs:357
   at MonoTouch.ObjCRuntime.Runtime.RegisterAssembly (System.Reflection.Assembly) [0x00062] in /Developer/MonoTouch/Source/monotouch/src/ObjCRuntime/Runtime.cs:92
   at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <IL 0x00050, 0xffffffff>

Native stacktrace:

     0   xplatform                        0x000908ec mono_handle_native_sigsegv + 284
     1   xplatform                        0x00005c88 mono_sigsegv_signal_handler + 248
     2   libsystem_c.dylib                   0x9c0d459b _sigtramp + 43
     3   ???                                 0xffffffff 0x0 + 4294967295
     4   ???                                 0x099ef64f 0x0 + 161412687
     5   ???                                 0x099ef5b2 0x0 + 161412530
     6   ???                                 0x099883f7 0x0 + 160990199
     7   ???                                 0x0998873e 0x0 + 160991038
     8   xplatform                        0x00009ff2 mono_jit_runtime_invoke + 722
     9   xplatform                        0x00169eee mono_runtime_invoke + 126
     10  xplatform                        0x0020267f monotouch_register + 95
     11  xplatform                        0x002115d7 main + 2583
     12  xplatform                        0x00003045 start + 53
     13  ???                                 0x00000005 0x0 + 5

=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================

_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Using resx resources on monotouch

Rolf Bjarne Kvinge
Hi,

The crash you are seeing looks like an older bug (which version of MonoTouch are you using?) where references got stale somehow.

Can you try doing the rename, and then delete the bin and obj directories in all the project directories, before you rebuild. Also ensure you clean the iOS simulator (in the main menu, "iOS Simulator -> Reset Contents and Settings" first.

If this doesn't work you should file a bug, it's clearly a scenario that should work.

I hope this helps,
Rolf

On Mon, Mar 12, 2012 at 11:12 PM, Felix Collins <[hidden email]> wrote:

On 9/03/2012 11:46 a.m., Rolf Bjarne Kvinge wrote:
Hi,

I'm pretty sure there was a bug about it, but now I can't find it.

In any case there is a test project in this bug: https://bugzilla.xamarin.com/show_bug.cgi?id=3708 you can use to see how it's done there: just make sure you apply the workaround mentioned in the first comment in the bug (so you don't run into the issue that bug's about).

Thanks for that. That test project worked fine for me so I knew it should all work and it lead me to figure out what was wrong.  Unfortunately now I'm in a bind caught between two limitations of the system.

My situation is this:

The project is cross platform for droid and touch with a test version on console for .net and mono. The resource strings are considered to be a cross platform part of the project and so are in the cross platform project (call it xplatform for arguments sake). To build xplatform for the three different platforms in the same solution I have three projects in the solution called xplatform, xplatform.MT and xplatform.MD with identical files but referencing different mono libs and targeting different platforms for the output.

To get the resources to load properly it looks as though the output files from the three projects should all be called xplatform.dll. If I call one of them xplatform.MT.dll then the resourcemanager need to load that file for the base resources ad so the resources are no longer handled in a cross platform way. It is possible in the project options to have the dll filename set differently from the project name so I tried that. For xplatform.MT I set the output file to xplatform.dll. I reset the iOS simulator and did a rebuild all. Unfortunately there seems to be a bug in monodevelop or monotouch somewhere because now when the application tries to load it crashes on loading.  So it seems that the project name and it's dll filename must be the same in monotouch.

Does anyone have a good idea for working around this? At the moment I'm considering moving the resources into the platform specific parts of the application despite the fact that they will all use the same files and this will preclude using string resources in the cross platform code (not ideal).

The crash info from the application output window is below... (note that the executable is also called xplatform) When I change the output .dll name back to xplatform.MT.dll and rebuild/reset simulator then the exception goes away. Oh, another thing I checked was that the xplatform.dll that is deployed to the simulator really is the one that is targeted to monotouch (the files are different sizes and output to different directories to avoid overwriting).

Launching application
Application launched. PID = 4903
Loaded assembly: /Developer/MonoTouch/usr/lib/mono/2.1/monotouch.dll [External]
Loaded assembly: /Developer/MonoTouch/usr/lib/mono/2.1/System.Core.dll [External]
Loaded assembly: /Developer/MonoTouch/usr/lib/mono/2.1/System.dll [External]
Thread started:
Stacktrace:

 at (wrapper managed-to-native) System.Reflection.Assembly.GetTypes (System.Reflection.Assembly,bool) <IL 0x0002e, 0xffffffff>
 at System.Reflection.Assembly.GetTypes () [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Reflection/Assembly.cs:357
 at MonoTouch.ObjCRuntime.Runtime.RegisterAssembly (System.Reflection.Assembly) [0x00062] in /Developer/MonoTouch/Source/monotouch/src/ObjCRuntime/Runtime.cs:92
 at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <IL 0x00050, 0xffffffff>

Native stacktrace:

   0   xplatform                        0x000908ec mono_handle_native_sigsegv + 284
   1   xplatform                        0x00005c88 mono_sigsegv_signal_handler + 248
   2   libsystem_c.dylib                   0x9c0d459b _sigtramp + 43
   3   ???                                 0xffffffff 0x0 + 4294967295
   4   ???                                 0x099ef64f 0x0 + 161412687
   5   ???                                 0x099ef5b2 0x0 + 161412530
   6   ???                                 0x099883f7 0x0 + 160990199
   7   ???                                 0x0998873e 0x0 + 160991038
   8   xplatform                        0x00009ff2 mono_jit_runtime_invoke + 722
   9   xplatform                        0x00169eee mono_runtime_invoke + 126
   10  xplatform                        0x0020267f monotouch_register + 95
   11  xplatform                        0x002115d7 main + 2583
   12  xplatform                        0x00003045 start + 53
   13  ???                                 0x00000005 0x0 + 5

=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================


_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch


_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Using resx resources on monotouch

Felix Collins
In reply to this post by Felix Collins



On 13/03/2012 11:38 a.m., Rolf Bjarne Kvinge wrote:
>  Hi,
>
>  The crash you are seeing looks like an older bug (which version of MonoTouch are you using?) where references got stale somehow.
>
Monotouch 5.2.5
Monodevelop 2.8.6.5
Xcode 4.2.1
MacOSX 10.7.3

>  Can you try doing the rename, and then delete the bin and obj directories in all the project directories, before you rebuild. Also ensure you clean the iOS simulator (in the main menu, "iOS Simulator ->  Reset Contents and Settings" first.
Tried it.  Same issue.
>
>  If this doesn't work you should file a bug, it's clearly a scenario that should work.
>
Hmmm. I just tried a test solution to isolate the problem and it worked.  Then I tried naming the output of the referenced dll with the same base name as the executable.  This failed.  So it seems that it is not possible to have MyAssembly.dll and MyAssembly.exe (or whatever) in the same solution.  Is is legal to do this (it seems to work for a console app on mac/windows)?  If it is, then the bug is in Monotouch.  If not then Monodevelop or the compiler should throw an error about ambiguous references.

I have a test project I can send.  I would file a bug but I'm not sure where the fault lies.

Now back to trying to get the resources to load...
Regards,
Felix



_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Using resx resources on monotouch

Felix Collins
In reply to this post by Rolf Bjarne Kvinge
Okay. In case anyone is following this thread I managed to get resources going in a nice cross platform way.
The resources are compiled in a crossplatform lib that is compiled in several projects to target the different platforms. The problems I was having turned out to all be red herrings. Once I got the executable named a different name to the cross platform lib and got my constructor arguments to ResourceManager sorted it all worked.
Thanks for the help.
_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch
Loading...