I am receiving between 20 to 60 errors stating:
Severity Code Description Project File Line Suppression State Error CS0246 The type or namespace name 'ALMSTWKND' could not be found (are you missing a using directive or an assembly reference?) App Name C:\Users\realj\Documents\Visual Studio 2019\App Name\GettingStarted.cs 2 Active
However, I am referencing this DLL and have written using directives all throughout my code where required. I cannot post all the code due to how many files and using directives there are, but here is a bit:
using App_Name.Properties;
using ALMSTWKND.UI.WindowsForms.Controls;
using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Media;
using System.Runtime.CompilerServices;
Something which may be of importance is that this project was recently decompiled using JustDecompile because I lost the original source dating back to 2009.
I have seen other questions of this nature on StackOverflow, where the suggestions were to make sure that each project targets the same version of the .NET framework. I have made sure that these projects both target the same version.
Code update:
using System;
using System.IO;
using System.Reflection;
using System.Windows.Forms;
namespace App_Name
{
internal static class Program
{
public static Version version;
public static string appVersion;
public static string AppDataDirectory;
public static string ColorHistoryFilePath;
public static History history;
static Program()
{
Program.version = Assembly.GetExecutingAssembly().GetName().Version;
Program.AppDataDirectory = string.Concat(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "\\App Name\\");
Program.ColorHistoryFilePath = string.Concat(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "\\App Name\\.history");
}
public static void EnsureAppDataDirectoryExists()
{
if (!Directory.Exists(Program.AppDataDirectory))
{
Directory.CreateDirectory(Program.AppDataDirectory);
}
}
[STAThread]
private static void Main()
{
Program.appVersion = Application.ProductVersion;
Program.EnsureAppDataDirectoryExists();
if (History.Exists(Program.ColorHistoryFilePath))
{
History.Load(Program.ColorHistoryFilePath);
}
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Window());
}
}
}
Screenshot update:
Update:
Upon changing the following line of code inside the Program.cs file Application.Run(new Window());
to Application.Run(new About());
I can get the About dialog to open without error.
Update 2: I got it working by commenting-out the following lines inside the Window.cs file:
//this.notificationIcon = null;
//this.notificationIcon.Icon = (System.Drawing.Icon)componentResourceManager.GetObject("notificationIcon.Icon");
CodePudding user response:
I finally got the application to build and run correctly by commenting-out these lines in the Window.cs file:
//this.notificationIcon = null;
//this.notificationIcon.Icon = (System.Drawing.Icon)componentResourceManager.GetObject("notificationIcon.Icon");