4

I have a form which has TableLayoutPanels, these table layout panels produce the following entries in the Resources.resx file,

tableLayoutPanel1.LayoutSettings    <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="txtOutput" Row="0" RowSpan="1" Column="2" ColumnSpan="4" /><Control Name="lblOutput" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="btnRetry" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="btnContinue" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="btnFail_Test" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="btnPass_Test" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="btnTimeOut" Row="1" RowSpan="1" Column="3" ColumnSpan="1" /><Control Name="btnViewLog" Row="1" RowSpan="1" Column="4" ColumnSpan="1" /><Control Name="btnAbort" Row="1" RowSpan="1" Column="5" ColumnSpan="1" /></Controls><Columns Styles="Percent,16.66667,Percent,16.66667,Percent,16.66667,Percent,16.66667,Percent,16.66667,Percent,16.66667,Absolute,20" /><Rows Styles="Percent,58.77193,Percent,41.22807,Absolute,20" /></TableLayoutSettings>

When I try to build the project, I get the following error,

Convert file C:\MyProject\ProjectName\FormName.resx to XLIFF format failed. Message:Unsupported processing instruction '?xml' found during encoding. Please remove unsupported processing instructions from the xml.

I have tried switching Localization of the form to "off", which allows me to build, but then I lose foreign language support.

NOTES:

  1. Deleting the tableLayoutPanel1.LayoutSettings from the resx file allows me to compile, but then my UI is completely destroyed.

  2. I am using Multilingual App Toolkit v4.0.1605.0

  3. Visual Studio Community 2015 Update 2

  4. Windows 7 64bit

  5. .NET4.5

Is there any way for me to fix this issue and use tableLayoutPanels and localization at the same time?

  • Why do you want to have this string in the .resx file? Does it need to be localized? – Jenszcz Jul 01 '16 at 09:15
  • @Jenszcz yes, I need to support different regions. – iamthemerovingian Jul 01 '16 at 09:24
  • Sorry for being thick, but I do not see which part of this string would be different for French than for English. Or is this about Bidirectional languages, and you want to provide a different column layout for Arabic and Hebrew? – Jenszcz Jul 01 '16 at 09:57
  • I'm no expert in this but here's what I know.... the resx files are used to save region specific data about the forms and well as general settings of controls. So when you localize a form it creates a localized resx "formname en-GB.resx" for example. The multi lingual app toolkit uses these resx files to generate a XLIFF file. That last stage is where my build fails. – iamthemerovingian Jul 01 '16 at 10:16
  • Exactly: the crucial bit is 'region specific data'. In my opinion this string `tableLayoutPanel1.LayoutSettings` is not region specific, and therefore it should not live in a resx file. If you have a look at this [video](https://www.youtube.com/watch?v=99Yn_gTfT4A) by Microsoft Build it says towards the end (28:06) that localizable strings should be put into resource files, but non-localizable strings should be hard coded. Unless your column layout is locale specific you should try hard-coding it. – Jenszcz Jul 01 '16 at 11:49
  • I've tried removing the table layout code from the localized resx file but that destroys the layout of my controls when I launch my application in a different language. Also VS keeps on adding this bit back in every time I delete it... so I seems to be fighting a system here... – iamthemerovingian Jul 01 '16 at 12:19
  • You should not only remove it from the localized resx file, but from all resx files and set the value somewhere in your form code. As long as it is in the source language VS will try to put it back into the target languages. – Jenszcz Jul 01 '16 at 12:38
  • Won't VS just put all the information I delete from the resx files back into them when I compile? That's what happens when I delete it from the main resx file and the localized version. VS puts it back. – iamthemerovingian Jul 01 '16 at 12:40
  • I am using Visual Studio 2013, and when I create a Form with a TableLayoutPanel I do not get any such string written to the project or form resx file. I'm afraid I have no idea where your string comes from - sorry. :-( – Jenszcz Jul 01 '16 at 13:04
  • It's not in the string section of the resx file. When you view the resx file in VS, on the top left hand side corner you will have a button with "Strings" written on it. Click it and you'll get a drop down where you can select "Other"..... the table layout settings will be there. – iamthemerovingian Jul 01 '16 at 13:08
  • Not for me - this could be different between VS 2013 and 2015. Sorry, I don't think I can help you there. – Jenszcz Jul 01 '16 at 13:13
  • Okay, thanks for trying. – iamthemerovingian Jul 01 '16 at 13:14
  • I'm facing the same issue, a suggestion to fix this bug can be found here : https://multilingualapptoolkit.uservoice.com/forums/231158-general/suggestions/15701274-fix-convert-problem-xml-with-embedded-xml-struc – Malick Aug 04 '17 at 10:33
  • @Malick do you happen to remember what the fix was? The uservoice community was shut down, and the only copy [Wayback Machine](https://web.archive.org/web/20200927193851/https://multilingualapptoolkit.uservoice.com/forums/231158-general/suggestions/15701274-fix-convert-problem-xml-with-embedded-xml-struc) has doesn't have any suggestions in it. – gcode May 18 '23 at 18:59
  • If anyone wants to join, I've posted this question over at the [Microsoft Q&A community](https://learn.microsoft.com/en-us/answers/questions/1287331/tablelayoutpanel-resx-property-generation-causes-m) in the hopes that this issue can work it's way up to the right person at MS. – gcode May 18 '23 at 19:22

2 Answers2

0

I simply removed the "<?xml version="1.0" encoding="utf-16"?>" and it seems to work for me. The XML declaration is optional in most XML. The biggest downside I see is that we've switched our encoding from utf-8 to utf-16. I looked at the embedded XML and didn't see any special characters. Since the file is utf-8, I think it would have to be an entity if there were any utf-16.

4 years later and it has not been fixed.

Bill
  • 19
  • 2
  • I know it's been several years since you posted this, but Visual Studio regenerates the XML data in the `.resx` file when the solution is reloaded. – gcode May 18 '23 at 19:00
0

The problem, as you're seeing, is that the Multilingual App Toolkit is localizing the LayoutSettings property into the Resx file, then attempting to convert that into an XLIFF file. It does this because it's important for a localized GUI to be able to adapt its layout to different locales. The TableLayoutPanel uses XML for its TypeConverter, and apparently the M.A.T cannot process that without error.

This appears to be a bug. One solution as Bill posted is to remove the offending XML header from values in your Resource file before compiling (removing the .resx XML header is not necessary), which will allow the compilation to complete. If possible, you may want to avoid using a TableLayoutPanel until Microsoft is able to fix the issue.

gcode
  • 2,954
  • 4
  • 21
  • 32