473,761 Members | 7,710 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help getting the straight on .resources/Icon(Type, string) constructor

Greetings.

While trying to get a simple app working, I've been forced to delve into
embedded and/or linked resources a bit. I read all the reference for the
System.Resource s namespace as well as all the material within the
"Resources and Localization... " tutorial. While I'm confident I now know
completely how to accomplish my original, simple task of embedding some
icons into my assembly and use of the same at runtime, I realize I've a
few unanswered questions on this topic.

Somehow, the docs for the System.Drawing. Icon class convinced me that I
should be able to very quickly extract an icon from a resource within my
assembly by merely using one of the classes overloaded constructors.
Specifically, the constructor taking two arguments: Icon(Type type,
string resource). According to the docs, this creates an instance from a
resource with the name specified by the string argument that is
contained within the assembly that contains the type specified by the
Type parameter.

After playing around a bit with how I *thought* this was supposed to
work I realize I just have no idea what I'm doing here. So, can anyone
give me some illumination or example as to how this Icon constructor is
intended to be used?

Thanks to anyone who chooses to humor me.
--
Kendall Gifford
=============== =============== ==========
WEB: http://kendall.jedis.com/
EMAIL: [REPLY TO NEWSGROUP PLEASE]
=============== =============== ==========

Nov 15 '05 #1
3 5658
Jon
When pass the Type, you are saying 'use the same assembly and namespace as this Type'.
It does not matter what kind of Type it is.

"Kendall Gifford" <re******@newsg roup.nospam> wrote in message news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
Greetings.

While trying to get a simple app working, I've been forced to delve into
embedded and/or linked resources a bit. I read all the reference for the
System.Resource s namespace as well as all the material within the
"Resources and Localization... " tutorial. While I'm confident I now know
completely how to accomplish my original, simple task of embedding some
icons into my assembly and use of the same at runtime, I realize I've a
few unanswered questions on this topic.

Somehow, the docs for the System.Drawing. Icon class convinced me that I
should be able to very quickly extract an icon from a resource within my
assembly by merely using one of the classes overloaded constructors.
Specifically, the constructor taking two arguments: Icon(Type type,
string resource). According to the docs, this creates an instance from a
resource with the name specified by the string argument that is
contained within the assembly that contains the type specified by the
Type parameter.

After playing around a bit with how I *thought* this was supposed to
work I realize I just have no idea what I'm doing here. So, can anyone
give me some illumination or example as to how this Icon constructor is
intended to be used?

Thanks to anyone who chooses to humor me.
--
Kendall Gifford
=============== =============== ==========
WEB: http://kendall.jedis.com/
EMAIL: [REPLY TO NEWSGROUP PLEASE]
=============== =============== ==========

Nov 15 '05 #2
Jon wrote:
When pass the Type, you are saying 'use the same assembly and namespace as this Type'.
It does not matter what kind of Type it is.

From the caught exceptions, I see that it is indeed looking for my
resource in the namespace as the type argument:

"Resource 'AppIcon16x16_3 2' could not be found in class
'ZMA.Base.CExit Form'."

I guess I should be specific about what I was trying so you'll know
which of my misconceptions need fixed. I have a class inheriting from
Form that contains the following in InitializeCompo nent():

public class CExitForm : Form {
...
private void InitializeCompo nent() {
...
this.Icon = new System.Drawing. Icon(
this.GetType(),
"AppIcon16x16_3 2"
);
...
}
...
}

AppIcon16x16_32 is the name I gave one of my Icons as I put into a
resource file "Images.resourc es". Finally, I build the test app using
the following on the command line:
csc.exe /target:winexe /out:ZMA.exe

/res:Images.reso urces,ZMA.Base. Images Apptest.cs
(my csc.rsp provides all the /r[eferences])

When I run it, I get the System.Argument Exception from my call to the
Icon() constructor with the message described above.
**********

So, other than this I've tried various combinations naming my resource
(/res:Images.reso urces,[various combos]), I've tried linking to the
resource file instead of embedding it (/linkres:...) though I pretty
much knew this wasn't related to the problem, and I've tried different
values for the string argument of the Icon constructor.

Either I just keep missing the correct combination, or - more likely - I
am barking up the wrong tree. Thanks again for all help rendered.

--
Kendall Gifford
=============== =============== ==========
WEB: http://kendall.jedis.com/
EMAIL: [REPLY TO NEWSGROUP PLEASE]
=============== =============== ==========

