Visual Studio error on Unity - FileNotFoundException

My game has a lot of AI and i’d prefer not to test it online through a Unity game. Better would be a Windows form app and some unit tests. Since Unity generates a Visual Studio project for the code, i created a new solution containing two projects. One is the project generated by Unity, the other is a WinForm app that references the Unity-generated project

The code compiles fine but when i run it, i get the error

System.IO.FileNotFoundException was unhandled
Message=“Could not load file or assembly ‘UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null’ or one of its dependencies. The system cannot find the file specified.”

i’m fairly sure my reference is fine because a)i picked it from a browser, b)it matches what’s in the Unity-generated project, c)the code compiles (which it won’t do if it can’t find the file and d)the DLL is copied to the bin/debug folder

If you look in the project file, the reference matches what’s in the Unity-generated project:

C:/development/compilers/Unity/Editor/Data/lib/UnityEngine-Debug.dll

i’ve also confirmed this file exists

i have no idea why this isn’t working, which makes fixing it slightly trickier

The very bestest fix is to remove all dependencies to Unity, which i’ve tried, but one file has a link to a class that had to be defined as a MonoBehavior to prevent it from being deleted between level loads (or so the game programmer told me)

i searched the forum but didn’t see anything

Ideas?

you can’t use the unity engine in MS .NET, you can only use it from within unity

the solution is only to use VS as a code editor

Ah. OK, that makes sense. Guess i better increase the priority of refactoring the code to remove that Unity dependency. Or learn how to write a nice AI design, test and unit test tool in Unity (i think i’ll start with refactoring :slight_smile: )

Thanks Marc