Entitas icon indicating copy to clipboard operation
Entitas copied to clipboard

Cannot run `Jenny.exe gen` on pure C# project

Open charlieamer opened this issue 5 years ago • 5 comments

Hi,

I tried to use Roslyn compiler on my new C# pure project, and I wasn't able to run Jenny.exe gen (i've got properly configured Jenny.properties file, as well as properly configured .csproj). I also couldn't run it using the tutorial that was provided for Entitas Pure. (so in order to reproduce the issue, just follow the tutorial on a Windows machine. Instead of mono Jenny.exe simply use Jenny.exe).

I got Jenny.zip today from Unity asset store. The version is 1.12.2.

The error that pops in the terminal is: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.

I managed to run Jenny.exe gen as a debug target in visual studio, to extract LoaderExceptions property, and here are the details LoaderExceptions details

I am trying to do this on Windows 10 machine.

EDIT: If I try to follow the tutorial, but don't enable roslyn plugin when asked, Jenny.exe gen runs without a problem.

charlieamer avatar Jan 02 '19 17:01 charlieamer

@charlieamer if you're on windows you can run Jenny.exe directly. You only need to use mono if you're on macOS.

You can append -v to any command to get verbose output e.g.

./Jenny/Jenny.exe gen -v

sschmid avatar Jan 03 '19 22:01 sschmid

when you run Jenny.exe without any parameters it will start the jenny wizard which helps you generate a proper Jenny.properties file. Usually that helps when there are any issues

sschmid avatar Jan 03 '19 22:01 sschmid

Running Jenny.exe doctor or Jenny.exe gen yields the same error. I run clean Jenny.exe (without any params) on both my own project I am trying to use, and in a clean project (created by following the tutorial from the link I provided in issue description), and I still get the error. In 2 days I will try Mono for windows, maybe that could help ? And try to run Jenny.exe with mono ?

Here is a full output of what I get when I run Jenny.exe gen -v:

Loading assemblies from C:\Users\ACER\Documents\GitHub\PiratesRising\Jenny
Name:Jenny.exe
There are no context policies.
 load: C:\Users\ACER\Documents\GitHub\PiratesRising\Jenny\DesperateDevs.Analytics.dll
  ? Loading: C:\Users\ACER\Documents\GitHub\PiratesRising\Jenny\DesperateDevs.Analytics.dll
Name:Jenny.exe
There are no context policies.
 load: C:\Users\ACER\Documents\GitHub\PiratesRising\Jenny\DesperateDevs.CLI.Utils.dll
  ? Loading: C:\Users\ACER\Documents\GitHub\PiratesRising\Jenny\DesperateDevs.CLI.Utils.dll
Name:Jenny.exe
There are no context policies.
 load: C:\Users\ACER\Documents\GitHub\PiratesRising\Jenny\DesperateDevs.CodeGeneration.CodeGenerator.dll
  ? Loading: C:\Users\ACER\Documents\GitHub\PiratesRising\Jenny\DesperateDevs.CodeGeneration.CodeGenerator.dll
Name:Jenny.exe
There are no context policies.
 load: C:\Users\ACER\Documents\GitHub\PiratesRising\Jenny\DesperateDevs.CodeGeneration.dll
  ? Loading: C:\Users\ACER\Documents\GitHub\PiratesRising\Jenny\DesperateDevs.CodeGeneration.dll
Name:Jenny.exe
There are no context policies.
 load: C:\Users\ACER\Documents\GitHub\PiratesRising\Jenny\DesperateDevs.Logging.dll
  ? Loading: C:\Users\ACER\Documents\GitHub\PiratesRising\Jenny\DesperateDevs.Logging.dll
Name:Jenny.exe
There are no context policies.
 load: C:\Users\ACER\Documents\GitHub\PiratesRising\Jenny\DesperateDevs.Logging.Formatters.dll
  ? Loading: C:\Users\ACER\Documents\GitHub\PiratesRising\Jenny\DesperateDevs.Logging.Formatters.dll
