getting Error while executing a simple form - c#

I am a beginner to C#. I just created a simple form for my project using Visual Studio 2010, by importing some pictures into it. After deleting some unwanted images from Resources file it is giving the error:
"Error 7 Invalid Resx file. Could not find file
'C:\Users\HP1\Documents\Visual Studio
2010\Projects\test\test\Resources\331295-krishna-playing-flute.jpg'.
After that I can't able make any changes in my form. Even after If I am making any changes it is not reflecting while executing the program.

in your project open your resx file in visual studio.it is xml file and easily readable. you need to remove those line which are causing this error (If these images are of no use) or place the given jpg file at the required location

I can't look at your file, but maybe error is that file contains source on files that do not exist. Remove those sources.

Related

My main .cs file is now blank after crash

I've just had a visual studio crash (2012 - Using Monogame) and now my main.cs file in my project shows up as a blank text file when opened in Visual studio.
The file itself still shows as 134kb so it isn't blank? No matter what I do the project cannot find the file .. every other .cs file is fine.
There is no backup that I can find .. I'm hoping there is some way of reading the file and recovering the code.
Monogame does not have a main.cs file.
I will assume is is user created. The Main() function is in Program.cs.
I would suggest moving to VS 2022 Community Edition, it is free, and Monogame 3.8.1.
Create a new project and copy all of your class files into it, modifying the namespace of each to match the new name.
Copy your content sources and add them with the mgcb-editor.

I get an error when compiling with an imported image resource

This is turning into a nightmare!
I have a C# DLL project and it has the regular About Form. I go to add my own image:
I can see it listed and I accept:
It looks fine:
The moment I compile I get this error:
I have googled the error:
The argument docData must implement the interface IVsTextStream
And it suggests deleting the RES file.
I am confused. I thought this would be a simple exercise and despite several attempts and can't use my own image.
Well, I do not know why the problem was happening. But here is my workaround:
I created a new C# DLL project.
I added the About Form.
I opened the form RESX file in the IDE.
I added the new image.
I set the image as embedded.
I deleted the existing image.
I renamed the new image the same as the old.
I restarted the project and the image showed fine.
I opened the RESX file with NotePad++ and copied the image bit over to my actual project about window RESX file.
It displays and compiles.

Unable to load resource (.resx) file because it is not trusted

I am facing an issue while building windows source in Visual studio 2017. Showing the error message mentioned in the title.
Anyone have any idea about this error message?
Finally I could have resolved the issue as below:
Open the file explorer. Navigate to project/solution directory
Search for *.resx. --> You will get list of resx files
Right click the resx file, open the properties and check the option 'Unblock'
Repeat #3 for each resx file.
Reload the project.

Can't access an imported library c#.net Visual studio

Basically I've created a project from 0 using Visual Studio 2010, a simple aspx (with his aspx.cs and .designer behind) which needs to call a library located in the same project folder /bin/libraryName.dll.
I right-clicked on my project and added the reference.
I even added the following lines to make sure my project could see the .dll file:
if (File.Exists("B:\\mk2015\\web\\Simposium2015\\bin\\DecoderEndeavour.dll"))
{
Response.Redirect("Found.html");
}
Inside the /bin/LibraryName.dll path on my Project Explorer I could see now a LibraryName.dll.refresh file was created, that simply has in him the path pointing to where the .dll is located.
I tried to execute the code:
LibraryName.Class1 Decoder = new LibraryName.Class1();
And I got the following error:
The system cannot find the file specified. (Exception from HRESULT: 0x80070002). From the FileNotFoundException.
I'm completely lost, in some way my code is able to verify a file is there, he can see it, but somehow it's not correctly linked to some part of the project as then it doesn't find it when trying to create a class declared inside the library.
Can anyone help?
Thanks!

Use external existing file as resource file in .NET

I'm writing some integration tests for some SQL scripts that live in a folder separate from the project. Since the setup of the machine I'm writing on the tests on differs from the machine they will be run on, I would like to include them as resource files rather than hard coding any paths. However the default behavior for adding an existing file as a resource file simply copies the file, which is not what I want in case any of the SQL scripts get updated.
Does anyone know the best way to get the resource file to actually reference the SQL scripts that are in a folder separate from the project, or to somehow copy them into the assembly at compile time so I don't have to load them via absolute/relative paths?
Edit: For clarity, I'm trying to get the resource file to act as a symlink to the original file at compile time. Adding an existing file to a resource in file in Visual Studio simply makes a copy of the file, which means any changes to the original are not propagated to the resource file.
After asking on IRC, someone guided me to what I was looking for. You are able to add an existing file to a project as a link (there is an arrow on the Add box when in the file dialog), and set it's Build Action property to Embedded Resource
https://support.microsoft.com/en-us/kb/306234
Daniel posted a link on how to actually read an embedded resource:
How to read embedded resource text file

Categories

Resources