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 / Visual Studio.NET / Extensibility / December 2004

Tip: Looking for answers? Try searching our database.

Generating resources.cs file

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Notre Poubelle - 19 Nov 2004 19:35 GMT
In the 'MyProject' managed package framework sample in VSIP SDK 2005 Beta 1,
there is a file named resources.cs that according to the comment at the top
of the file was generated from Resources.txt using ResXFromTextFileGenerator.


I don't see a Resources.txt file (maybe this was really generated from
Resources.resx?) and I don't see any documentation on
ResXFromTextFileGenerator. I can see the function of the resources.cs file -
to wrap resources - but I'd like to get instructions on how to create such a
file myself.
Gary Chang[MSFT] - 20 Nov 2004 08:14 GMT
Hi Notre,

Currently I am looking for somebody who could help you on it. We will reply
here with more information as soon as possible.
If you have any more concerns on it, please feel free to post here.

Have a nice weekend!

Best regards,

Gary Chang
Microsoft Online Partner Support

Signature

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

--------------------
Gary Chang[MSFT] - 23 Nov 2004 09:33 GMT
Hi Notre,

I consulted one of the product dev team members, his opinion is:

The text in that sample project is probably out of date, and that it should
probably be similar to what you will see in newly created projects like the
one listed below:
The comment on a newly created C# windows app project with Beta1 includes
the following comment in the resources.cs file:

//--------------------------------------------------------------------------
----
// <autogenerated>
// This code was generated by a tool.
// Runtime Version:2.0.40607.16
//
// Changes to this file may cause incorrect behavior and will be lost if //
the code is regenerated.
// </autogenerated>
//--------------------------------------------------------------------------
----

    /// <summary>
    ///    A strongly-typed resource class, for looking up localized strings,
etc.
    /// </summary>
    // This class was auto-generated by the Strongly Typed Resource Builder
    // class via a tool like ResGen or Visual Studio.NET.
    // To add or remove a member, edit your .ResX file then rerun ResGen
    // with the /str option, or rebuild your VS project.
    class Resources
    {
        .......
    }

Note the "Custom Tool" property for Resources.resx. It contains a setting
of "ResXFileCodeGenerator", and this is probably what the comment in that
sample was refering to.

Looking through the sources, it appears this is an internal component of
the forms designer package. It's marked as an internal class, so it
probably would not be exposed via VSIP or automation. However, a quick test
shows that you can delete this resources.cs, and regenerate it again by
selecting "Run Custom Tool" from the context menu. So it seems you can
probably generate a resources.cs from a .resx that is a member of a
project.  

Thanks!

Best regards,

Gary Chang
Microsoft Online Partner Support

Signature

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

--------------------
Notre Poubelle - 23 Nov 2004 18:05 GMT
Hi Gary,

Thanks for looking into this for me.

I understand what you're saying about the Resources.cs file that's generated
from the Resources.resx file in a basic Windows Application.  In fact, that's
also what I thought was happening -- that the Resources.cs file in the
MyProject sample was outdated and it was really meant to be generated with
the ResXFileCodeGenerator custom tool.

However, if you look at the PropertyPages.cs file in the MyProject project,
you'll see that some of the attributes to the methods reference constants
that are defined in the Resources.cs file.  For example, look at this snippet
of code from PropertyPages.cs file:

       [SRCategoryAttribute(SR.Application)]
       [LocDisplayName(SR.AssemblyName)]
       [SRDescriptionAttribute(SR.AssemblyNameDescription)]
       public string AssemblyName
       {
           get { return this.assemblyName; }
           set { this.assemblyName = value; this.IsDirty = true; }
       }

The SR class is defined in Resources.cs.  It contains a constant named
Application that resolves to the string "Application".  This is a resource
name in the Resources.resources file.  

In order to decordate the method with attributes like in the above, the
constants need to be defined.  These constants are not defined when you look
at the Resources.cs that's generated from Resources.resx using the
ResXFileCodeGenerator custom tool.  There must be a way to generate the
Resources.cs that we see in the MyProject sample VSIP project.

