I am getting ERRORS when I try to use MSBuild or LocBaml with a WPF Application. Here is what I am doing.
I need help in learning how toLocalize an WPF Application according to Microsoft textbook "MCTS EXAM 70-511 Windows Application Development with Microsoft .NET Framework 4 (Self-Paced Training Kit)", starting at the bottom of page 472.
STEP 1:
First, I built a very simple WPF application. The XAML is shown below:
MainWindow.xaml
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="100" Width="300">
<Grid>
<Label Content="Title" Name="label1"/>
</Grid>
</Window>
Step 2:
Then, I un-commented the following line is "AssemlyInfo.cs" and rebuild the project.
AssemlyInfo.cs
[assembly:NeutralResourcesLanguage("en-US",UltimateResourceFallbackLocation.Satellite)]
Step 3:
Third, I opened my csproj file "WpfApplication1.csproj" in Notepad and added the following line within the<PropertyGroup> tag, saved the file, reopened the project in VS2010 and rebuild the application.
WpfApplication1.csproj
<UICulture>en-US</UICulture>
Step 4:
Then I attempted to have MSBuild.exe add all the Uid tags in my XAML file. But that did not work. So I attempted manually in insert the Uid tag, and that also did not work. Below are the details.
I copied the MSBuild.exe file into the directory that held the .csproj file, opened a command prompt, and attempted to run the following command:
MSBuild /t:updateuid WpfApplication1.csproj
In reply, I received the following error. I have copied exactly what was in the command prompt.
Information from Command Prompt (2010) window
Setting environment for using Microsoft Visual Studio 2010 x86 tools.
c:\WpfApplication1\WpfApplication1>MSBuild /t:updateuid WpfApplication1.csproj
Microsoft ® Build Engine Version 4.0.30319.1
[Microsoft .NET Framework, Version 4.0.30319.2391]
Copyright (C) Microsoft Corporation 2007. All rights reserved.
Build started 11/28/2011 12:56:42 PM.
Project "c:\WpfApplication1\WpfApplication1\WpfApplication1.csproj" on node 1(updateuid target(s)).
c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets(483.9): error : The OutputPath property is not set for project 'WpfApplication1.csproj'. Please check to make sure that you have specified a valid combination of Configuration and Platform for this project. Configuration='Debug' Platform='MCD. You may be seeing this message because you are trying to build a project without a solution file, and have specified a non-default Configuration or Platform that doesn't exist for this project. [c:\WpfApplication1\WpfApplication1\WpfApplication1.csproj]
Done Building Project "c:\WpfApplication1\WpfApplication1\WpfApplication1.csproj" (updateuid target(s)) -- FAILED.
Build FAILED.
"c:\WpfApplication1\WpfApplication1\WpfApplication1.csproj" (updateuid target(s)) ->
(_CheckForInvalidConfigurationAndPlatform target) ->
c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.target(483.9): error : The OutputPath property is not set for project 'WpfApplication1.csproj'. Please check to make sure that you have specified a valid combination of Configuration and Platform for this project. Configuration='Debug' Platform='MCD. You may be seeing this message because you are trying to build a project without a solution file, and have specified a non-default Configuration or Platform that doesn't exist for this project. [c:\WpfApplication1\WpfApplication1\WpfApplication1.csproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.09
c:\WpfApplication1\WpfApplication1>
So, I checked the properties of the MSBuld.exe by right-clicking it and selecting properties. Below is what I saw.
Information from "Details" tab from MSBuild.exe Properties
File description MSBuild.exe
Type Application
File version 4.0.30319.1
Product name Microsoft® .NET Framework
Product version 4.0.30319.1
Copyright ©Microsoft Corporation. All rights reserved.
Size 129 KB
Data modified 3/18/2010 5:23 PM
Language English (United States)
Original filename MSBuild.exe
Then, I decided that instead of using MSBuild to add the Uid tags to my XAML file, I would manually insert at least one myself. See the XAML file below, and rebuild the project.
MainWindow.xaml
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="100" Width="300">
<Grid>
<Label Content="Title" Name="label1"x:Uid="label1" />
</Grid>
</Window>
Step 5:
Then I attempted to run LocBaml. I copied LocBaml.exe into the Debug folder, and run it in the Command Prompt (2010) window. Here is what I typed:
LocBaml /parse en-US\WpfApplication1.resources.dll /out:My.csv
Here is the error I got back from that attempt.
Command Prompt Window
c:\WpfApplication1\WpfApplication1\bin\Debug>LocBaml /parse en-US\WpfApplication1.resources.dll
Microsoft (R) Baml Localization Utility 0.0.0.0
Copyright (C) Microsoft Corporation 2005. All rights reserved.
Could not load file or assembly 'file:///c:\WpfApplication1\WpfApplication1\bin\Debug\en-US\WpfApplication1.resources.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format.
c:\WpfApplication1\WpfApplication1\bin\Debug>
So, I checked the properties of the MSBuld.exe by right-clicking it and selecting properties. Below is what I saw.
Information from "Details" tab from LocBaml.exe Properties
File description
Type Application
File version 0.0.0.0
Product name
Product version 0.0.0.0
Copyright
Size 34.5 KB
Data modified 11/18/2010 2:26 PM
Language Language Neutral
Original filename LocBaml.exe
Summary
Now I have tried many other procedure combinations go get localization to work. My objection is to do it the why the book says to since that most likely will be on the exam. I have found other procedures on the internet from good quality writers, but I think I need to learn this method. What am I doing wrong? Or what system problem do I have?
Thanks for reading this and helping me.
Mike