modesttree / Zenject

Dependency Injection Framework for Unity3D
MIT License
2.54k stars 273 forks source link

PlaceholderFactory likes to pretend it doesn't exist at times. #31

Open asusralis opened 5 years ago

asusralis commented 5 years ago

I've had this problem for a few months now, and it seems random for when it happens.

It seems that PlaceholderFactory likes to act like it isn't a class which with give errors saying it cannot be found. This only happens in VS as Unity will compile and run, but VS will not compile which will lead to me not being able to debug.

It seems like PlaceholderFactory is the only class that gives trouble as other classes in Zenject - even in the same file - will not give any errors. I've fixed this by exiting Unity, deleting all my sln/vsprog files, and running Unity again. This will work for a time until the problem randomly comes back.

I'm free to dig deeper into this, but I'm not sure where to start as it is very random.

JuegoShivaprsad commented 5 years ago

I think it is specific to visual studio, have you tried it with latest visual studio on Windows10? Mac Visual studio is very buggy.

asusralis commented 5 years ago

Hey! Yes, I have the latest Visual Studio of 2019 (16.2.5). It's interesting because it's always from Zenject/PlaceholderFactory. No other library gives me this issue.

asusralis commented 5 years ago

Here is the output:

------ Rebuild All started: Project: Assembly-CSharp-Editor-firstpass, Configuration: Debug Any CPU ------ error CS0009: Metadata file 'C:\XXX\Temp\UnityVS_bin\Debug\Zenject.dll' could not be opened -- Could not find a part of the path 'C:\XXX\Temp\UnityVS_bin\Debug\Zenject.dll'. ------ Rebuild All started: Project: Assembly-CSharp-Editor, Configuration: Debug Any CPU ------ error CS0009: Metadata file 'C:\XXX\Temp\UnityVS_bin\Debug\Zenject.dll' could not be opened -- Could not find a part of the path 'C:\XXX\Temp\UnityVS_bin\Debug\Zenject.dll'. ========== Rebuild All: 3 succeeded, 5 failed, 0 skipped ==========

Deleting all project/sln files fixes this issue, but it eventually comes back.

JuegoShivaprsad commented 5 years ago

Use Rider its amazing BTW... but its paid...

IanLondon commented 4 years ago

On Linux with VSCode (backed by Mono I think), Unity 2019.3, I'm getting The type or namespace name 'PlaceholderFactory<>' could not be found (are you missing a using directive or an assembly reference?). I'm using Zenject; in the script this is coming from, and other Zenject classes. Haven't been able to get it working, tried deleting the .sln, tried reinstalling Extenject from Assets Store with everything checked, so I have to avoid using PlaceholderFactory :grimacing:

Maybe this is a Linux issue, I'm also having problems using SignalBus

asusralis commented 4 years ago

What unity and visual studio version are you on? I haven't had this problem in a long time, but I have no idea what fixed it.

IanLondon commented 4 years ago

just updated. ^ I'm not using Visual Studio, I'm using VSCode

Update: my problems were due to using an assembly definition in Scripts/ and not referencing the Zenject assembly definition in it, so core Zenject worked but PlaceholderFactory (and SignalBus) wouldn't get resolved