Thanks
Ed Dore [MSFT] - 24 Nov 2004 06:39 GMT
Hi Notre,

From past experience, I've found a number of samples included with beta
drops, that aren't quite be up to date. I suspect that was probably the case
with this sample. I haven't had a chance to look at the sample though, as
I'm remote until Monday. Gary may be able to investigate this a bit more
though. As an experiment (I don't have the beta installed at home), you
might want to try deleting the resources.cs, and try regenerating it again.
I'm pretty certain that this "RexXFileCodeGenerator" tool probably was
originally this RexXFromTextFileGenerator referenced in the comments. A
quick search of the latest Whidbey sources yesterday showed no hits on that
string. Which pretty much indicates the sample was probably generated from a
pre-beta drop of VS 2005.

Sincerely,
Ed Dore [MSFT]

This post is 'AS IS' with no warranties, and confers no rights.
Notre Poubelle - 24 Nov 2004 21:49 GMT
Hi Ed,

Thank you for looking into this.  

I would like to try recreating the resources.cs file. That's actually the
goal of this line of questioning.  I just can't figure out how to do it.  I
tried recreating it using the str option on the resgen command, i.e.

resgen resources.resx /str:c#

This creates a Resources.resources file and a Resources.cs file.  The format
of the Resources.cs file is completely diffrent from what I see in the
MyProject sample.  There is no SR nor SRCategoryAttribute class nor internal
constant stirngs that map up to resource names in the source resources.resx
file.

Using the ResXFileCodeGenerator custom tool does the same thing as
resgen.exe with the 'str' option.

I look forward to anything you can find out on Monday or whatever else Gary
can come up with.

Thank you
"Ed Dore [MSFT]" - 29 Nov 2004 19:22 GMT
Hi Notre,

The ResXFileCodeGenerator is a custom tool, so you can invoke it via the
VsProjectItem.RunCustomTool automation method. You'll need to retrieve the
desired ProjectItem, and then cast it's Object property to a VSProjectItem,
and then you should be able to call RunCustomTool. This will invoke the
ResXFileCodeGenerator (or whatever tool is listed in the Custom Tool
properly for that item, via a call to the appropriate
IVsSingleFileGenerator.Generate method.

I'm not certain if this is reusable outside of the project environment, but
it's implemented using the standard IVsSingleFileGenerator, so you may be
able to use it outside of a project system to produce a .cs file. I haven't
tried it though :-)  Hint, the CLSID for the ResXFileCodeGenerator should
be listed under the HKLM\Software\Microsoft\VisualStudio\8.0\Generators
hive.

Sincerely,
Ed Dore [MSFT]

This post is 'AS IS' with no warranties, and confers no rights.
Notre Poubelle - 30 Nov 2004 17:53 GMT
Hi Ed,

I'm not having any difficulty running the ResXFileCodeGenerator as a custom
tool.  I believe it is operating as designed and it is generating a
resources.cs file for me when I associate the custom tool with the
Resources.resx file.  It's just that the Resources.cs file that
ResXFileCodeGenerator generates is completely different from the one in the
'MyProject' managed package framework sample in VSIP SDK 2005 Beta 1.  I want
to know how to generate a resources.cs that is like in the one in the sample
project.
Gary Chang[MSFT] - 04 Dec 2004 03:47 GMT
Hi Notre,

> It's just that the Resources.cs file that ResXFileCodeGenerator
>  generates is completely different from the one in the 'MyProject'
> managed package framework sample in VSIP SDK 2005 Beta 1.
>  I want to know how to generate a resources.cs that is like in the
> one in the sample project.

We do understand what you want in this issue, however just as Ed figured
before, the sample you concerned is out of date, and the tool used to
generate that sample is gone. We could not to go back and undo the changes
to the ResXFileCodeGenerator, or provide you the one that we used to build
the sample at this time.

So in such scenario, we suggest you could wait for the release version of
Whidbey and use the tools we plan to ship in the box, then the generated
code will be consistent with the code our wizards will produce.

Thanks for your understanding!

Best regards,

Gary Chang
Microsoft Online Partner 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.