Name:Jenny.exe
There are no context policies.
 load: C:\Users\ACER\Documents\GitHub\PiratesRising\Jenny\DesperateDevs.Networking.dll
  ? Loading: C:\Users\ACER\Documents\GitHub\PiratesRising\Jenny\DesperateDevs.Networking.dll
Name:Jenny.exe
There are no context policies.
 load: C:\Users\ACER\Documents\GitHub\PiratesRising\Jenny\DesperateDevs.Serialization.CLI.Utils.dll
  ? Loading: C:\Users\ACER\Documents\GitHub\PiratesRising\Jenny\DesperateDevs.Serialization.CLI.Utils.dll
Name:Jenny.exe
There are no context policies.
 load: C:\Users\ACER\Documents\GitHub\PiratesRising\Jenny\DesperateDevs.Serialization.dll
  ? Loading: C:\Users\ACER\Documents\GitHub\PiratesRising\Jenny\DesperateDevs.Serialization.dll
Name:Jenny.exe
There are no context policies.
 load: C:\Users\ACER\Documents\GitHub\PiratesRising\Jenny\DesperateDevs.Utils.dll
  ? Loading: C:\Users\ACER\Documents\GitHub\PiratesRising\Jenny\DesperateDevs.Utils.dll
Name:Jenny.exe
There are no context policies.
 load: C:\Users\ACER\Documents\GitHub\PiratesRising\Jenny\Jenny.exe
  ? Loading: C:\Users\ACER\Documents\GitHub\PiratesRising\Jenny\Jenny.exe
Generating using Jenny.properties
Name:Jenny.exe
There are no context policies.
 load: DesperateDevs.CodeGeneration.Plugins
  ? Loading: DesperateDevs.CodeGeneration.Plugins
    ? Resolved: ../Jenny/Plugins/DesperateDevs\DesperateDevs.CodeGeneration.Plugins.dll
Name:Jenny.exe
There are no context policies.
 load: Entitas.CodeGeneration.Plugins
  ? Loading: Entitas.CodeGeneration.Plugins
    ? Resolved: ../Jenny/Plugins/Entitas\Entitas.CodeGeneration.Plugins.dll
Name:Jenny.exe
There are no context policies.
 load: Entitas.Roslyn.CodeGeneration.Plugins
  ? Loading: Entitas.Roslyn.CodeGeneration.Plugins
    ? Resolved: ../Jenny/Plugins/Entitas.Roslyn\Entitas.Roslyn.CodeGeneration.Plugins.dll
  ? Loading Dependency: Entitas.CodeGeneration.Attributes, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
    ? Resolved: ../Jenny/Plugins/Entitas.Roslyn\Entitas.CodeGeneration.Attributes.dll
Pre Processing: Validate Project Path (3%)
Pre Processing: Fix Target Framework Profile (6%)
Creating model: Context (9%)
Creating model: Cleanup (12%)
Opening PiratesRising.shproj
  ? Loading Dependency: Microsoft.CodeAnalysis.Features, Version=2.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
  ? Loading Dependency: Microsoft.CodeAnalysis.CSharp.Features, Version=2.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
  ? Loading Dependency: Microsoft.CodeAnalysis.VisualBasic.Features, Version=2.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
  ? Loading Dependency: System.Collections.Immutable, Version=1.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
    ? Resolved: ../Jenny/Plugins/Entitas.Roslyn\System.Collections.Immutable.dll
  ? Loading Dependency: SQLitePCLRaw.core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1488e028ca7ab535
  ? Loading Dependency: Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
    ? Resolved: ../Jenny/Plugins/Entitas.Roslyn\Microsoft.Build.dll
  ? Loading Dependency: Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
    ? Resolved: ../Jenny/Plugins/Entitas.Roslyn\Microsoft.Build.Tasks.Core.dll
