Error Could not load file or assembly 'System.Windows.Forms

porkshopp

Active member
Joined
Apr 13, 2019
Messages
26
Location
Sweden
Programming Experience
Beginner
I get this error when trying to run the code

C#:
using System;
using System.Threading;
namespace cTest
{
class Program
{
public static int Base = 0x004E4DBC;
        public static int Health = 0xF4;

static void Main(string[] args)
{
            VAMemory vam = new VAMemory("ac_client");
            int LocalPlayer = vam.ReadInt32((IntPtr)Base);
            while (true)
{
int address = LocalPlayer + Health;
                vam.WriteInt32((IntPtr)address, 9999);

                Thread.Sleep(100);

            }

        }
}
}
Activated Event Time Duration Thread
Exception thrown: 'System.IO.FileNotFoundException' in VAMemory.dll ("Could not load file or assembly 'System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.") Exception thrown: 'System.IO.FileNotFoundException' in VAMemory.dll ("Could not load file or assembly 'System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.") Hyperlink: Activate Historical Debugging 0.14s [13308] Main Thread
 
The error message tells you exactly what the issue is, in this case your code can't find a dll file: VAMemory.dll
Actually, no. The error message actually says that the exception was thrown in that assembly, not that that assembly couldn't be found. It's System.Windows.Forms.dll that couldn't be found, which is rather strange, given that it is part of the .NET Framework.

What type of project did you create in the first place? What version of the .NET Framework did you target? Is VAMemory.dll your own assembly or form another source?
 
.Net Core is announced to support Windows Forms and WPF on Windows desktops from version 3.0 that is to be released in September, but current version does not.
 
As JohnH says, .NET Core does not support WinForms until version 3.0. If you want to use it now then you will need VS 2019, which supports the preview of .NET Core 3.0. I'm not sure whether the final release will be supported in VS 2017 or not.
 
1. It should be a cheat for a singleplayer game
When I asked what type of project, I meant what project template did you select in the New Project dialogue. This whole episode is an example of why you need to provide a FULL and CLEAR explanation up front. Hopefully it has given you a feel for what type of information can be relevant and therefore needs to be provided. Problems and, therefore, solutions can be different for different versions of .NET, different project templates, different aims, etc.
 
Back
Top Bottom