-1

I want to use a windows form that is in a Framework 4.7.2 library

I have the following stack ;

Framework 4.72 XAF Winforms exe which references
Framework 4.7.2 library1 which references
Framework 4.7.2 library2 which references a a standard2.0 library

I have the following code in Library2

   public static void ShowMessageBox()
    {
        MessageBox.Show("hi");
    }

    public static void ShowForm() // errors when this is called
    {
        var form = new Form1(); // debugger can not reach here
        MessageBox.Show("hi2");
    }

I can call ShowMessageBox However if I call ShowForm I get a System.IO.FileNotFoundException exception occurs immediately. The line that instantiates the form is never reached.

System.IO.FileNotFoundException: 'Could not load file or assembly 'MyLibrary, 
Version=0.0.0.0, Culture=neutral, PublicKeyToken=a3471ea16b9add4c' 
or one of its dependencies. The system cannot find the file specified.'
Kirsten
  • 15,730
  • 41
  • 179
  • 318
  • This is a follow up question from https://stackoverflow.com/questions/66232549/could-not-load-file-or-assembly-microsoft-entityframeworkcore-when-calling-sta – Kirsten Feb 19 '21 at 01:48

1 Answers1

0

I was able to get past the immediate error when I noticed that there were some yellow triangles displaying beside some old references in library2. I deleted those references.

Now the error occurs within the method and the name of the missing file is shown.

Kirsten
  • 15,730
  • 41
  • 179
  • 318