ntrampolines=8192,nrgctx-trampolines=8192,nimt-trampolines=8192
using JetBrains.Annotations; using strange.extensions.context.impl; namespace Assets.Game { internal class GameRoot : ContextView { [UsedImplicitly] protected void Awake() { context = new GameContext(this); } } }
if we bypass this GameContext altogether, that means we aren't ever instantiating a class which has an injectionbinder object in it.
Therefore, how do we ever invoke a method on injection binder?
Therefore, how do we ever use strangeioc?
So if there is no context, what is the alternative? How do we invoke these methods without a context?
do you mean to inside the GameRoot script above simply include the line for example:
var obj = new CrossContextInjectionBinder(); ?
And then continue with this?
Or would you prefer an instance of one of the base classes ? and if so which one?
using UnityEngine;using strange.extensions.injector.api;using strange.extensions.injector.impl;using strange.extensions.dispatcher.eventdispatcher.api;using strange.extensions.dispatcher.eventdispatcher.impl;using strange.extensions.context.api;using strange.framework.api;
public class StrangeBehavior : MonoBehaviour{ private void Update( ) { if( Input.GetButtonDown( "Submit" ) ) { TestBindings( ); } }
private void OnGUI( ) { if( GUILayout.Button( "Begin Test" ) ) { TestBindings( ); } }
private void TestBindings( ) { Debug.Log( "Beginning binding tests..." );
// Example Code from CrossContext.addCoreComponents, line 87. //ICrossContextInjectionBinder injectionBinder = new CrossContextInjectionBinder( ) //injectionBinder.Bind<IEventDispatcher>().To<EventDispatcher>().ToSingleton().ToName(ContextKeys.CROSS_CONTEXT_DISPATCHER).CrossContext();
//--------//--------//--------//-------- // TEST 00: BINDINGS //--------//--------//--------//--------
// TEST 00a: Binding.To<T>( ) // RESULT: PASS IBinding iBinding00a = new EventBinding( ); IBinding iBindingTo00a = iBinding00a.To<EventDispatcher>( );
// TEST 00b: Binding.To( System.Type ) // RESULT: PASS IBinding iBinding00b = new EventBinding( ); IBinding iBindingTo00b = iBinding00b.To( typeof( EventDispatcher ) );
// TEST 01a: InjectionBinding.To<T> // RESULT: PASS IInjectionBinding iInjectionBinding01a = new InjectionBinding( null ); IInjectionBinding iInjectionBindingTo01a = iInjectionBinding01a.To<EventDispatcher>( );
// TEST 01b: InjectionBinding.To( System.Type ) // RESULT: PASS IInjectionBinding iInjectionBinding01b = new InjectionBinding( null ); IInjectionBinding iInjectionBindingTo01b = iInjectionBinding01b.To( typeof( EventDispatcher ) );
//--------//--------//--------//-------- // TEST 10: BINDERS //--------//--------//--------//--------
// TEST 10a: InjectionBinder.Bind<T>( ) // RESULT: PASS IInjectionBinder iInjectionBinder10a = new InjectionBinder( ); IInjectionBinding iInjectionBinding10a = iInjectionBinder10a.Bind<IEventDispatcher>( );
// TEST 10b: InjectionBinder.Bind( System.Type ) // RESULT: PASS IInjectionBinder iInjectionBinder10b = new InjectionBinder( ); IInjectionBinding iInjectionBinding10b = iInjectionBinder10b.Bind( typeof( IEventDispatcher ) );
// TEST 10c: InjectionBinder.Bind<T>( ).To<T>( ) // RESULT: FAIL //IInjectionBinder iInjectionBinder10c = new InjectionBinder( ); //IInjectionBinding iInjectionBindingBind10c = iInjectionBinder10c.Bind<IEventDispatcher>( ); // Execution fails here on XB1! //IInjectionBinding iInjectionBindingTo10c = iInjectionBindingBind10c.To<IEventDispatcher>( );
// TEST 10d: InjectionBinder.Bind<T>( ).To( System.Type ) // RESULT: FAIL //IInjectionBinder iInjectionBinder10d = new InjectionBinder( ); //IInjectionBinding iInjectionBindingBind10d = iInjectionBinder10d.Bind<IEventDispatcher>( ); // Execution fails here on XB1! //IInjectionBinding iInjectionBindingTo10d = iInjectionBindingBind10d.To( typeof( IEventDispatcher ) );
// TEST 10e: InjectionBinder.Bind( System.Type ).To<T>( ) // RESULT: FAIL //IInjectionBinder iInjectionBinder10e = new InjectionBinder( ); //IInjectionBinding iInjectionBindingBind10e = iInjectionBinder10e.Bind( typeof( IEventDispatcher ) ); //IInjectionBinding iInjectionBindingTo10e = iInjectionBindingBind10e.To<IEventDispatcher>( ); // Execution fails here on XB1!
// TEST 10f: InjectionBinder.Bind( System.Type ).To( System.Type ) // RESULT: PASS IInjectionBinder iInjectionBinder10f = new InjectionBinder( ); IInjectionBinding iInjectionBindingBind10f = iInjectionBinder10f.Bind( typeof( IEventDispatcher ) ); IInjectionBinding iInjectionBindingTo10f = iInjectionBindingBind10f.To( typeof( IEventDispatcher ) );
//--------//--------//--------//-------- // TEST 100: FULL BIND CHAIN //--------//--------//--------//--------
ICrossContextInjectionBinder iCrossContextInjectionBinder = new CrossContextInjectionBinder( ); IInjectionBinding iInjectionBindingBind = iCrossContextInjectionBinder.Bind<IEventDispatcher>( ); //IInjectionBinding iInjectionBindingTo = iInjectionBindingBind.To<EventDispatcher>( ); // Execution fails here on XB1! IInjectionBinding iInjectionBindingTo = iInjectionBindingBind.To( typeof( EventDispatcher ) ); // Execution succeeds here on XB1! IInjectionBinding iInjectionBindingToSingleton = iInjectionBindingTo.ToSingleton( ); IInjectionBinding iInjectionBindingToName = iInjectionBindingToSingleton.ToName( ContextKeys.CROSS_CONTEXT_DISPATCHER ); IInjectionBinding iInjectionBindingCrossContext = iInjectionBindingToName.CrossContext( ); }}
// CrossContext.cs
protected override void addCoreComponents(){ base.addCoreComponents(); if (injectionBinder.CrossContextBinder == null) //Only null if it could not find a parent context / firstContext { injectionBinder.CrossContextBinder = new CrossContextInjectionBinder(); }
if (firstContext == this)
{ #region ElsEdit //injectionBinder.Bind<IEventDispatcher>().To<EventDispatcher>().ToSingleton().ToName(ContextKeys.CROSS_CONTEXT_DISPATCHER).CrossContext(); // Execution fails here on XB1! //injectionBinder.Bind<CrossContextBridge> ().ToSingleton ().CrossContext(); // Execution fails here on XB1, too!
injectionBinder.Bind( typeof( IEventDispatcher ) ).To( typeof( EventDispatcher ) ).ToSingleton().ToName(ContextKeys.CROSS_CONTEXT_DISPATCHER).CrossContext(); injectionBinder.Bind( typeof( CrossContextBridge ) ).ToSingleton().CrossContext(); #endregion // ElsEdit }}
At least that is my understanding
RESULTS (Target: XB1, Build Type: Development Player, Deploy Method: Package, Script Debugging: enabled. Built with Windows Unity 5.2.0b5)
[IL2CPP, .NET 2.0 Subset] - runtime error
[IL2CPP, .NET 2.0 Subset, Strip Engine Code] - runtime error
[IL2CPP, .NET 2.0] - runtime error
[IL2CPP, .NET 2.0, Strip Engine Code] - runtime error
[Mono2x, .NET 2.0 Subset, Disabled] - hang at launch
[Mono2x, .NET 2.0 Subset, Strip Assemblies] - hang at launch
[Mono2x, .NET 2.0 Subset, Strip Bytecode] - crash at launch
[Mono2x, .NET 2.0 Subset, Micro Mscorlib] - hang at launch
[Mono2x, .NET 2.0, Disabled] - hang at launch
[Mono2x, .NET 2.0, Strip Assemblies] - hang at launch
[Mono2x, .NET 2.0, Strip Bytecode] - crash at launch
[Mono2x, .NET 2.0, Micro Mscorlib] - crash at launch
ReflectionException: the reflector requires concrete classes.Type UnityEngine.Camera has no constructor. Is it an interface?
InjectorException: attempt to instantiate a null binding. target: strange.examples.strangerocks.ScreenUtil type: UnityEngine.Camera name: GAME_CAMERA
ReflectionException: The reflector requires concrete classes.Type UnityEngine.Camera has no constructor. Is it an interface? at strange.extensions.reflector.impl.ReflectionBinder.mapPreferredConstructor (IReflectedClass reflected, IBinding binding, System.Type type) [0x00000] in <filename unknown>:0 at strange.extensions.reflector.impl.ReflectionBinder.Get (System.Type type) [0x00000] in <filename unknown>:0 at strange.extensions.injector.impl.Injector.Inject (System.Object target, Boolean attemptConstructorInjection) [0x00000] in <filename unknown>:0 at strange.extensions.injector.impl.Injector.getValueInjection (System.Type t, System.Object name, System.Object target) [0x00000] in <filename unknown>:0 at strange.extensions.injector.impl.Injector.performSetterInjection (System.Object target, IReflectedClass reflection) [0x00000] in <filename unknown>:0 at strange.extensions.injector.impl.Injector.Inject (System.Object target, Boolean attemptConstructorInjection) [0x00000] in <filename unknown>:0 at strange.extensions.injector.impl.Injector.Instantiate (IInjectionBinding binding) [0x00000] in <filename unknown>:0 at strange.extensions.injector.impl.Injector.getValueInjection (System.Type t, System.Object name, System.Object target) [0x00000] in <filename unknown>:0 at strange.extensions.injector.impl.Injector.performSetterInjection (System.Object target, IReflectedClass reflection) [0x00000] in <filename unknown>:0 at strange.extensions.injector.impl.Injector.Inject (System.Object target, Boolean attemptConstructorInjection) [0x00000] in <filename unknown>:0 at strange.extensions.mediation.impl.MediationBinder.injectViewAndChildren (IView view) [0x00000] in <filename unknown>:0 at strange.extensions.mediation.impl.MediationBinder.Trigger (MediationEvent evt, IView view) [0x00000] in <filename unknown>:0 at strange.extensions.mediation.impl.MediationBinder.injectViewAndChildren (IView view) [0x00000] in <filename unknown>:0 at strange.extensions.mediation.impl.MediationBinder.Trigger (MediationEvent evt, IView view) [0x00000] in <filename unknown>:0 at strange.extensions.context.impl.MVCSContext.postBindings () [0x00000] in <filename unknown>:0 at strange.examples.strangerocks.ui.UIContext.postBindings () [0x00000] in <filename unknown>:0 at strange.extensions.context.impl.Context.Start () [0x00000] in <filename unknown>:0 at strange.extensions.context.impl.Context..ctor (System.Object view, ContextStartupFlags flags) [0x00000] in <filename unknown>:0 at strange.examples.strangerocks.ui.UIBootstrap.Start () [0x00000] in <filename unknown>:0 at System.Collections.Generic.Dictionary`2+KeyCollection[TKey,TValue].System.Collections.Generic.ICollection<TKey>.get_IsReadOnly () [0x00000] in <filename unknown>:0 at System.Collections.Generic.Dictionary`2+KeyCollection[TKey,TValue].System.Collections.Generic.ICollection<TKey>.get_IsReadOnly () [0x00000] in <filename unknown>:0 at System.Collections.Generic.Dictionary`2+KeyCollection[TKey,TValue].System.Collections.Generic.ICollection<TKey>.get_IsReadOnly () [0x00000] in <filename unknown>:0 at System.Collections.Generic.Dictionary`2+KeyCollection[TKey,TValue].System.Collections.Generic.ICollection<TKey>.get_IsReadOnly () [0x00000] in <filename unknown>:0 at System.Collections.Generic.Dictionary`2+KeyCollection[TKey,TValue].System.Collections.Generic.ICollection<TKey>.get_IsReadOnly () [0x00000] in <filename unknown>:0 at System.Collections.Generic.Dictionary`2+KeyCollection[TKey,TValue].System.Collections.Generic.ICollection<TKey>.get_IsReadOnly () [0x00000] in <filename unknown>:0 at System.Collections.Generic.Dictionary`2+KeyCollection[TKey,TValue].System.Collections.Generic.ICollection<TKey>.get_IsReadOnly () [0x00000] in <filename unknown>:0 at System.Collections.Generic.Dictionary`2+KeyCollection[TKey,TValue].System.Collections.Generic.ICollection<TKey>.get_IsReadOnly () [0x00000] in <filename unknown>:0 at System.Collections.Generic.Dictionary`2+KeyCollection[TKey,TValue].System.Collections.Generic.ICollection<TKey>.get_IsReadOnly () [0x00000] in <filename unknown>:0 at System.Collections.Generic.Dictionary`2+KeyCollection[TKey,TValue].System.Collections.Generic.ICollection<TKey>.get_IsReadOnly () [0x00000] in <filename unknown>:0 System.Collections.Generic.KeyCollection:System.Collections.Generic.ICollection<TKey>.get_IsReadOnly()System.Collections.Generic.KeyCollection:System.Collections.Generic.ICollection<TKey>.get_IsReadOnly()System.Collections.Generic.KeyCollection:System.Collections.Generic.ICollection<TKey>.get_IsReadOnly()System.Collections.Generic.KeyCollection:System.Collections.Generic.ICollection<TKey>.get_IsReadOnly()System.Collections.Generic.KeyCollection:System.Collections.Generic.ICollection<TKey>.get_IsReadOnly()System.Collections.Generic.KeyCollection:System.Collections.Generic.ICollection<TKey>.get_IsReadOnly()System.Collections.Generic.KeyCollection:System.Collections.Generic.ICollection<TKey>.get_IsReadOnly()System.Collections.Generic.KeyCollection:System.Collections.Generic.ICollection<TKey>.get_IsReadOnly() (Filename: currently not available on il2cpp Line: -1)
InjectionException: Attempt to Instantiate a null binding. target: strange.examples.strangerocks.ScreenUtil type: UnityEngine.Camera name: GAME_CAMERA at strange.extensions.injector.impl.Injector.failIf (Boolean condition, System.String message, InjectionExceptionType type, System.Type t, System.Object name, System.Object target) [0x00000] in <filename unknown>:0 at strange.extensions.injector.impl.Injector.getValueInjection (System.Type t, System.Object name, System.Object target) [0x00000] in <filename unknown>:0 at strange.extensions.injector.impl.Injector.performSetterInjection (System.Object target, IReflectedClass reflection) [0x00000] in <filename unknown>:0 at strange.extensions.injector.impl.Injector.Inject (System.Object target, Boolean attemptConstructorInjection) [0x00000] in <filename unknown>:0 at strange.extensions.injector.impl.Injector.Instantiate (IInjectionBinding binding) [0x00000] in <filename unknown>:0 at strange.extensions.injector.impl.Injector.getValueInjection (System.Type t, System.Object name, System.Object target) [0x00000] in <filename unknown>:0 at strange.extensions.injector.impl.Injector.performSetterInjection (System.Object target, IReflectedClass reflection) [0x00000] in <filename unknown>:0 at strange.extensions.injector.impl.Injector.Inject (System.Object target, Boolean attemptConstructorInjection) [0x00000] in <filename unknown>:0 at strange.extensions.mediation.impl.MediationBinder.injectViewAndChildren (IView view) [0x00000] in <filename unknown>:0 at strange.extensions.mediation.impl.MediationBinder.Trigger (MediationEvent evt, IView view) [0x00000] in <filename unknown>:0 at strange.extensions.context.impl.MVCSContext.AddView (System.Object view) [0x00000] in <filename unknown>:0 at strange.extensions.mediation.impl.View.bubbleToContext (UnityEngine.MonoBehaviour view, Boolean toAdd, Boolean finalTry) [0x00000] in <filename unknown>:0 at strange.extensions.mediation.impl.View.Start () [0x00000] in <filename unknown>:0 at System.Collections.Generic.Dictionary`2+KeyCollection[TKey,TValue].System.Collections.Generic.ICollection<TKey>.get_IsReadOnly () [0x00000] in <filename unknown>:0 at System.Collections.Generic.Dictionary`2+KeyCollection[TKey,TValue].System.Collections.Generic.ICollection<TKey>.get_IsReadOnly () [0x00000] in <filename unknown>:0 at System.Collections.Generic.Dictionary`2+KeyCollection[TKey,TValue].System.Collections.Generic.ICollection<TKey>.get_IsReadOnly () [0x00000] in <filename unknown>:0 at System.Collections.Generic.Dictionary`2+KeyCollection[TKey,TValue].System.Collections.Generic.ICollection<TKey>.get_IsReadOnly () [0x00000] in <filename unknown>:0 at System.Collections.Generic.Dictionary`2+KeyCollection[TKey,TValue].System.Collections.Generic.ICollection<TKey>.get_IsReadOnly () [0x00000] in <filename unknown>:0 at System.Collections.Generic.Dictionary`2+KeyCollection[TKey,TValue].System.Collections.Generic.ICollection<TKey>.get_IsReadOnly () [0x00000] in <filename unknown>:0 at System.Collections.Generic.Dictionary`2+KeyCollection[TKey,TValue].System.Collections.Generic.ICollection<TKey>.get_IsReadOnly () [0x00000] in <filename unknown>:0 at System.Collections.Generic.Dictionary`2+KeyCollection[TKey,TValue].System.Collections.Generic.ICollection<TKey>.get_IsReadOnly () [0x00000] in <filename unknown>:0 at System.Collections.Generic.Dictionary`2+KeyCollection[TKey,TValue].System.Collections.Generic.ICollection<TKey>.get_IsReadOnly () [0x00000] in <filename unknown>:0 at System.Collections.Generic.Dictionary`2+KeyCollection[TKey,TValue].System.Collections.Generic.ICollection<TKey>.get_IsReadOnly () [0x00000] in <filename unknown>:0 System.Collections.Generic.KeyCollection:System.Collections.Generic.ICollection<TKey>.get_IsReadOnly()System.Collections.Generic.KeyCollection:System.Collections.Generic.ICollection<TKey>.get_IsReadOnly()System.Collections.Generic.KeyCollection:System.Collections.Generic.ICollection<TKey>.get_IsReadOnly()System.Collections.Generic.KeyCollection:System.Collections.Generic.ICollection<TKey>.get_IsReadOnly()System.Collections.Generic.KeyCollection:System.Collections.Generic.ICollection<TKey>.get_IsReadOnly()System.Collections.Generic.KeyCollection:System.Collections.Generic.ICollection<TKey>.get_IsReadOnly()System.Collections.Generic.KeyCollection:System.Collections.Generic.ICollection<TKey>.get_IsReadOnly()System.Collections.Generic.KeyCollection:System.Collections.Generic.ICollection<TKey>.get_IsReadOnly() (Filename: currently not available on il2cpp Line: -1)
PMEM [T276]: Could not map profile memory (8). ProfilingMode might be disabled. Use xbconfig to enable it.0110:0114 @ 00004531 - LdrpNameToOrdinal - WARNING: Procedure "DllGetActivationFactory" could not be located in DLL at base 0x0000010175F40000.0110:0114 @ 00004531 - LdrpReportError - WARNING: Locating export "DllGetActivationFactory" for DLL "Unknown" failed with status: 0xc0000139.Connect to pipe \SEVPipe\ac5565c4a08ce91bNamed pipe listen \\.\SEVPipe\15_aff8719e8f3f4a55Connect to pipe \SEVPipe\489865be4cf25161Unity for Xbox built on XDK 13004.Connect to pipe \SEVPipe\8e7396e60d08ec24Application Path: G:/XboxOnePlayer.exeG:/XboxOnePlayer.exePlayerConnection initialized from G:/Data (debug = 0)PlayerConnection initialized network socket : 0.0.0.0 4600Multi-casting "[IP] 192.168.0.36 [Port] 4600 [Flags] 3 [Guid] 1438739884 [EditorId] 3316863107 [Version] 1048832 [Id] XboxOnePlayer(192.168.0.36):4601 [Debug] 1" to [225.0.0.222:34997]...Waiting for connection from host on [192.168.0.36:4600]...PlayerConnection accepted from [192.168.0.26] handle:0x1a8[PlayerPrefs] PlayerPrefs cannot be used. Ensure that you have setup yourTitleID, SCID in the PlayerSettings window and that your DevKit is setup to use the proper sandbox.GfxDevice: creating device client; threaded=1PMEM [T320]: Could not map profile memory (8). ProfilingMode might be disabled. Use xbconfig to enable it.Failed to initialize profiling memory.---------------------------------------------------------Xbox User Mode Driver for Direct3D 11.1 / GameCopyright (C) Microsoft Corporation. All rights reserved.---------------------------------------------------------Using Direct3D 11.X Monolithic (Instrumented)XboxOne Direct3D: Version: Xbox One Direct3D 11.1 Renderer: Microsoft Xbox One Renderer (ID=0x0) Vendor: Microsoft VRAM: 6144 MBMono path[0] = 'G:/Data/Managed'Mono config path = 'G:/Data/Managed'PlayerConnection already initialized - listening to [192.168.0.36:4600]Using monoOptions --debugger-agent=transport=dt_socket,embedding=1,defer=y,address=0.0.0.0:4601Connect to pipe \SEVPipe\5450104eaf24bf49Initialize engine version: 5.2.0b5 (ee847a19704b)---------------------------------------------------------Xbox User Mode Driver for Direct3D 11.1 / GameCopyright (C) Microsoft Corporation. All rights reserved.---------------------------------------------------------Using Direct3D 11.X Monolithic (Instrumented)0110:0140 @ 00006125 - LdrpNameToOrdinal - WARNING: Procedure "DllGetActivationFactory" could not be located in DLL at base 0x0000010178070000.0110:0140 @ 00006125 - LdrpReportError - WARNING: Locating export "DllGetActivationFactory" for DLL "Unknown" failed with status: 0xc0000139.Begin MonoManager ReloadAssemblyPlatform assembly: G:\Data\Managed\UnityEngine.dll (this message is harmless)Platform assembly: G:\Data\Managed\System.dll (this message is harmless)Platform assembly: G:\Data\Managed\Mono.Security.dll (this message is harmless)Platform assembly: G:\Data\Managed\System.Configuration.dll (this message is harmless)Platform assembly: G:\Data\Managed\System.Xml.dll (this message is harmless)Platform assembly: G:\Data\Managed\System.Security.dll (this message is harmless)Platform assembly: G:\Data\Managed\System.Core.dll (this message is harmless)Platform assembly: G:\Data\Managed\Mono.Posix.dll (this message is harmless)Platform assembly: G:\Data\Managed\Assembly-CSharp.dll (this message is harmless)Platform assembly: G:\Data\Managed\UnityEngine.UI.dll (this message is harmless)Platform assembly: G:\Data\Managed\UnityEngine.Networking.dll (this message is harmless)Platform assembly: G:\Data\Managed\UnityEngine.Analytics.dll (this message is harmless)- Completed reload, in 1.190 seconds . [ 0.137853 ] seconds to load first level Window has gained focusPlayerConnection accepted from [192.168.0.26] handle:0x580
Unity even in 5.3 also can not seem to create a working Web gl build either. As far as I can tell it is the exact same issue. Probably, if someone can get it to work on webgl, the same would work for the consoles.