Okay, I have been working on a small application to generate configuration files for my CCTS script.
I have also included a feature for the main part of the script to be generated if the player wants to. I added a a .txt file to the project, which is the main part of the script, set its properties to embed as a resource. I then use this code after the player chooses the save directory:
DialogResult result = dialog.ShowDialog();
if (result == DialogResult.OK)
{
try
{
// Load the embedded resource from the assembly
Assembly assembly = Assembly.GetEntryAssembly();
StreamReader docScreenTest =
new StreamReader(assembly.GetManifestResourceStream(
"ForeverZer0.RMXP.CCTSConfig.CCTS v.1.2.3 Main.txt"));
File.WriteAllText(dialog.FileName, docScreenTest.ReadToEnd(),
System.Text.Encoding.Unicode);
}
catch (Exception error)
{
MessageBox.Show("Error accessing embedded resource.\r\n\r\n" + error.Message, "Load Error");
}
Here is the error message I get that pops up in the catch block:
Quote from: From the damn message box
Error accessing embedded resource.
Value cannot be null.
Parameter name: stream
I counted out all the dumb problems such as wrong filename, wrong namespace, etc., etc.
This has something to do with the difference between .NET 2.0 and .NET 4.0. I had just gotten done converting it from 4.0 to 2.0 for the sake of compatibility, and was debugging when this popped up. It compiles fine, and when I run a code analysis with VS, I don't get a single warning. I tested this completely before the switch and it was working perfectly.
Any ideas?