Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / February 2005

Tip: Looking for answers? Try searching our database.

Using images on windows forms, stored in a dotnet assembly (dll).

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Emmanuel - 06 Feb 2005 20:44 GMT
Hi,

I am creating a multi assembly windows application.

I want to store all the images or/and icons of my application to a single
dll (as resources ?) and use them from there, when needed, on other
assemblies containing windows forms.

I want to be able to use them from code (using enumerations for example) and
from the designer when designing windows forms (if possible).

Does anyone know, how can I accomplish this technic ?

Thank you

Emmanuel
"Jeffrey Tan[MSFT]" - 07 Feb 2005 02:42 GMT
Hi Emmanuel,

Thanks for your posting!!

In .Net, the assembly that only contains resource is called Satellite
Assembly. So we may store the resource in Satellite Assemblies, then
manipulate the resource from them.

For how to create Satellite Assemblies, please refer to:
"Creating Satellite Assemblies"
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm
l/cpconcreatingsatelliteassemblies.asp

For how to retrieve resource from Satellite Assemblies, please refer to:
"Retrieving Resources in Satellite Assemblies"
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm
l/cpconlocalizingresources.asp
"How to read satellite assemblies resources in ASP.NET"
http://www.codeproject.com/aspnet/SatResourcesDemo.asp

Here is a C# sample project for how to operating Satellite Assemblies:
"LocalizedHelloWorld Sample: Demonstrates Satellite Assemblies for Console
Applications"
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cssample/ht
ml/vcsamLocalizedHelloWorld.asp

Hope this helps.
==============================================================
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Signature

Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Emmanuel - 07 Feb 2005 20:23 GMT
Jeffrey,

thank you for your feedback.
I have read most of the articles but there are some things that are not yet
clear to
me:

In order to store the images/icons to resource files and from them create
the satellite assemblies, do I have to write a separate program that does
the job ?

Is there a way to do this using the Visual Studio interface ?

CREATING THE RESOURCES:

Can I Create the .resources, or whatever file is needed, using the VS
interface ?
Can I then place this resource file inside a new project which I will
include in my solution ?

USING THE RESOURCES IN VISUAL STUDIO FORM DESIGNER:

I thing that I understand how can I use the resources inside a satellite
assembly using code.
I can just repeat the code that the forms designer generates when creating a
form that contains resources.

But how can I use the satellite assembly and its resources inside the
designer ???

If I want to use an Icon or bitmap that it is stored in a satelite assembly
how can I refer to it when
I am in the Forms Designer. For example, let's say that I want to place a
bitmap/icon from the
satellite assembly to a windows form button. How can I do that, using the
designer ?

For the moment I am not interested at all for form localization issues.

Thanks again

Emmanuel
Steven Cheng[MSFT] - 08 Feb 2005 05:44 GMT
Hi Emmanuel,

Welcome to .net community. As for the .net resource files and satellite  
assemblies, they are pure resources containers which only contains resource
objects( string , image  or other serializable objects). Also, resource
file and satellite assembly are all binary files which are not human
readable. So we can manually embed .resource file into VS.NET project, but
it display it as binary file (not readable or editable format).

In fact, in VS.NET we use .resx( assembly resource file) to manipulate
resources. And when we build our project, the VS.NET will compile the .resx
file into .resource file and embeded the generated resource file into main
assembly(or satellite assembly) according to its cultureinfo.

So the first question you mentioned:
CREATING THE RESOURCES:

I think we can just create ".resx" file (add new item----> assembly
resource file) and add items into it. But the VS.NET IDE dosn't provide
full support for editing .resx file. If we want to add some binary data
such as image or our custom objects, it is recommended that we create a
separate application to generate resource (.resx). And the "ResEditor" is a
good tool (shipped with VS.NET as buildin tool in whidbey) for editing
existed resource or resx file).

USING THE RESOURCES IN VISUAL STUDIO FORM DESIGNER:

As for using resource in VS.NET design-time, I'm afraid there hasn't been
any means currently. As we could see, when we create different
resource(.resx) file for a locallized form , the VS.NET's design-time work
is just generate the code  in the InitializeComponents method , and those
auto generated code also use the  ResourceManager to retrieve the objects
from the assembly's embeded resources. So there is no means to directly use
items in resource files at design-time( at least no buildin api now).

Thanks & Regards,

Thanks & Regards,

Steven Cheng
Microsoft Online Support

Signature

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Emmanuel - 08 Feb 2005 11:48 GMT
Steven,

thank you very much for your answer.

But to clarify the things a little bit I would summarize your answer to the
following:

If someone wants to develop a "Word-Ready Application" as mentioned at the
.NET's Framework help file, and wants to put together the images and other
resources used in the application in an assembly file (dll), he has only one
way of doing it:

THE GOOD
===========
Creating the resources:
He should create another windows application, that gathers all resources
from the development directories and stuffs them inside a .resource file.
The resource file is then embeded inside the assembly during compilation
process. The class involved is the System.Resources.ResourceWriter class and
the related.

Using the resources:
Resources that reside in a separate satellite assembly can be used ONLY BY
CODE. using the System.Resources.ResourceReader class and the related.

THE BAD
=======
So Visual Studio integrated environment:

1. Cannot in any way create resource files (with images of course) nor you
can edit resource files with the tools provided by Visual Studio .NET 2003.
(A new tool called "ResEditor" will be available when the new version of
Visual Studio becomes available...)

2. The resource files in satellite assemblies cannot be used by the Form
Designer. So you cannot design forms using resources that reside in a
different satellite assembly.

Thanks again
Emmanuel

> Hi Emmanuel,
>
[quoted text clipped - 45 lines]
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
Steven Cheng[MSFT] - 10 Feb 2005 07:33 GMT
Thanks for your followup Emmanuel,

Yes, the currently resource manipulation support in VS.NET( until 2003) are
limited. And we can manually create and edit resx file(not .resource) file
and even the resx file's manipluation is limited( there hasn't a good edior
for resource in the current IDE).  And form designer's support for resource
manipulation( for resx file) are only available when we dealing with
localizable form.

Thanks & Regards,

Steven Cheng
Microsoft Online Support

Signature

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.