I'm trying to add/change images in my project, using Microsoft Visual Studio 2008 C#. Along with it, Devexpress components are also included.
What I did, I copied an image (.png file) and paste it it in my "PrintRibbonControllerResources.resx" and then after that I have to open again the MainForm.cs right click on the form and click on the Run Designer. It will open the Ribbon Control Designer. From there, I can add the image.
Do you think its ok? It's my first time to do this, and I don't have any experience & I'm learning it by doing.
Thanks
===
it seems I don't see the add function under resource tab
I generally add an image to the project itself. (Add/Existing item) I do this so I can use SourceControl to check in/out the image file. The resx then links to these files.
Basically, my philosophy is: if it works, don't fix it.
If this solution works for you, it's fine. At least, until you discover a situation where it fails.
If you go in the properties of your project, and select the resources tab, you can add it directly from there and it will be accessible in the default resource file of your project, which might be more convenient.
I like to add it to a solution folder (or folder in the project) and like that to the resx via "Add Exising File".
I get all of the advantages of having the resource file, but also the advantages of having a physical file (editing, quick view, etc.)
Related
I get this error message when I try to apply the Move to Reource refactoring to a string in a razor file:
"This project does not contain an available resource file"
I have tried added ressource files by adding new item, and also by adding in the project settings dialog. and building etc. All to no help. What is the problem?
I am using JetBrains ReSharper Ultimate 2015.1.1 Build 102.0.20150521.123255
ReSharper 9.1.20150521.134223
in Visual Studio 2015 rc in an ASp.NET MVC 5 project.
Any suggestions how to make this refactoring to work?
Open the .resx file with your "Managed Resource Editor" (the default), look at the top of the screen. There's a dropdown called "Access Modifier". Set it to public. Done.
Bart Van Meerbeeck's answer didn't work for me for the identical issue, though it definitely is the best answer. In MY case, however, the problem was me.
I was working in a large solution, and the file, in which I was attempting to do this refactoring, was located within a completely different project than where my Solution Explorer was scrolled to at the time. Upon realizing this, I created the resources file in the respective project, and all was well.
So, to others who may run into this, simply click your "Sync with Active Document" button in Solution Explorer, to jump to the project for which file you're editing, and you won't feel dumb like I do. :)
Or maybe access it's data via reflection somehow ?
Thanks
EDIT: I'd like to know if there's a way to do it without reading it as an XML.
Like a ms library that supports it, so it'll work for any kind of project and any kind of vs version (2005, 2008, 2010 ... ).
The *.csproj file is really just an XML file. You can open it just like any other XML file and treat it as such as well. Realize that any changes made to it, though, will require reloading the project.
Also, remember, there is no *.csproj file once the application is compiled/deployed.
Yes, you can open it in a text editor, or from Visual Studio
Right click on a project
Unload Project
Right click on the unloaded project
Edit project
Right clicking the project and selecting the properties option gives you a GUI to change some of the settings in the project file. Also, when you right click a file and change it's properties it causes a change in the project file. If you want to do anything very serious, like add custom build steps, you have to do it by hand in a text editor like notepad++. It's just an XML file. If you're familiar with MSBuild the proj file has many similarities to a build script for MSBuild.
I got here by clicking on a Button on my Form in the designer, going to the Properties window, finding the Image property, and hitting the ... button that appears to the right of the textbox.
If I open up the Properties\Resources.resx file in the designer, I see all the images in my project, yet I cannot view them in this list. I suppose I could import the images I want from a directory, but then I would have duplicates.
How can I select from images in the resource file from this dialog? How can I get them to appear? Thanks.
You should probably click the Import button first, and than add the images. This will add them to the resource folder. You should do this from visual studio, not via the explorer
I had the same problem but it was a simple answer. I have multiple projects in my solution, and consolidate my common resources in a separate assembly. The resources must be in the same project (assembly) in order to be accessed by the designer of whatever control you're using that wants to use the image. Otherwise you have to get the images at runtime.
I added several files (HTML, CSS, etc.) as resources to my Visual Studio project. According to MSDN, I should be able to access these resources via
MyProjectName.Properties.Resources.Filename
Unfortunately, IntelliSense doesn't even know the Properties property behind MyProjectName. If I type "MyProjectName.", IntelliSense offers me several things but no properties. I already built the project, but nothing changed.
If this is important: that project is not the main/startup project of my Visual Studio solution.
You need to add them here:
Project menu
MyProjectName Properties
Resources tab
"Click here to create resources" (if necessary)
Select Files menu
Add Resource
Now you can access them using MyProjectName.Properties.Resources.Filename
Make the file as a resource from its properties as:
BuildAction=Compile
Take a look at this MSDN Forum link. What I take from it is make sure your resources are added as resources and that the namespace's match.
Are you sure they're marked as resources? Right click and check their properties.
It is a little confusing that there is a folder in Visual Studio called Propertieson the same level as Resourcesbut which is bypassed altogether.
So while the path in your code may go via Solution_name.Properties.Resources.yourFile.png this does not reflect in the folders used in Solution Explorer of Visual Studio, as there you find the image then directly under Solution_name\Resources\yourFile.png.
And just adding a file and moving the resource with the mouse won't make Visual Studio find this file as Resource in your code. So you must go through menu Project, Properties (lowest entry) ? or click Alt + F7, Highlight Resources.
Now click on the Drill-down-Arrow of Add Resource rather than just on the main area of the button. Doing that would open the dialog window for Add New Resource, but actually you want to click Add Existing File. That's it.
I know this is contrary what answer said but on VS2013, I had to set BuildAction=Resource
For anyone else perhaps check the Resources.Designer file?
I found a discrepancy on this line
System.Resources.ResourceManager("DemoApp.Properties.Resources", ...
I had changed the project name to Demo.
I am not sure will it help or not but all I had to do is creating a new form and adding an icon to picturebox. Somehow that solved the problem.
I'm upgrading a project from Visual Studio 2003 to 2008 and wish to automatically generate XXX.Designer.cs files and update the corresponding XXX.cs original one.
Any automatic way to do it?
UPDATE: I'm referring to WinForms. Of course, I know the old style works but i'm looking for a way to go to the new style without doing it by hand.
There is a macro out there floating that does this. I have used it and it works great. Start by looking at Nathan Jones Blog. If you dont have much luck then download a zip of the macro source (I posted) from VSCONVERT - PasteBin
The original classes will continue to work - even with the Visual Studio designer. The code the VS puts in the Designer classes is simply meant to remove the designer "noise" into a separate file so you can focus on the non-visual code in your class.
Once you migrate the project to VS2008 using the wizard, you can open up your forms in VS and continue to edit them just like you did before. Any new forms that you create will get Designer backer files.
We had this problem.
Basically the designer file should contain nothing but a set of object declarations (i.e. the objects on the form) and the InitializeComponent() call. If you've done any fancy work on your constructor that might be there too.
Simply create a file called MyForm.Designer.cs and add it to the project. VS2008 will automatically place it underneath MyForm.cs. From there, if you create the partial class heading and the namespace, then copy across all the declarations and Initializecomponent call into the designer file, then it will work.
But because if you had to, people would edit initializecomponent and also edit the default constructor, VS2005 and 2008 couldn't automatically upgrade these files as all sorts of strange things might occur. I guess from a project point of view, what benefit do you think your working code will derive from the separation?
I'm not sure I understand, but I'll make a guess.
Was this an ASP.NET project in VS2003? Did it have .Designer.cs files in it? Is it the case that you've done an upgrade but you find that you have no .Designer.cs files now?
If so - you may have inadvertently changed your Web Application Project into a Web Site "project". This sort of "project" was introduced in VS2005, so you would not have seen it yet. These aren't real projects (no .csproj file), and they have many other differences.
Otherwise, if your project didn't used to have .Designer.cs files, then why do you want them now?
In general, the way to create designer files is to open the file in a designer, wait a few moments for the designer to finish what it's doing (updating the screen, etc); and then saving the file. You might possibly have to "touch" the original in order to get the designer to reevaluate things.