# CoherenceMonoBridge: : The instantiation of the prefab 'Wildlife\_Agent\_Base (Coherence.Toolkit.CoherenceSync)' failed: System.NullReferenceException

**URL:** <https://community.coherence.io/t/coherencemonobridge-the-instantiation-of-the-prefab-wildlife-agent-base-coherence-toolkit-coherencesync-failed-system-nullreferenceexception/161>\
**Category:** Bug reports\
**Created:** [October 14, 2022, 9:52am UTC](https://community.coherence.io/t/coherencemonobridge-the-instantiation-of-the-prefab-wildlife-agent-base-coherence-toolkit-coherencesync-failed-system-nullreferenceexception/161 "2022-10-14T09:52:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kirsten\_Miller](https://dub1.discourse-cdn.com/flex017/user_avatar/community.coherence.io/kirsten_miller/32/97_2.png) [@Kirsten\_Miller](https://community.coherence.io/u/Kirsten_Miller)\
**Post date:** [October 14, 2022, 9:52am UTC](https://community.coherence.io/t/coherencemonobridge-the-instantiation-of-the-prefab-wildlife-agent-base-coherence-toolkit-coherencesync-failed-system-nullreferenceexception/161/1 "2022-10-14T09:52:20Z")

</div>

## Bug Description

```auto
(coherence) CoherenceMonoBridge: : The instantiation of the prefab 'Wildlife_Agent_Base (Coherence.Toolkit.CoherenceSync)' failed: System.NullReferenceException

3350 at (wrapper managed-to-native) UnityEngine.Component.get_gameObject(UnityEngine.Component)

3351 at Coherence.Toolkit.CoherenceMonoBridge.InstantiateNetworkedEntity (Coherence.Toolkit.CoherenceSync syncPrefab, Coherence.Toolkit.CoherenceMonoBridge+SpawnInfo info, Coherence.Entity.SerializeEntityID entityID, Coherence.Entity.EntityUpdate entityUpdate, System.String newName) [0x00051] in /builds/bossians/production/wild-skies/Library/PackageCache/io.coherence.sdk@0.9.1/Coherence.Toolkit/CoherenceMonoBridge.cs:836 , stacktrace: UnityEngine.Debug:LogError (object,UnityEngine.Object)

3352Coherence.Log.UnityLogger:BuildAndPrintLog (Coherence.Log.LogLevel,string,System.Text.StringBuilder,System.ValueTuple`2<string, object>[]) (at /builds/bossians/production/wild-skies/Library/PackageCache/io.coherence.sdk@0.9.1/Coherence.Log/UnityLogger.cs:120)

3353Coherence.Log.Logger:Log (Coherence.Log.LogLevel,string,System.ValueTuple`2<string, object>[]) (at /builds/bossians/production/wild-skies/Library/PackageCache/io.coherence.sdk@0.9.1/Coherence.Log/Logger.cs:110)

3354Coherence.Log.Logger:Error (string,System.ValueTuple`2<string, object>[]) (at /builds/bossians/production/wild-skies/Library/PackageCache/io.coherence.sdk@0.9.1/Coherence.Log/Logger.cs:78)

3355Coherence.Log.UnityLogger:Error (string,System.ValueTuple`2<string, object>[]) (at /builds/bossians/production/wild-skies/Library/PackageCache/io.coherence.sdk@0.9.1/Coherence.Log/UnityLogger.cs:66)

3356Coherence.Toolkit.CoherenceMonoBridge:InstantiateNetworkedEntity (Coherence.Toolkit.CoherenceSync,Coherence.Toolkit.CoherenceMonoBridge/SpawnInfo,Coherence.Entity.SerializeEntityID,Coherence.Entity.EntityUpdate,string) (at /builds/bossians/production/wild-skies/Library/PackageCache/io.coherence.sdk@0.9.1/Coherence.Toolkit/CoherenceMonoBridge.cs:900)

3357Coherence.Toolkit.CoherenceMonoBridge/<>c __DisplayClass113_0:<CreateNetworkedEntity>b__ 0 (Coherence.Toolkit.CoherenceSync) (at /builds/bossians/production/wild-skies/Library/PackageCache/io.coherence.sdk@0.9.1/Coherence.Toolkit/CoherenceMonoBridge.cs:825)

3358Coherence.Toolkit.PrefabLoader`1<Coherence.Toolkit.AddressablesLoader>:ProcessEvents (Coherence.Toolkit.CoherenceSync,System.Action`1<Coherence.Toolkit.CoherenceSync>) (at /builds/bossians/production/wild-skies/Library/PackageCache/io.coherence.sdk@0.9.1/Coherence.Toolkit/PrefabLoader.cs:42)

3359Coherence.Toolkit.AddressablesLoader/<>c __DisplayClass1_0:<Load>b__ 0 (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1<UnityEngine.GameObject>) (at /builds/bossians/production/wild-skies/Library/PackageCache/io.coherence.sdk@0.9.1/Coherence.Toolkit/PrefabLoader.cs:84)

3360DelegateList`1<UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1<UnityEngine.GameObject>>:Invoke (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1<UnityEngine.GameObject>) (at /builds/bossians/production/wild-skies/Library/PackageCache/com.unity.addressables@1.20.0/Runtime/ResourceManager/Util/DelegateList.cs:69)

3361UnityEngine.AsyncOperation:InvokeCompletionEvent () (at /home/bokken/buildslave/unity/build/Runtime/Export/Scripting/AsyncOperation.cs:21)

```

Collapse

## Expected behaviour

## Screenshots

If applicable, add screenshots to help explain the problem.

## How to reproduce

Sometimes

**Steps:**

1. Start 4 clients
2. client 0 creates a room
3. 3 other clients join
4. Test different sort of conditions (e.g. max players +1, owner disconnects)

intermittently seeing above error and not sure why

## Environment

SDK: v0.9.1  
Engine: ?  
Unity: 2022.1.8f  
OS/Platform: Linux/Docker - clients run in batchmode nographics

---

<div class="post-metadata">

**Author:** ![per\_coh](https://dub1.discourse-cdn.com/flex017/user_avatar/community.coherence.io/per_coh/32/27_2.png) [@per\_coh](https://community.coherence.io/u/per_coh)\
**Post date:** [October 14, 2022, 10:43am UTC](https://community.coherence.io/t/coherencemonobridge-the-instantiation-of-the-prefab-wildlife-agent-base-coherence-toolkit-coherencesync-failed-system-nullreferenceexception/161/2 "2022-10-14T10:43:20Z")

</div>

Hi @Kirsten_Miller thanks for posting. We just released 0.9.2. I don’t know if that will resolve this, but it’s a good starting point.

---

<div class="post-metadata">

**Author:** ![per\_coh](https://dub1.discourse-cdn.com/flex017/user_avatar/community.coherence.io/per_coh/32/27_2.png) [@per\_coh](https://community.coherence.io/u/per_coh)\
**Post date:** [October 24, 2022, 9:45am UTC](https://community.coherence.io/t/coherencemonobridge-the-instantiation-of-the-prefab-wildlife-agent-base-coherence-toolkit-coherencesync-failed-system-nullreferenceexception/161/3 "2022-10-24T09:45:56Z")

</div>

Following up on this. I believe you discussed with some of my colleagues and this was the outcome?

It seemed to be an intermittent error and removing the prefab as having the addressables box ticked and updating the prefabMapper to make it not be loaded as an addressable seems to fix the issue.

---

<div class="post-metadata">

**Author:** ![Kirsten\_Miller](https://dub1.discourse-cdn.com/flex017/user_avatar/community.coherence.io/kirsten_miller/32/97_2.png) [@Kirsten\_Miller](https://community.coherence.io/u/Kirsten_Miller)\
**Post date:** [October 24, 2022, 12:58pm UTC](https://community.coherence.io/t/coherencemonobridge-the-instantiation-of-the-prefab-wildlife-agent-base-coherence-toolkit-coherencesync-failed-system-nullreferenceexception/161/4 "2022-10-24T12:58:48Z")

</div>

Hey,

Yes doing both those steps resolved the issue.

We were wondering does coherence not support having a prefab with addressabkes box ticked but then loading it not via addresssables? Because we found the coherence prefabMapper seemed to automatically update to load via addressables when the box was ticked

---

<div class="post-metadata">

**Author:** ![miguel-coherence](https://dub1.discourse-cdn.com/flex017/user_avatar/community.coherence.io/miguel-coherence/32/101_2.png) [@miguel-coherence](https://community.coherence.io/u/miguel-coherence)\
**Post date:** [October 24, 2022, 1:57pm UTC](https://community.coherence.io/t/coherencemonobridge-the-instantiation-of-the-prefab-wildlife-agent-base-coherence-toolkit-coherencesync-failed-system-nullreferenceexception/161/5 "2022-10-24T13:57:45Z")

</div>

You can, but is not advisable.

If you bundle a prefab through Addressables, but you also reference it directly in your build (either via a scene or resources dependency, or as a dependency of an object that is always loaded (like PrefabMapper)), then your asset will be duplicated in disk, but it will also be duplicated in memory.

You can check asset duplication for your particular project with Addressables Analyze tool.
