Could not load file or assembly system windows forms

 

Have problems with Visual Studio 2019, where I have created a solution with 2 projects. The start-up project (# 1) has been created with the Console App (.NETCore) as a base. The second project (# 2) is based on the Windows Forms app (.NET
Framework)

Project 1 contains the main logic and calls a procedure in project 2 that will set up a form, take care of specified values ​​and return this via global variables. Both projects do their jobs separately. It is when it comes to the call
that errors occur. The call has been adapted as the initial syntax error occurred which has now been corrected so compilation of the solution is error free and without warnings. When executed, there is an interruption

System.IO.FileNotFoundException:
‘Could not load file or assembly ‘System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′. Det går inte att hitta filen.’

This means that it is not possible to track in the program as I wanted. Of course, there are differences in the two projects’ .NET environments that make up for it, but it is not told how I can get hold of the missing file.

Question 1. Does anyone know how to get the file and how it is then incorporated into the environment?

I am not a VB encoder so that with Objects, classes, methods etc. is not something I have immersed myself in. However, I can do so much that I can make it work as regular calls with arguments and so on.

The call itself is simple in itself and I think I got to that with how to send the information. However, I do not find anywhere the values ​​that the parameters should contain.

Call MYform1.Form1_Load(Mysender, Myargs)

Question 2. Does anyone know how to find which values ​​should be included in the Mysender and Myargs parameters

In the log I find this

‘Project20200727.exe’ (CoreCLR: DefaultDomain): Loaded ‘C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.1.6\System.Private.CoreLib.dll’.

‘Project20200727.exe’ (CoreCLR: clrhost): Loaded ‘C:\Users\janne\source\repos\Project20200727\bin\Debug\netcoreapp3.1\Project20200727.dll’. Symbols loaded.

‘Project20200727.exe’ (CoreCLR: clrhost): Loaded ‘C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.1.6\System.Runtime.dll’.

‘Project20200727.exe’ (CoreCLR: clrhost): Loaded ‘C:\Users\janne\source\repos\Project20200727\bin\Debug\netcoreapp3.1\WindowsApp3_20200730.exe’. Symbols loaded.

An unhandled exception of type ‘System.IO.FileNotFoundException’ occurred in Unknown Module.

Could not load file or assembly ‘System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’. Det går inte att hitta filen.

The program ‘[13828] Project20200727.exe’ has exited with code -1 (0xffffffff).

Best regards

Janne

  • Moved by

    Friday, July 31, 2020 2:02 AM

ℹ️ UPDATE: Workaround here for those who need it.

. . .

There appears to be a critical problem with the new 6.0.2 update which makes apps compiled with it fail to start on machines running 6.0.1.

To reproduce, do the following:

  1. Visit Windows Update to update the runtime on your dev machine, and also update Visual Studio 2022 using Visual Studio Installer.
  2. On a client/test machine, install the 6.0.1 desktop runtime. Direct Link
  3. On your dev machine, create a new WinForms project, build it and copy the executable files to the client/test machine.
  4. Run it and it will not start. Event logs show the following:
Application: WinFormsApp1.exe
CoreCLR Version: 6.0.121.56705
.NET Version: 6.0.1
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.FileLoadException: Could not load file or assembly 'System.Windows.Forms, Version=6.0.2.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The located assembly's manifest definition does not match the assembly reference. (0x80131040)
File name: 'System.Windows.Forms, Version=6.0.2.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   at WinFormsApp1.Program.Main()

This problem did not happen on .NET 5. I was under the impression patch versions are generally compatible with each other, and I use <RollForward>LatestPatch</RollForward> in my real app, but even with that setting it still crashes.

This is a blocking issue for me because if I distribute an update for my app built on 6.0.2 and the client is still running 6.0.1, that will be bad if the app suddenly stops working.

I have an NUnit test project dedicated for unit testing which has a Target Framework of .Net Core 2.1. This test project has references of two other Projects one of which is a Windows Form based application and the other is a Class Library based application for database interactions. Both of these projects has a target framework of .Net Framework 4.6.1

I am writing a test for testing a method of the Class Library based application to test the output of the method. But it’s showing the following error,

‘System.IO.FileNotFoundException : Could not load file or assembly ‘System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′. The system cannot find the file specified.’

I have tried the following fixes and none of them worked.

  • Removing the project references and adding them again
  • Changing build platform target from AnyCPU to X86 and x64
  • Adding dependant assemblies tag inside a .config file. (Interesting things is .NET Core 2.1 doesn’t provide with a .config file)

This is the test class (Test_DataClasses.cs),

using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using System.Data.SQLite;
using SharedDataClasses;
using MantechAutomationControl;
using System.IO;
using System.Reflection;

namespace MAC_Testing
{
[TestFixture]
class Test_DataClasses
{
    #region Tests
    [Test]
    public void t_m_initializeDatabase()
    {
        //Assign
        string v_dbLocation = Path.Combine("M:\\For_Jabed\\MAC\\MAC\\MantechAutomationControl\\bin\\Debug\\", "DB.sqlite");
        //Act
        DataClasses_v2.m_initializeDatabase();
        //Assert
        Assert.That(new FileInfo(v_dbLocation), Does.Exist);
    }
    #endregion
}
}

And this is the method the above test is trying to validate,

public static class DataClasses_v2
{
    #region Variables 
    #endregion
    #region Methods
    public static void  m_initializeDatabase()
    {
        string v_executableLocation = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
        string v_dbLocation = Path.Combine(v_executableLocation, "DB.sqlite");
        if (!File.Exists(v_dbLocation))
        {
            DialogResult o_createDBFileDialogBox = MessageBox.Show("Could not find the database in the expected location:\n" + v_dbLocation + "\n\nWould you like to create a new blank database file?", "Warning", MessageBoxButtons.YesNo);
            if (o_createDBFileDialogBox == DialogResult.Yes)
            {
                SQLiteConnection.CreateFile(v_dbLocation);
                using (SQLiteConnection o_dbConnection = new SQLiteConnection(@"DataSource=" + v_dbLocation + ";Version=3;"))
                {
                    o_dbConnection.Open();
                }
            }
            else
                return;
        }
    }

I don’t really understand whats going on here. Although point to be noted I actually was working towards to use Nunit Form dll to work with Forms (DialogBox) as the method to be tested had a DialogBox to work with.

In the test project there is another class and the tests written inside those class works fine for the Same target ‘Class Library’ based project to validate a different function.

Hopefully someone will be able to explain whats going on here.

  • #1

I get this error when trying to run the code

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

See more:

salam
i have just finished a small project and i used installshield to deploy it.after a successfull installation in another pc and when i’m trying to lunch the application an error accured in a message box
<Could not load file or assembly ‘System.Windows.Forms.Ribbon35, Version=3.5.8.0, Culture=neutral, PublicKeyToken=null’ or one of its dependencies.file not found
File name: ‘System.Windows.Forms.Ribbon35, Version=3.5.8.0, Culture=neutral, PublicKeyToken=null’
>
whats the solution plz

What I have tried:

i tried to copy the dll file indicated on system32 and syswow64 and try to register it but in vain

Updated 11-Dec-16 11:35am


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject,
20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8
+1 (416) 849-8900

  • Could not find or load the qt platform plugin windows
  • Could not find bootmgr установка с флешки windows 7
  • Cossacks back to war скачать торрент для windows 10
  • Cortana что это за программа и нужна ли она на windows 10
  • Cortana для windows 10 на русском скачать