System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
   at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
   at System.Reflection.RuntimeAssembly.get_DefinedTypes()
   at System.Composition.Hosting.ContainerConfiguration.<>c.<WithAssemblies>b__16_0(Assembly a)
   at System.Linq.Enumerable.<SelectManyIterator>d__17`2.MoveNext()
   at System.Composition.TypedParts.TypedPartExportDescriptorProvider..ctor(IEnumerable`1 types, AttributedModelProvider attributeContext)
   at System.Composition.Hosting.ContainerConfiguration.CreateContainer()
   at Microsoft.CodeAnalysis.Host.Mef.MefHostServices.Create(IEnumerable`1 assemblies)
   at Microsoft.CodeAnalysis.Host.Mef.DesktopMefHostServices.get_DefaultServices()
   at DesperateDevs.Roslyn.ProjectParser..ctor(String projectPath)
   at DesperateDevs.Roslyn.CodeGeneration.Plugins.PluginUtil.GetCachedProjectParser(Dictionary`2 objectCache, String projectPath)
   at Entitas.Roslyn.CodeGeneration.Plugins.CleanupDataProvider.GetData()
   at DesperateDevs.CodeGeneration.CodeGenerator.CodeGenerator.generate(String messagePrefix, IPreProcessor[] preProcessors, IDataProvider[] dataProviders, ICodeGenerator[] codeGenerators, IPostProcessor[] postProcessors)
   at DesperateDevs.CodeGeneration.CodeGenerator.CodeGenerator.Generate()
   at DesperateDevs.CodeGeneration.CodeGenerator.CLI.GenerateCommand.run()
   at DesperateDevs.CLI.Utils.AbstractCommand.Run(CLIProgram program, String[] args)
   at DesperateDevs.Serialization.CLI.Utils.AbstractPreferencesCommand.Run(CLIProgram program, String[] args)
   at DesperateDevs.CLI.Utils.CLIProgram.runCommand(String[] args)

charlieamer avatar Jan 03 '19 22:01 charlieamer

@sschmid After installing Mono for Windows I have managed to get it to work (after a bit of hacking).

First when I installed it and run mono ..\Jenny\Jenny.exe on my project, after i selected which plugins I want, I was presented with the following error: Could not load type of field 'Microsoft.CodeAnalysis.SQLite.Interop.SqlConnection:_handle' (0) due to: Could not load file or assembly 'SQLitePCLRaw.core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1488e028ca7ab535' or one of its dependencies.

The solution was a bit boring, I had to install the package "SQLitePCLRaw.core" in a dummy c# project, went to package files and found a SQLitePCLRaw.core.dll file, and copied the file to the same directory as where Jenny.exe resides. That made it work and it finally works like a charm (for mono ..\Jenny\Jenny.exe).

My advice: you should pack Jenny.zip with SQLitePCLRaw.core.dll pre-packaged, so that it works out of the box for third-party installed mono. You should also look into the error I mentioned above for default .NET support on windows, and see why exactly it fails, and can it be fixed. I don't think I should close the issue as this wasn't solved for me without using mono (I wasn't able to run Jenny.exe gen even after I copied SQLitePCLRaw.core.dll to Jenny directory, I still got the same error as mentioned above).

charlieamer avatar Jan 06 '19 12:01 charlieamer

follow @charlieamer , I use mono to run jenny.exe and modify Entitas.CodeGeneration.Plugins.Assemblies = Library/ScriptAssemblies/Assembly-CSharp.dll to project dll path in bin/Debug/{.netversion}/{dllname}.dll it works for me

AstralRoad avatar Jun 15 '21 08:06 AstralRoad

@charlieamer

EntitasPure has been renamed to Entitas-Standalone and is updated to .NET 6.0 and using nuget. You can now generate using dotnet. Please see: Entitas-Standalone

sschmid avatar Sep 06 '22 21:09 sschmid