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 / January 2006

Tip: Looking for answers? Try searching our database.

embedded resource

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Michael Reukauff - 20 Jan 2006 11:19 GMT
Hi

I am currently writing a wizard which runs inside VS 2005. I need to include
a bitmap and set the Build Action to embedded. How can I make this
programmatically? I know how to add the resource to the project, but not how
to set the Build Action.

Thanks a lot
Michael
Michael Reukauff - 25 Jan 2006 08:11 GMT
Nobody?

> Hi
>
[quoted text clipped - 5 lines]
> Thanks a lot
> Michael
Dustin Campbell - 25 Jan 2006 16:07 GMT
> I am currently writing a wizard which runs inside VS 2005. I need to
> include a bitmap and set the Build Action to embedded. How can I make
> this programmatically? I know how to add the resource to the project,
> but not how to set the Build Action.

You'll need to create a custom wizard that implements the IWizard interface
to manually change the build action for that file after it is added. In you
IWizard implementor's ProjectItemFinishedGenerating method, you should be
able to use Properties of the ProjectItem that is passed in to change the
build action.

See this topic in the VS 2005 documentation: Development Tools and Languages\Integrated
Development Environment for Visual Studio\Managing Solutions, Projects, and
Files\Visual Studio Templates\Customizing Templates\How to: Use Wizards with
Project Templates.

-----
Best Regards,
Dustin Campbell
Developer Express Inc
Michael Reukauff - 25 Jan 2006 18:22 GMT
Hi Dustin

Thanks for your answer.

I know this article in the VS 2005 docs. As I mentioned, I already added the
file (a bitmap) to my project, but I don't know how to set the property
"Build action". I can't find them. Maybe I am a bit too blind to find it.
Can you point me in the right direction?

Thanks
Michael

>> I am currently writing a wizard which runs inside VS 2005. I need to
>> include a bitmap and set the Build Action to embedded. How can I make
[quoted text clipped - 16 lines]
> Dustin Campbell
> Developer Express Inc
Dustin Campbell - 25 Jan 2006 18:48 GMT
> I know this article in the VS 2005 docs. As I mentioned, I already
> added the file (a bitmap) to my project, but I don't know how to set
> the property "Build action". I can't find them. Maybe I am a bit too
> blind to find it. Can you point me in the right direction?

You'll have to figure out the name of the build action property. To find
this you will need a bit of probing code in your IWizard.ProjectItemFinishedGenerating
method first. Something like this:

private void ListProperties(ProjectItem projectItem)
{
 foreach (Property property in projectItem.Properties)
 {
   System.Diagnostics.Debug.WriteLine("Property name: " + property.Name);
   if (property.Value == null)
     System.Diagnostics.Debug.WriteLine("Property value: NULL");
   else
     System.Diagnostics.Debug.WriteLine(String.Format("Property value: {0}
({1})", property.Value, property.Value.GetType().FullName));
 }
}

That should get you a list of properties for a ProjectItem and their values
along with the type of value that each property expects. Armed with this
information, you should be able to set the property with something like this:

projectItem.Properties.Item("build_action_name_goes_here").Value = build_action_value_goes_here;

-----
Best Regards,
Dustin Campbell
Developer Express In
Michael Reukauff - 26 Jan 2006 08:11 GMT
Hi Dustin

Yes, this is a very good idea. I will try it at the weekend and hope I find
this property.

Thanks again for your help
Michael

>> I know this article in the VS 2005 docs. As I mentioned, I already
>> added the file (a bitmap) to my project, but I don't know how to set
[quoted text clipped - 30 lines]
> Dustin Campbell
> Developer Express Inc
Michael Reukauff - 26 Jan 2006 12:07 GMT
So, I can't wait and I found it.

To set a resource as embedded resource inside a project, you must set the
following properties:
"BuildAction" must be set to 3
"ItemType" must be set to "EmbeddedResource".

Thanks again to all
Michael

> Hi Dustin
>
[quoted text clipped - 38 lines]
>> Dustin Campbell
>> Developer Express Inc
Dustin Campbell - 26 Jan 2006 16:00 GMT
> So, I can't wait and I found it.
>
[quoted text clipped - 3 lines]
> "BuildAction" must be set to 3
> "ItemType" must be set to "EmbeddedResource".

Thanks for the info. Thus far, I have not been able to find a list of all
known properties and their accepted values. Probing code has always been
necessary. Does anyone know of such a list? Carlos? :-)

-----
Best Regards,
Dustin Campbell
Developer Express Inc
Michael Reukauff - 27 Jan 2006 08:19 GMT
Hi Dustin

Did not find one.

I wrote a small addin to show me the properties of that opened solution.
There are a lot of properties for each item in the solution and the names of
the properties differs and depends on the file type. for example the .ico
has 23 properties.

Michael

>> So, I can't wait and I found it.
>>
[quoted text clipped - 12 lines]
> Dustin Campbell
> Developer Express Inc
Carlos J. Quintero [VB MVP] - 27 Jan 2006 09:27 GMT
> Thanks for the info. Thus far, I have not been able to find a list of all
> known properties and their accepted values. Probing code has always been
> necessary. Does anyone know of such a list? Carlos? :-)

Hi Dustin,

No, I do not have such a list, and it seems to me that it is "subject to
change" with each new version. But I noticed that the new VSLangProj80
assembly contains quite a few property lists, so maybe there is some
standarization there...

Signature

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio
You can code, design and document much faster:
http://www.mztools.com

Dustin Campbell - 27 Jan 2006 17:32 GMT
> But I noticed that the new VSLangProj80 assembly contains quite a few
> property lists, so maybe there is some standarization there...

Let's hope so. :-)

-----
Best Regards,
Dustin Campbell
Developer Express In

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.