Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I am getting the following error on a project of mine when I try to build... Error CS2001: Source file '.cs' could not be found. I took the two files that are causing this error out on purpose because they conflict with other files and cannot be in there. How can I resolve this error without putting the 2 files back in the solution?
They are likely still referenced by the project file. Make sure they are deleted using the Solution Explorer in Visual Studio - it should show them as being missing (with an exclamation mark).
I open the project,.csproj, using a notepad and delete that missing file reference.
I had this problem, too.
Possible causes in my case: I had deleted a duplicated view twice and a view model.
I reverted one of the deletes and then the InitializeComponent error appeared.
I took these steps.
I checked all of the solutions mentioned on this question. The class
name and build action were correct.
I Cleaned my Solution and rebuilt. Another error appeared. "Error CS2001: Source file '.cs' could not be found"
I found this answer and followed the steps.
I reloaded the project and cleaned/rebuilt again.
My solution builds without errors and my application works now.
In my case, I add file as Link from another project and then rename file in source project that cause problem in destination project. I delete linked file in destination and add again with new name.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have a question.
I want my program to create a new cs. File (console application), and than to make it an exe file.
Does it possible? How?
Thanks,
Tom
Edit:
sorry for not being clear. I mean not to rename the file's ending. what i mean is how to make a program that will make an Execution file from a code file (such as cs. files)
.cs file is nothing but a plain text file, written in C# language.
You can use this MSDN reference to make a plain text file:
https://msdn.microsoft.com/en-us/library/8bh11f1k.aspx
As for compiling, it can be done by running csc.exe using proper parameter. MSDN reference here: https://msdn.microsoft.com/en-us/library/78f4aasd.aspx
Your question is not quite clear nor specific but I´ll try to give you some basic information about compiling a C# class.
If you are using a text file you can either use Java-compiler like java from Sun or C# compiler like csc from Microsoft. Although the ending .cs is used frequently it is not necessary in order to compile. Just make sure to have a Main() if you want to make your file executable.
csc myClass.cs
Should do the job in your cmd with the csc compiler. You can execute myClass.exe with:
myClass
You can add /out as an option to change the name of the output file.
However, if you want to compile your class to be used by another class you have to compile it as a module:
csc /t:module myClass.cs
It will be saved as myClass.netmodule.
This question already has an answer here:
Symbol status showing "Skipped Loading" for dll in modules window?
(1 answer)
Closed 6 years ago.
I already had a look at solutions on the internet for this problem but no one really worked.
What I already tried:
Cleaning the solution and rebuilding everything
Deleteing the bin + obj directory
Restarting visual studio
Restarting the pc
Loading the module manually (but it will not be loaded when starting debugging again so this is a really annoying solution)
I have two startup projects, one is loaded normally but the other one is not.
Thanks for your help!
I fixed this by deactivating the option "Optimize code" in project properties.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I'm having an issue in saving an rtf file, I'm saving it in a subfolder in "MyDocuments" the strange this is that i also save a .bin file and some other stuff and it doesn't causes any exeption, i'am pc admin so why does it happen?
string docs = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\Monitor\\Immobili\\";`
richTextBox1.SaveFile(docs+code);
code is also another string
An UnauthorizedAccessException means one of 3 things:
The caller does not have the required permission.
Path is a directory.
Path specified a read-only file.
Check for last two reasons. I think you are not adding filename after path. Add breakpoints and check if richTextBox1.SaveFile(docs+code); is getting the complete path to the file instead of just folder path.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I have the following code:
var test = _myDictionary.ContainsKey(myKey);
if (!test)
{
Logger.Error("My log message");
throw new ApplicationException("My exception message");
}
The dictionary contains the key. When debugging, the value of test is true
What happens, is that the code jumps directly to the throw statement, skipping the call to Logger, while it really shouldn't do neither - it should just skip the whole block and continue execution.
I've replaced the source completely from repository, I've cleaned and rebuilt numerous times, to no avail.
However, when I changed my code to
if (test)
{
// my code
}
else
{
Logger.Error("My log message");
throw new ApplicationException("My exception message");
}
everything works as expected.
Any ideas what might be going on here? It works as it currently is, but I won't rest easy unless I know what might be cause this.
UPDATE: I deleted my .suo file and some binaries in the output folder which were not deleted even if I cleaned the solution. After this, it seems to work fine
This can happen sometimes when the assembly and its PDB gets out of sync. When you're debugging, the debugger actually reads the relevant information from the PDB file, and not directly from your source file.
You should simply try and rebuild the project (or manually Clean then Build), then try again.
EDIT I misread your question, where you said you already tried rebuilding. In this case, during Debugging, go to Debug → Windows → Modules window, and make sure the symbol file that is loaded is in fact the correct one (e.g. loaded from the same bin\Debug location):
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
Hi
I am trying to read a plain text file named "test.txt" from my system but all the attempts
File.Exists(), StreamReder are not getting the file, that is not a new task for me but i am irritated due to this strange behavior. I have given full permissions to the file but in vain. I am doing the test in a C# console application. The system has a fresh installation and I am wondering of any permission issue when run in debug mode. I also copied the file to Debug folder but still same error. Can anyone please guide me about this? Thanks in advance
There is a neat function in C# for reading string files: (in System.IO namespace)
string text = File.ReadAllText("test.txt");
If you are having trouble with the path, you can add test.txt as a resource with copy to (add the file to teh project, right-click properties and select Copy to output directory.
Then you can use:
string path = Path.Combine(Directory.GetCurrentDirectory(), "test.txt");
File.ReadAllText(path);
Have you stepped through the code? The first step is to make sure the path being used in the program is correct.
Debug mode will still run under your account so, if you have permission to open the file, that won't be a problem.