Select to view content in your preferred language

Content vs Resource

932
2
07-11-2022 06:04 PM
AbelPerez
Frequent Contributor

So working on our company Addin off and on. I've added some Button and DockPane controls and have used custom images with BuildAction=Content. It all works great.

I've extended the functionality with a Pane and ProWindow control but could not get any images to display. It dawned on me that maybe I was doing something wrong. From the forum I found a post that said use BuildAction=Resource. So I did that and it worked!!!

So my question is...what is the difference? Why do we need two options? Why wouldn't the control auto detect that a BuildAction on the graphic is not compatible? What if I need the same graphic in various controls that use Content and Resource? Do I have to add it twice?

AbelPerez_0-1657587741294.png

 

 

 

 

 

Tags (3)
0 Kudos
2 Replies
CharlesMacleod
Esri Regular Contributor

There are many different build actions in Visual Studio and it can be a bit confusing on which one to use (for any given usage).

Content is a bit of an odd ball and I, personally, am not exactly sure what it is specifically intended for - I think it is more relevant for building ASP apps where "content" needs to be deployed to a website. I believe files marked as "content" get deployed with the website when it is published. The documentation (see below) also states that file content marked as "Content" will be accessible via Application.GetContentStream  but I have not had occasion to use that.

Resource is a WPF build action and this is usually what you want for images. When image content is marked as Resource it is literally compiled into the DLL and gets embedded in the assembly's manifest resources. This allows you to access said image resources with something called Pack URI 

The VS Build action reference is here if you are interested in reading further: Build actions for files 

 

0 Kudos
AbelPerez
Frequent Contributor

Interesting. Almost everything I have read up to now says to use Content.

0 Kudos