Application crashes when calling embedded resources - vb.net

I'm writing a console application in Visual Basic 2008 Express.
I added several text files to my project as resources. Specifically...
I went to my project's "Properties" page and selected the "Resources" tab.
I clicked the "Add Resource" dropdown and chose "Add New Text File".
I entered some simple text and saved the file as "Welcome.txt".
I built the entire solution.
In my code, I use console.writeline(My.Resources.Welcome) to display the text.
If I run my code through the IDE, it works fine.
If I run the EXE that's in the /bin/release folder, the app crashes.
My system logs show the error as "System.IO.FileLoadException".
I have tried setting the properties on the embedded text file to "Embedded Resource", but the result is the same.
Has anyone encountered this issue? Thank you in advance.

Copy Welcome.txt to your bin\release folder.
OR
To make Welcome.txt an embedded resource, right-click either the text file or the bitmap, and then select Properties.
In the Properties dialog box, locate the Build Action property. By default, this property is set to Content. Click the property and change the Build Action property to Embedded Resource.

Related

How append Resx into the project ressources list?

How to add my resx named "ImagesParametres.resx" into the list of "My Project*.resx" ?.
I tried many settings without success. When i open the dialog that shows resources via BackgroundImage property of my button, he never appears.
Default ressources choosen

How do I open a file with a specific application rather than its default application?

I am trying to open files using a specified executable; just like as if you were to right mouse click on a file then scroll to "Open with"
I tried what kaymaf said and reviewed the docs, but I cannot seem to get this to work.
Dim FI As New FileInfo(GetFileNameFromListViewItem(ListViewCollection.SelectedItems(0)))
Dim GetExif As Process = System.Diagnostics.Process.Start("C:\Users\*username*\Downloads\exiftool.exe", FI.FullName)
This just ends up open the executable and rather than opening the file with the executable.
You would like to open a file with your program using the Windows context menu; and do you want to get an entry in that menu? If that is not correct, the answer can be deleted.
I found this in a German forum, and they refer to this site:
This is the translated text:
One possibility would be that you register your file extension and your program in the system to open this file extension. As soon as the system knows everything, you only need to right-click on the file(s) and in the context menu, in addition to the standard entries, another menu item for opening these files is displayed. If you select this menu item, your program will start automatically if it has not yet started, and you can read out / determine the path to this file or several files in your program and process it accordingly. How it all works is described here: ookii.org/Blog/opening_files_via_idroptarget_in_net
On this page there is also a sample for download (start text files with your own program via an additional entry in the context menu / display paths to the files). It is not a VB, but it should be translatable without any problems. Corresponding information on the page and the comments should be observed.

Namespace path broken after changing Resources.resx properties

I have a runtime System.Resources.MissingManifestResourceException on my VB.Net VSTO. I read this was likely due to wrong settings in my resources file. So I went into the properties and made sure Build Action was set to Embedded Resource(and it was).
Just below, I saw Copy to Output Directorywas set to Do not copy. I thought it would not hurt if I just changed it to Copy always and gave it a try to compile.
It did not fix anything, but now Build Action has changed to Content, and I have dozens of BC30456 errors:
'Resource' is not a member of 'WordAddIn.My'
When I go to the error, I end up in a UserControl designer, and the line with an error shows: Me.Button_Foo.Image = Global.WordAddIn.My.Resources.Resources.Resource_Bar
I did set my resources file settings back to what they were (Embedded Resource, and Do not copy), but the errors remain..
Note: the namespace of Resources.Designer is My.Resources, and the Resources class and its members are Friend. However intellisense does not let me access the namespace from any of the objects where I have the build errors. I have tried changing the "Custom Tool Namespace" for other names but It does not appear from anywhere in the project. (the custom tool does update the Resources.Designer.vb file, and I would say it does it properly)
UPDATE
Resources.Designer.vb is not included in the project, but shows in the "Miscellanous Files". Same symptom as this post: Visual Studio - project shows up as "Miscellaneous Files"
I did (1) exclude the Resources.resx (cannot work on Resources.Designer.vb alone) from the project, (2) clean the solution, (3) restart Visual Studio, (4) clean the solution (zust'in'kase), (5) an then re-included it, the problem now is that Resources.Designer.vbis included in the project, but does not sit as "embeded" within the Resources.resx, so I am afraid I might have broken it?
The fix with Visual Studio 2017 was the following:
Note the Custom Tool namespace: in solution explorer, right click the Resources.resx file -> 'Properties' and memorize the value for the 'Custom Tool Namespace' field. (needed for step 6)
Remove the Resources.resx and the Resources.Designer.vb files from project: in solution explorer, for each file, right click -> "Exclude from project"
Clean / Rebuild solution
Restart Visual Studio
Re-include the Resources.resx file , but not the Resources.Designer.vb: in solution explorer, make sure you have the [Show All Files] button enabled (near [Refresh]); the resources file should appear with a greyed folder/file symbol next to it; right click -> "Include in project" (or alternatively, right click on the 'My Project' node and choose 'Add' / 'Existing item..'
In solution explorer, right click on Resources.resx -> 'Properties': make sure 'Custom Tool' value is "PublicVbMyResourcesResXFileCodeGenerator"; and that 'Custom Tool Namespace' corresponds to the value it had before you removed the file from project (see step 1.).
In solution explorer, right click on Resources.resx -> 'Run Custom Tool'
A new designer file should be generated automatically.

VB.Net 2010 Resources Not Working After Importing

When I go to set the Image on a regular Button, and get to the Select Resource dialog, I can select an imported resource, but the preview does not show up. This is true for all of the imported resource images, not just one of them. If I try to go on and hit OK, it still says "(None)" in the Image property of the Button.
I've tried deleting the resource files and re-importing, both from the Select Resource dialog, and from Project Settings -> Resources. Under Project Settings -> Resources, the images show up just fine. All of the images are PNG's and were previously working yesterday.
Any suggestions?
I was able to resolve this by doing the following:
Remove all image resources from the program.
Look through all of *.Designer.vb files of for lingering references to the any of the image resources (I found a few).
Close completely out of Visual Studio.
Re-open the project.
Add the image resources back.

VB.NET Adding an image so that it shows up under My.Resources.TheImageName

Using VS2012, I would like to add an image to the My.Resources. namespace.
I would like to draw this image to a PictureBox on the Paint event.
I did the following:
I clicked "Add existing item", then I opened up the image.
I clicked the image from the Solution Explorer and set the Build Task to "Embedded Resource".
I saved the project and re-built it.
But it still does not show up under My.Resources.
What did I do wrong, please?
Thank you for the help!
ps:
I do not want to add it directly to "Resources.resx" (for example by clicking the "BackGroundImage" property of a form).
I would prefer having the image in the solution explorer instead. I once experienced that VS2012 once damaged a file, and I had to rebuild the resource file. I would like to avoid it.
You need to add the image to the Resources tab in Project Properties, not to the project directly.