> Sure enough, as I've been racking my brain over this, a new build of
> NAnt (0.85 RC1) has been released. And the solution task doesn't
> crash on me the way it did in 0.84...
>
> I will give this a try, and report back when I do some clean-box
> testing on a machine with v1.0 only.
Nope, it's just as I feared: using NAnt's <solution> task to
down-level build an app with VS2003-generated resx files results in a
blowup, when I run the app on a clean v1.0-only test machine.
The blowup is especially noticeable if you set Localizable=true -- in
which case the emitted code attempts to read a bunch of stuff from the
ResourceManager that it otherwise might not. If Localizable=false,
you'll only hit the exception if you attempt to load in any big,
base64 encoded goo (like a bitmap for your BackgroundImage property,
for example).
I will take this issue up with the NAnt team, to make sure they know
about it, at least... honestly, I'm not sure it's fixable in the
general case.
But if anyone's curious, I'll explain what I plan on doing...
I need to support localization of my code base, but I *hate* storing
binary data inside resx files (I much prefer to keep my .ico's and
.bmp's and such in their own files, not embedded and hidden away in
the .resx) so... I'm just going to impose a rule on my team that no
binary data is allowed in .resx files!
I'll probably enforce this with a custom NAnt task to scan the .resx
files, pre-build -- I gotta open those files up anyway, to downgrade
all the elements from v1.0.5000.0 to v1.0.3300.0.
Thankfully, I've found that NAnt's <solution> task *does* give proper
treatment to "EmbeddedResource" files named with culture
identifiers... eg, the file "MyBackground.jpg" will be included in
the main assembly, while the file "MyBackground.en-CA.jpg" will be
included in the canadian satellite assembly, but under the same root
name "MyBackground.jpg".
So, instead of using ResourceManager to load this kind of binary goo,
I've written a few lines of helper code to grab it out of the
appropriate satellite assem (failing back to the main assem, if
necessary):
private static Image TryLoadLocalizedImageResource(string name)
{
System.Globalization.CultureInfo curruicult =
System.Threading.Thread.CurrentThread.CurrentUICulture;
System.Reflection.Assembly currassem =
System.Reflection.Assembly.GetExecutingAssembly();
try
{
System.Reflection.Assembly satellite =
currassem.GetSatelliteAssembly(curruicult);
return Image.FromStream(satellite.GetManifestResourceStream(name));
}
catch (System.IO.FileNotFoundException)
{
return Image.FromStream(currassem.GetManifestResourceStream(name));
}
}
Thanks for all the pointers, and the moral support, everyone...!
Cheers,
-S
===================================
This list is hosted by DevelopMentor� http://www.develop.com
Some .NET courses you may be interested in:
Essential .NET: building applications and components with C#
November 29 - December 3, in Los Angeles
http://www.develop.com/courses/edotnet
View archives and manage your subscription(s) at http://discuss.develop.com