473,675 Members | 3,629 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

What to do when numeric resource ID is required in .NET?

Several attributes and interface methods I'm using refer to resources (such
as strings or icons) by a numeric ID. This was the only way to refer to
resources in unmanaged code (C++, for example), but I'm writing in C# now,
and it seems that resources are named with string identifiers.

Visual Studio doesn't seem to like resource names such as "100", so I'm
wondering how this could work. Is it absolutely necessary for me to have a
satellite DLL project which uses the old .res (unmanaged) resource format?

Confused...

-Scott
Oct 3 '05 #1
1 4148
"Scott Smith" <paul@nospam_co lton.net> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
Several attributes and interface methods I'm using refer to resources
(such as strings or icons) by a numeric ID. This was the only way to
refer to resources in unmanaged code (C++, for example), but I'm writing
in C# now, and it seems that resources are named with string identifiers.

Visual Studio doesn't seem to like resource names such as "100", so I'm
wondering how this could work. Is it absolutely necessary for me to have
a satellite DLL project which uses the old .res (unmanaged) resource
format?

(snip)

OK, I think I've resolved this. For those who are curious, here's a
clarification of the problem, followed by the resolution...

There is an attribute that you can apply to your
Microsoft.Visua lStudio.Shell.P ackage derived class:

[Microsoft.Visua lStudio.Shell.P ackageRegistrat ionAttribute(Us eManagedResourc esOnly
= true)]

This says that you're not going to be referring to resources such as strings
in an unmanaged satellite DLL. Instead, strings, icons, bitmaps, what have
you, are going to be in your assembly as managed resources.

So then, when you implement the IVsInstalledPro duct interface in your
Package-derived class, you're faced with implementing methods such as the
following:

public int IdIcoLogoForAbo utbox(out uint pIdIco)

....but managed resources are identified by strings. Perhaps the caller of
this method (or the resource loader that it's using) will convert this
integer into a string (e.g loading a resource named "101").

This seemed reasonable, and the "...\Visual Studio 2005
SDK\2005-09\VisualStudio Integration\Sam ples\IDE\CSharp \Reference.Pack age"
sample does exactly this. It has several string resources, a bitmap and an
icon, all named using a number like "101".

Whenever I tried to name a resource with an identifier like "101" in my
solution, it generated an error saying something like "the identifier must
start with an alpha character, or underline". I even tried copying the XML
contents of the .resx file from the sample project into my Project's .resx
file. I still got the errors.

I was convinced at that point that there must be some kind of flag or
setting in one project that wasn't present in the other. After a
side-by-side comparison, looking at the properties for my .resx file, I
found it in the "Custom Tool" property:

Custom Tool ResXFileCodeGen erator

Not sure whether this is something new to VS 2005, but this creates a new
class ("{your-resx-filename}.Desig ner.cs") with type-safe properties to
retrieve every resource in your .resx file, e.g.:

internal static string _101 {
get {
return ResourceManager .GetString("101 ", resourceCulture );
}
}

....the property name ("_101") is based on the resource name, and as you can
see, if your resource name is numeric, the result is an invalid C# property
name. If you set the "Custom Tool" property to empty, the generated
....Designer.cs file goes away, and Dev Studio doesn't complain about the
resource names any more.

-Scott Smith
Oct 4 '05 #2

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

Similar topics

2
2390
by: entoone | last post by:
I have a field called pword, whenever someone enters anything but numeric, i.e. mixed alpha with numeric, or even just alpha.. the following error appears. Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource What do I need to change the field to, to be able to have whatever password configuration the user wants to enter?
5
3046
by: lkrubner | last post by:
I have a webserver through Rackspace. I create a domain. I create an FTP user. I upload some files. I create a database called testOfSetupScript and then I create a database user named setup. I write some PHP code which should, I think, be able to to auto create the tables. The SQL looks like this:
226
12556
by: Stephen C. Waterbury | last post by:
This seems like it ought to work, according to the description of reduce(), but it doesn't. Is this a bug, or am I missing something? Python 2.3.2 (#1, Oct 20 2003, 01:04:35) on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> d1 = {'a':1} >>> d2 = {'b':2} >>> d3 = {'c':3}
39
2897
by: Holly | last post by:
I'm trying to validate my code and I can't figure out what kind of doctype I have. The validator can't tell me anything because it can't move beyond the doctype declaration. http://www.wavian.com/clients/pugwash/ Is there anyway to tell what kind of doctype this is? I tried inserting a few different types (please excuse me if this is the stupid way to do it, I am learning...) but am unsuccessful.
7
3934
by: BBFrost | last post by:
I'm receiving decimal values from database queries and placing them on a report page. The users want to see the following .... Db Value Display Value 123.3400 123.34 123.0000 123 i.e. I want to trim trailing zeros and (decimal point if no decimal values
3
1728
by: Saradhi | last post by:
How to get the names of all the Resources embedded in a Resource File? -SARADHI
7
5414
by: Wysiwyg | last post by:
Is there any way to add an embedded resource to a project without copying it to the project's directory? I have shared resources and don't want each project using the images, xml files, etc. to need to be updated with the current copy before being built. I also don't want projects being built with the old copy. Thanks! Bill
1
309
by: Scott Smith | last post by:
Several attributes and interface methods I'm using refer to resources (such as strings or icons) by a numeric ID. This was the only way to refer to resources in unmanaged code (C++, for example), but I'm writing in C# now, and it seems that resources are named with string identifiers. Visual Studio doesn't seem to like resource names such as "100", so I'm wondering how this could work. Is it absolutely necessary for me to have a...
6
1953
by: CSharper | last post by:
I have following code, if you cut and paste it in VS and compile it you see only an answer of 0. I was expecting values from o through 2999 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Resources; using System.IO;
0
8515
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
8446
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
8966
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
8863
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...
1
8675
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6275
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5754
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
4259
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...
3
1863
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.