0

I've added a reference to my project. It's a PixelEngine.dll and the issue is, that whenever I call a constructor, there is an Exception System.IO.FileNotFoundException. I checked the path and the dll is in the directory.

Code sample:

using PixelEngine;
using System;

namespace Herni_Engine3D
{
    public class RandomPixels : Game
    {
        static void Main(string[] args)
        {
            //Vytvořit instanci:
            RandomPixels Konzola = new RandomPixels();
            //Okno:
            Konzola.Construct(200, 200, 4, 4); //<<Here it crashes
            //Spustit:
            Konzola.Start();
        }
        //Každý snímek:
        public override void OnUpdate(float elapsed)
        {
            for (int i = 0; i < ScreenWidth; i++)
            {
                for (int j = 0; j < ScreenHeight; j++)
                {
                    Draw(i, j, Pixel.Random());
                }
            }
        }
    }
}
Maytham Fahmi
  • 31,138
  • 14
  • 118
  • 137

1 Answers1

1

I have tried to solve it, but your problem description is a bit inaccurate.

It is true you get System.IO.FileNotFoundException, but you should have provided the whole exception description:

Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'System.Drawing.Common, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
File name: 'System.Drawing.Common, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
   at PixelEngine.Sprite.Load(String path)
   at PixelEngine.Font.CreateRetro()
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
   at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.get_Value()
   at PixelEngine.Font.op_Implicit(Presets p)
   at PixelEngine.Game.Construct(Int32 width, Int32 height, Int32 pixWidth, Int32 pixHeight, Int32 frameRate)

The issue is not that your dll is not included, but the issue saying that your code is looking for System.Drawing.Common and that is easy, you can install System.Drawing.Common from NuGet packages.

So that your project has following:

<ItemGroup>
    <PackageReference Include="System.Drawing.Common" Version="6.0.0" />
</ItemGroup>

When that is done, the issue is gone, of course, you will get a new issue that it is asking for PixGL.dll, which I really do not have, I guess you should have it.

Some reference to my founds:

Maytham Fahmi
  • 31,138
  • 14
  • 118
  • 137