In a Visual Studio resource file (.resx) for a C# project I've located strange entries which start with two greater-than signs (>>), e.g.:
<data name=">>$this.Type" xml:space="preserve">
<value>Framework.Forms.MyForm, Framework, Version=1.1.5127.0, Culture=neutral, PublicKeyToken=f4aaf1fba1062dc8</value>
</data>
These entries sort of reference various classes (MyForm, MyButton, etc.) in a custom framework library but in an outdated version.
Are these entries still valid? Should I change them so that they reference the current framework version? Do they have an impact on the project? Why does the name start with >>?
This is how .Net/Winforms stores text resources from Windows forms classes, if you have set "Localizable" to "True". This way, they are taken out of the .designer.cs code and are put into a resource file (one for every language supported) that can be switched, depending on the chosen language.
This is at least the one case I know, where resources appear that start with ">>".
Related
I used to program WinForm .net Framework Applications. There I used the .exe.config (via "Settings" - Scope "Application" in VS).
With that, I could change the entries of the .config file after being deployed, and I was able to access these changed entries easyly via Properties.Settings.Default..
Is there an easy way to do similar things in .net6 WinForms? I couldn't find "the whole story" anywhere (how to define such settings, how to make them editable after having compiled the program and how to access the Settings in cSharp.
I am building an application for UWP in Visual Studio 2017 (it is actually a Unity game, the solution is exported from Unity). During build, I get the following warnings, and the files which are reported as such do not show up in the final appxupload file, and thus cannot be found at runtime:
1>GENERATEPROJECTPRIFILE : warning PRI263: 0xdef01051 - No default or neutral resource given for 'Files/Data/GI/level1/ca51e77bb6146d425e0c9319844929a0.vis'. The application may throw an exception for certain user configurations when retrieving the resources.
There is a warning message for the resource situation in general, which reads like this:
1>GENERATEPROJECTPRIFILE : warning PRI257: 0xdef00522 - Resources found for language(s) 'be,ca,fa' but no resources found for default language(s): ''. Change the default language or qualify resources with the default language. http://go.microsoft.com/fwlink/?LinkId=231899
The languages that are reported as such are in folders which have language iso codes (for example, in the error message, the file is actually in the folder Files/Data/GI/level1/ca/). However, these folders are NOT language specific, they are named this way due to an internal indexing scheme of Unity which I cannot change.
So, what I am asking is this: How, and where, can I configure Visual Studio or whatever part of MSBuild is responsible to NOT treat these folders as language-specific? Or is there any other solution to this problem?
Thank you.
I found a solution/workaround. Part of the build is a call to makepri.exe which creates the Package Resource Index (PRI) files which more or less contain a directory of files in the build. Makepri, by default, looks for language-named folders and splits the build along the languages it finds - which moves the language-specific files into resource packs.
Luckily, this behavior can be configured, as is described here - makepri can be instructed to just place everything in one big resource file instead of splitting up. This is achieved by editing the .csproj file, and adding the following two lines to the configuration section for Master|x64:
<AppxBundleAutoResourcePackageQualifiers>
DXFeatureLevel
</AppxBundleAutoResourcePackageQualifiers>
<AppxDefaultResourceQualifiers>
Language=en-us;de-de;es-es
</AppxDefaultResourceQualifiers>
The first tag disables auto-language qualifiers (since "Language" is MISSING from the list of qualifiers). Since languages are now no longer auto-detected, they must be explicitly listed (second tag).
I've not found a way to do what I originally wanted - specifying that certain folders should not be considered language-specific - but this works for me.
I have a question regrading the localization of WinRT-Apps.
As far as I know the system works like that:
Strings || Resources
de-DE
Resources.resw
en-US
Resources.resw
etc.
Resources.resw
So far, this folder structure is implemented in my project.
In my Package.appxmanifest the "Default Language" is set to "en-US", so everything should be okay from my point of view, if language is not supported it should fall back to "en-US", since it's set there.
But if I compile the stuff, in the Output-Box from VS I get a warning from MakePRI
2>MakePRI : warning 0xdef01051: No default or neutral resource given for 'Resources/String'. The application may throw an exception for certain user configurations when retrieving the resources.
I searched so far and found only things that are related to the Advertising SDK from MS, which I don't use in my project, so the problem shouldn't be there.
Why is MakePRI giving me this message, where I'm wrong?
Just for the records: I had the same warning when building a Windows 8.1 Store Universal App (Windows + Windows Phone). My project contains a folder with images which are used as pinpoint markers on a map. The folder names were
Assets/marker/yes/foo.png
Assets/marker/yes/bar.png
Assets/marker/yes/baz.png
...
Assets/marker/no/foo.png
Assets/marker/no/bar.png
Assets/marker/no/baz.png
...
The separation in yes/no subfolders is appliation-specific. My program uses markers inidicating the presence/absence of something on a map.
For each element under Assets/marker I got twice the warning below - one for the Windows project and the other for the Windows Phone project.
MakePRI : warning 0xdef01051: No default or neutral resource given for ...
According to the MakerPRI documentation the resource indexing system tries to recognize language identifiers in folder and file names. I figured that the reason for the warning was the folder name "no". MakerPRI interpreted it as "Norwegian" and rightfully complaint that my project contains resources which are available in one language but not for all languages.
I changed the folder name "no" to something else and the warnings were gone. So bottomline is that one should be careful with file names and folder names which could be misinterpreted as language tags. Here is a list of all available language tags.
This error means that you have a localized string named "String" which is not defined in your default "en-US\Resources.resw" file.
If you look in your "de-DE\Resources.resw" file you should find the entry. You will have to report it to the default file or delete it if it is not needed.
All the strings which exist in your non-default localization files must have a default value in the default language file.
I have a situation where in I have a string that should contain today's date in it..
the issue is that I need to put that string including today's date in the .resx file.
is there any way to do that?
e.g.
lets say about copyright string
it should be copyright-2012-abc is today's date is of year 2012
&it should be copyright-2013-abc is today's date is of year 2013
EDIT:
I m going to use the resource file for this copyright thing only.
it will be static for all other things just that year value will be changing with every passing year just like in the example.
There is no built-in way to add "current environment" values to RESX (or any other C# related files).
But you can relatively easy create pre-build rule that will call your custom script/tool that will modify your RESX file to your liking.
One option it to create tool that will genreate a file that later included in the RESX file. This way you avoid modification of RESX file itself (which could be problematic if RESX is under source control). Depending on your need simple date /t > ..\..\out.txt with out.txt include in RESX maybe enough.
Steps to include a file created at build time into RESX:
Add TextFile1.txt to your project
Drop that file on {resourceFileName}.RESX (in design mode)
Check if {resourceFileName}.Designer.cs is updated with new property to access content of the new resource
In Solution explorer chose properties of your project and open "Build Events" tab
Add "date /t > ....\TextFile1.txt" to pre-build steps (will dump current date into "TextFile1.txt"
Build and use new resource variable i.e. Console.WriteLine(Resource1.TextFile1)
RESX sample content:
<data name="TextFile1" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>textfile1.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
resx is for storing static resource. Though there could be hack to change resx at run time, or during development time through some sort of scripting, however, both introduce too much complexity for little feature.
If you could clarify the use cases of such copyright string, readers might be able to provide more concrete suggestion. Say, do you use the string only for displaying in an About box? or assembly attribute?
I'm developing a C# solution where I use files as external resources.
I need to this files to be modified without building all solution again.
I used to have shuch configuration and all went well.
I don't remember what I changed but now all resources are embedded in .exe file, I cannot find a way to make them linked again.
In resource properties in all resources Persistence option is diabled and is set to Linked at compile time, so I don't think this is the problem because I think it must be this way.
I think it could be a language configuration, problem started when I changed a form language propiertie that created an language specific resx but later it returned to its original configuration.
Thanks
Take them out of resources, add (add existing file) them to the project, make sure you set the properties on each one to copy if newer, assuming you are happy to have them deployed in to the same folder as the exe/dll that depends on them.