Nov 15 '05 #3
Jon wrote:
Run ILDASM.
Check to see if 'AppIcon16x16_3 2' is indeed in the 'ZMA.Base' namespace.
It isn't. AppIcon16x16_32 isn't anywhere to be seen via ILDASM. The only
thing that ever shows up is either:
csc.exe ... /linkres:Images. resources,ZMA.B ase.Images ..mresource public ZMA.Base.Images
{
.file Images.resource s at 0x00000000
}

.... OR ...
csc.exe ... /res:Images.reso urces,ZMA.Base. Images

..mresource public ZMA.Base.Images
{
}

But even when I replace 'AppIcon16x16_3 2' with various strings like
'Images' or 'ZMA.Base.Image s' or 'Images.resourc es' or even
'Images.AppIcon 16x16_32' and other combinations, it doesn't seem to
work. Does anyone have a complete working example of using this constructor?

--
Kendall Gifford
=============== =============== ==========
WEB: http://kendall.jedis.com/
EMAIL: [REPLY TO NEWSGROUP PLEASE]
=============== =============== ==========

Nov 15 '05 #4

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

Similar topics

4
1811
by: Laszlo Szijarto | last post by:
I'm iterating through various members of a struct using Reflection. While I can use fieldInfo.FieldType.BaseType to determine that a member is an array, how do I determine what that array is an array of. e,g., I want it to tell me that a UInt32 member is an Array of UInt32 (via code). Thank you, Laszlo
2
7733
by: Danny Gagne | last post by:
I'm currently working an .net application (I can use 1.1 or 2.0 if needed) that needs to read a wsdl file and generate another piece of code that can use it. I'm encountering a problem where I cannot extract all of the type information from the wsdl using any standard tools. I'm using HttpGet style webservices if that makes any difference, but I want to be able to use any type. 1. I've tried the ServiceDescription.Types and I cannot...
6
2378
by: isaac2004 | last post by:
hello i am getting a type mismatch for a page i am trying to write. any help would be great source code <%@ Language=VBScript %> <% Option Explicit %> <!--#include file="DatabaseConnect.asp"--> <!--#include virtual="06winter/levini/database/adovbs.inc"--> <html>
8
1638
by: marc | last post by:
hi there, i try to do a little generic style of programing in c#. the situation is like this: class MyObj1 { } class MyObj2 : MyClass1
6
34963
by: Rico | last post by:
Hello, I'm looking for a way to reference the string name of an enumerator. I know in VB.net you can do "MyEnum.ToString" and get the name instead of the integer value. Is there a way I can do something similar with an Enum created in Access? Alright, here is some air code to explain what I mean Public Enum MyEnum
3
2677
by: =?Utf-8?B?c3BkMzAwMQ==?= | last post by:
I have a C++/CLI app that uses a logging control in an ATL COM Server. C++ Interop seems to work just fine to pass data from the C++/CLI app to the ATL Control but I can't seem to figure out how to get a string value back from the ATL Control. When debugging the code seen below, I see that the VARIANT pointed to by 'data' is updated but the String 'str' passed from the C++/CLI app doesn't change. So the String 'str' seems to be passed by...
0
1023
by: j.lendholt | last post by:
Hey Folks, it's some years ago i wrote applications in VB respectively VB .NET 2003. We have a java-application based on java-scokets. We try to connect to the server, send up a string, let the server-app work and wait for a server-response. The VB-App connects correctly to the java-app in port 11111 on our
7
2626
by: cephal0n | last post by:
Hi there! I've been racking my brains out for 4 days and still not getting why is msaccess stubborn about string parsing, first I have a table named tblItems, this table has columns: ProductItem, ItemID. Now I want to search and count my items found and produce the result in a textbox and a label control called: txtItemResult and lblCount so I have the code Public Sub StringFinder() Dim conn1 As ADODB.Connection Dim rsShowTable As...
7
4442
vikas251074
by: vikas251074 | last post by:
I am getting error above in following code since few days giving tension day and night. How can I solve this? I am facing since Oct.25. in line no. 362 After doing a lot of homework, I am surrendered to you. <%@ Language=VBScript%> <%Option Explicit%>
0
9531
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9345
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10115
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9957
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9775
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6609
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5229
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5373
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3881
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.