473,508 Members | 2,053 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Resource file

Al
Hi,
I have created a solution with two projects in it - a class library and a
windows forms front end. I have added a resource file (Resources.resx) to the
class library and filled it with icons.
Does anybody know how would I go about using an icon from this resource file
in the windows forms project?
Thanks in advance,
Al.
May 3 '06 #1
2 6204
Al,

You can use the Icon's constructor overload that accept a Type and a
resource name. The type needs to be declared in the assembly where the
resource is. The constructor uses the type for 2 pieces of information:
assembly and namespace, so the type and the resource needs to be under the
same namespace in the same assembly.

Other possiblility is to use Assembly.GetManifestResourceStream to get a
stream with the resource data and load it from there. This is BTW what
internaly the Icon constructor uses.

From experience I can tell that the tricky part is to get the resource
namespace right. VS IDE for C# puts all the resources under the default
namespace (property of the project) and then it appends the names of any
subfolder that the file might be in. VB's IDE works differently. If you have
problems loading the resource I'd suggest to use the reflector tool to check
out what is the correct namespace of the resource.
--
HTH
Stoitcho Goutsev (100)
"Al" <Al@discussions.microsoft.com> wrote in message
news:61**********************************@microsof t.com...
Hi,
I have created a solution with two projects in it - a class library and a
windows forms front end. I have added a resource file (Resources.resx) to
the
class library and filled it with icons.
Does anybody know how would I go about using an icon from this resource
file
in the windows forms project?
Thanks in advance,
Al.

May 3 '06 #2
Al
Hi Stoitcho,
Thanks for your help. It is the namespace that I am struggling with. I have
followed your advice and downloaded Reflector from the web but I'm struggling
to see how I can use this to return the basename of my resource file in
ProjectA to construct my resource manager in ProjectB. I have tried just
using the namespace of ProjectA but it tells me 'Could not find any resources
appropriate for the specified culture or the neutral culture'.
Any further help would be great,
Al.

"Stoitcho Goutsev (100)" wrote:
Al,

You can use the Icon's constructor overload that accept a Type and a
resource name. The type needs to be declared in the assembly where the
resource is. The constructor uses the type for 2 pieces of information:
assembly and namespace, so the type and the resource needs to be under the
same namespace in the same assembly.

Other possiblility is to use Assembly.GetManifestResourceStream to get a
stream with the resource data and load it from there. This is BTW what
internaly the Icon constructor uses.

From experience I can tell that the tricky part is to get the resource
namespace right. VS IDE for C# puts all the resources under the default
namespace (property of the project) and then it appends the names of any
subfolder that the file might be in. VB's IDE works differently. If you have
problems loading the resource I'd suggest to use the reflector tool to check
out what is the correct namespace of the resource.
--
HTH
Stoitcho Goutsev (100)
"Al" <Al@discussions.microsoft.com> wrote in message
news:61**********************************@microsof t.com...
Hi,
I have created a solution with two projects in it - a class library and a
windows forms front end. I have added a resource file (Resources.resx) to
the
class library and filled it with icons.
Does anybody know how would I go about using an icon from this resource
file
in the windows forms project?
Thanks in advance,
Al.


May 3 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
5770
by: Gabriel Lozano-Morán | last post by:
First of all sorry for the cross-posting but I am not sure wether this belongs under internationalization or just general. Environment: Visual Studio .NET 2003 Problem: Newly added and...
1
3980
by: Namratha Shah \(Nasha\) | last post by:
Hi All, This is a resource file generation tool which converts an xml based resource formats to .net resource file i.e. (.resources) and vice-versa. Today we will see how we will generate ...
2
1673
by: Joe Thompson | last post by:
Hi, I am trying to use PlaySound in a VC++.net Windows app (VS 2003). I can use it to play a file but now I want to play it from a resource. I have two questions: How do I add a wav file to...
0
2180
by: Johann Blake | last post by:
I'm having trouble grasping how ASP.NET correctly locates resources. There is plenty of documentation on this subject but some things are not clear at all. In my ASP.NET application, I have...
3
3322
by: al | last post by:
Hi, I use a resource file (.resx) to store user's settings such as language and other strings. The problem i'm facing is that when the user changes one of the strings in the resource file, ...
11
1951
by: Alan T | last post by:
I added a resource file into my project, to store the caption of buttons and labels.. How do I make use of this resource file to dynamically assign to the buttons and labels ?
8
13650
by: CodeLeon | last post by:
Hi, All. I am creating a setup program. The way it works is that the user creates their setup info, my program generates the C# code for a setup executable, embeds the xml file containing the info...
7
2091
by: craig | last post by:
....quick question for anyone who might have some experience with .net resource files in VS 2003. I have an application that is not localized, but I would still like to be able to place all of...
13
3515
by: Bob Jones | last post by:
Here is my situation: I have an aspx file stored in a resource file. All of the C# code is written inline via <script runat="server"tags. Let's call this page B. I also have page A that contains...
12
5242
by: TS | last post by:
i have a need to possibly enable mutli language support. What benefit do i get by using a resource file instead of a custom xml solution? thanks!
0
7125
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7388
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7499
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5631
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5055
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4709
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3199
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3186
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
422
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.