Oreintation Aware Control Revisited

few days back i have posted about the orientation aware control (OAc) , how much it  is beneficial to the mobile development and other stuf.

well while working with oac i observed that , the resource names generated follow the VS naming convention as they are generated by build process. , and your source code should follow certain heirarchy, otherwise your resources will be named incorrectly. Also OAC expects all the resources to be embeded in the main assembly and file based resources will not be loaded,OAC utilizes Localization feature of .net framework, but overrides the component resrouce manager to look for resource in the main assembly only ,

for my aplication it was more desirable to have resource splitted in to culture base resources, for each resolution. after spending some time with msbuild i found that this is acheivable.

for generating proper resource names i used <LogicalName>myresourcename.resource</LogicalName>

for generating separte setallite assemblies for each resource. i added few build action

<AvailableItemName Include=”EmbeddedResource320_240″ />
<AvailableItemName Include=”EmbeddedResource480_640″ />
<AvailableItemName Include=”EmbeddedResource640_480″ />

then updated build action of each resoultiion related resx to its build type , like abc.320-240.resx , will have build action “EmbeddedResource320_240″ and so on

and then override the After Res Gen build event in my project file

<Target Name=”AfterResGen”>

<CreateItem Include=”@(EmbeddedResource320_240)” AdditionalMetadata=”Culture=320-240″>
<Output TaskParameter=”Include” ItemName=”OACResrouceWithCustomCulture”/>

<CreateItem Include=”@(EmbeddedResource480_640)” AdditionalMetadata=”Culture=480-640″>
<Output TaskParameter=”Include” ItemName=”OACResrouceWithCustomCulture”/>

<CreateItem Include=”@(EmbeddedResource640_480)” AdditionalMetadata=”Culture=640-480″>
<Output TaskParameter=”Include” ItemName=”OACResrouceWithCustomCulture”/>

<Message Text=”@(OACResrouceWithCustomCulture) ” />
<MakeDir Directories=”$(IntermediateOutputPath)%(OACResrouceWithCustomCulture.Culture)”/>
<GenerateResource  Sources=”@(OACResrouceWithCustomCulture)” OutputResources=”@(OACResrouceWithCustomCulture->’$(IntermediateOutputPath)%(LogicalName)’)”>

<Output  TaskParameter=”OutputResources”     ItemName=”OACResrouces”/>
<Output  TaskParameter=”FilesWritten”     ItemName=”FileWrites”/>

<AL EmbedResources=”@(OACResrouces)”
OutputAssembly= “$(IntermediateOutputPath)%(OACResrouces.Culture)\$(TargetName).resources.dll”>

<Output TaskParameter=”OutputAssembly”     ItemName=”OACSatelliteAssemblies”/>


<Copy  SourceFiles=”@(OACSatelliteAssemblies)”

<Output TaskParameter=”DestinationFiles” ItemName=”FileWrites”/>



problem solved :D:D

i dont know the behavour when localizing control with different languages




3 responses to “Oreintation Aware Control Revisited

  1. Hi Faraz,

    above is good example of what I wanted to achieve, but still stuck at error. I would appreciate if you can help me out..

    I am trying to compile the resources file and then get a dll out of it. I am referenceing the PortalResources.dll in my library. My code is as follows. I get past all the lines, I put message it works fine till I get AL error AL1016 – no valid inputs specified. Please note that I do not have culture information, version or any other. AL specifies that there are no mandatory fields. Any help appreciated



    Thank you

  2. Portal.PortalResource


  3. i have sent you a mail at your specified email address. please check and reply as you can.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s