Hi,
>> Hi,
>>
[quoted text clipped - 23 lines]
>
> I'm using 3.0.
Oh, duh *LOL* Answering to a post in the WPF newsgroup, this should be
obvious to me. Sorry. I spend too much time in the ASP.NET and C# NGs ;-)
> I tried iterating the Resource names - only 1 resource
> was shown even though I have 2 files added to my resx file. It returned
> 'db.test_resource.resources' where db is my app name and test_resources
> is my resource file name. I'm not sure where it got the final resources
> string from. I also tried iterating GetModules ( only returned db.exe )
> and GetFiles ( returned path_to_exe\db.exe ) without any luck.
I suspect that you add the files to the RESX file the old (1.1) way.
To add a file to resources in the 2.0 (and 3.0) way, you do as follow:
1) Add the XAML file to your project, using "Add existing file". The
file may be in a folder too, that's OK.
2) Select the file, select Properties (F4)
3) Set "Build action" to "Embedded resource"
Voilà. Next time you compile, the file will be added to the DLL without
you having to fiddle with the RESX file. Neat ;-)
After this, it should occur in the Resource names as standalone.
> The relevant portion of the resx file looks like this
>
[quoted text clipped - 4 lines]
> PublicKeyToken=b77a5c561934e089;Windows-1252</value>
> </data>
Yes. Use the other way described above, it's easier and will act as
expected.
> The only other thing that may be an issue is that I'm calling
> Assembly::GetExecutingAssembly() to get the Assembly. That seemed to
> work when I needed an Assembly to pass into the ResourceManager
> constructor. If I need to call GetAssembly I'm not sure what type to
> pass into that call.
GetExecutingAssembly() will return the current assembly, which is
probably fine for that you do. My code is generic, I use it in a Utility
class to extract resources embedded in any assembly, which I identify
using a type present in that assembly.
HTH,
Laurent

Signature
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
John Dunn - 04 Dec 2006 20:45 GMT
> 1) Add the XAML file to your project, using "Add existing file". The
> file may be in a folder too, that's OK.
>
> 2) Select the file, select Properties (F4)
>
> 3) Set "Build action" to "Embedded resource"
Step 2 isn't working for me. I add the resource with the 'Add existing file...'
button and the only properties I can set on my resource are (Name), Comment and
FileType. Filename, Persistance and Type are grayed out on any of the files I add.
I tried adding an image and I could then change the Perstance to either 'Link at
compile time' or 'Embedded in Resx'. Trying either of those didn't make the
image show up in GetManifestResourceNames.
I'm guessing that I'm missing an obvious step since this is my first foray into
Resource Assemblies.
John
Laurent Bugnion - 04 Dec 2006 21:45 GMT
Hi,
>> 1) Add the XAML file to your project, using "Add existing file". The
>> file may be in a folder too, that's OK.
[quoted text clipped - 7 lines]
> (Name), Comment and FileType. Filename, Persistance and Type are grayed
> out on any of the files I add.
Strange. I just tried it again on a WPF application here, just to be
sure, and it works fine. I created a "Resources" folder, then added a
new ResourceDictionary (MyFile.xaml) in it, and then I can set the Build
action as I described. BTW, I use Visual Studio 2005 professional.
Can you tell me which type of project you created (WPF application?
XBAP? other?) and which version of the .NET Framework 3.0 you're using?
Oh, and also, which version of Visual Studio are you using?
Also, if you want, can you send me the project files zipped? (my email
address is genuine). Really curious why it doesn't work.
> I tried adding an image and I could then change the Perstance to either
> 'Link at compile time' or 'Embedded in Resx'. Trying either of those
[quoted text clipped - 4 lines]
>
> John
HTH,
Laurent

Signature
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
John Dunn - 04 Dec 2006 22:57 GMT
> Can you tell me which type of project you created (WPF application?
> XBAP? other?) and which version of the .NET Framework 3.0 you're using?
> Oh, and also, which version of Visual Studio are you using?
I'm guessing the problem is that I'm writing a C++/CLI application. It doesn't
look like I have access to the same set of resource properties that C# apps
have. I'm using VS2005 so I'll send you a zipped project but I'm probably out of
luck.
I did a quick WPF project and I do get the Embedded Resource option.
John
Laurent Bugnion - 05 Dec 2006 07:04 GMT
Hi John,
>> Can you tell me which type of project you created (WPF application?
>> XBAP? other?) and which version of the .NET Framework 3.0 you're
[quoted text clipped - 8 lines]
>
> John
I got your files. Yes, I guess that you cannot embed files in an
assembly the same way in C++ as you do in C#. I wasn't aware of the fact
(never tried managed C++, my experiences with C++ were in the embedded
world only, and a few years ago ;-)
I think that your idea to create a C# assembly for resources is a good
one. I hope that'll work better.
Greetings,
Laurent

Signature
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch