Thursday, February 09, 2006

Please Note: If you're using VS 2008, you don't need this tool anymore. 2008 has this functionality built-in, look for the dropdown on top of the resource editor.

Introduction

In Visual Studio 2005, strongly-typed code for resource files (.resx files) are automatically generated when you save them. The generated class, however, cannot be accessed externally since the class is marked as internal.

This little add-in just instructs the generation process to build a Public class. To use it, just change the Custom Tool property of any resource file from ResXFileCodeGenerator to ResXFilePublicCodeGenerator.

After you make any changes and save the file, IDE will auto-generate a Public strongly-typed class for your resource.

Licence

The component and source is provided "as is" and there are neither warranties to the quality of the work nor any expressed or implied agreements that the programmer will release any updates. The programmer will release updates and provide any support at his own discretion.

External code mentioned in credits may subject to their own licence terms.

1.0.0.1 Update:
Fixed the issue with VB.Net root namespaces. This is, in fact, reported months ago but I totally forgot to fix it. I apoligize from all VB.Net users for the trouble.

Download

v1.0.0.1

Credits

Includes some code from Daniel Cazzulino’s XSD -> Classes Generator Custom Tool article.

VS Integration classes from http://www.gotdotnet.com/Community/UserSamples/Details.aspx?SampleGuid=4AA14341-24D5-45AB-AB18-B72351D0371C

10/11/2006 3:47:55 PM UTC
This is a nice tool! Just what I was looking for. Thank you for making it available publicly.
Speedbird186
10/11/2006 5:31:15 PM UTC
Thanks. That internal thing is really a pain. Have fun.
Gokhan
10/31/2006 5:40:41 PM UTC
Hi, great initiative and thanks for making this publicly available! There is a problem when working in VB.NET which has root namespaces. Compare

Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("ResourceNamespace", GetType(OurProduct).Assembly)

with what gets generated by the ResxFileCodeGenerator:

Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("Namespace1.Namespace2.ResourceNamespace", GetType(OurProduct).Assembly)

if our root namespace is Namespace1.Namespace2. Is this something you are aware of and is planning a fix for? If you are, we would be eternally grateful :-)

Many thanks,
Manso
manso
11/23/2006 10:43:20 PM UTC
Manso,

Fixed (I believe). Blog comments sometimes slip into spam folder so I didn't see your message on time. This issue has been reported months ago, I didn't make a note of it and it got totally forgotten in time :(

Please let me know if it's still broken.
Gokhan
12/1/2006 5:35:11 PM UTC
Gokhan, thank you so much for publishing this. I was feeling icky about using the InternalsVisibleTo attribute. It works great!
12/12/2006 11:36:54 AM UTC
Mike,

The worldwide developer community is supporting me for years and I'm just trying to give my best back to community.

Thanks for your nice comments.
Gokhan
10/30/2007 4:14:16 PM UTC
great little utility!
Nick L
10/30/2007 7:49:43 PM UTC
Nick,

Thanks.
Gokhan
11/5/2007 12:57:44 PM UTC
Thanks for your solution, but I think there will be 1 issue using this - my build server will not be able to compile. Any thoughts on that?
I had seen a implementation where someone had removed the customtool property and added a target in csproj to compile the resources as public.
Nitin
11/5/2007 1:13:44 PM UTC
Found the article : How to make generated resource class public using resgen in csproj
http://blogs.msdn.com/lifenglu/archive/2006/03/16/553348.aspx
Nitin
4/4/2008 4:51:33 PM UTC
It's an old tool but useful and now I've changed IDE to VS 2008 and got some trouble.

I have a problem with this tool when compiling and installing it on Visual Studio 2008 on Windows Vista...
The new Visual Studio seems unable to use your DLL
I've tried downloading the source code and recompiling it but maybe something on the installation place or registry keys have changed.

I don't know if the malfunctioning is due to Visual Studio or due to Vista.

If you have a hint telling where to look at in your code, maybe we can fix it and made it work also on 2008, Elsewhere I have to manage my public resource file by hand and it is not so nice...

Thank you in advance for any help
4/4/2008 6:45:52 PM UTC
@Sabrina,

You don't need it to generate public resources in 2008, it has the functionality built-in. On the resx editor, there's a dropdown on top to select target accessibility. Internal / public / don't generate or something like that.
Gokhan
6/26/2008 1:37:45 PM UTC
I still using this excelent tool with VS 2008 because I modified it to generate an enumeration with the resources.

I just made one change to use with VS 2008. The private variable _key declared into ResXFilePublicCodeGenerator.cs points to VisualStudio\8.0 folder. This works to VS 2005. To use with VS 2008, just change 8.0 to 9.0, rebuild and install! ;)

Bye.
Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):