# Editor error after run

**URL:** https://discussions.unity.com/t/editor-error-after-run/730245
**Category:** C# & .NET
**Tags:** Scripting
**Created:** [January 28, 2019, 2:40pm UTC](https://discussions.unity.com/t/editor-error-after-run/730245 "2019-01-28T14:40:45Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![Alex1337rus](https://avatars.discourse-cdn.com/v4/letter/a/dc4da7/32.png) [@Alex1337rus](https://discussions.unity.com/u/Alex1337rus)
#### Post date: [January 28, 2019, 2:40pm UTC](https://discussions.unity.com/t/editor-error-after-run/730245/1 "2019-01-28T14:40:45Z")

</div>

Hi! I have TypeLoadException after running my project without any object on scene. I have only file with this code in project directory.

```csharp
class ChainClass
{
    public unsafe struct HashForgetfulChain
    {
        private fixed ushort banks_[1524288];
    }

    public static HashForgetfulChain m2()
    {
        return new HashForgetfulChain();
    }
}

```

StackTrace:  
TypeLoadException: Could not load type ‘HashForgetfulChain’ from assembly ‘Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null’.  
System.Reflection.MonoMethodInfo.GetMethodInfo (IntPtr handle) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:59)  
System.Reflection.MonoMethodInfo.GetAttributes (IntPtr handle) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:75)  
System.Reflection.MonoMethod.get\_Attributes () (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:245)  
System.Reflection.MethodBase.get\_IsSpecialName () (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:184)  
UnityEditor.Build.BuildPipelineInterfaces.InitializeBuildCallbacks (Boolean findBuildProcessors, Boolean findSceneProcessors) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildPipelineInterfaces.cs:149)

---

<div class="post-metadata">

### Author: ![Alex1337rus](https://avatars.discourse-cdn.com/v4/letter/a/dc4da7/32.png) [@Alex1337rus](https://discussions.unity.com/u/Alex1337rus)
#### Post date: [January 28, 2019, 2:42pm UTC](https://discussions.unity.com/t/editor-error-after-run/730245/2 "2019-01-28T14:42:41Z")

</div>

This is not my code, but only part of a project from github. I left only the minimum part to reproduce the error. How can i fix this?

---

<div class="post-metadata">

### Author: ![dgoyette](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/dgoyette/32/114815_2.png) [@dgoyette](https://discussions.unity.com/u/dgoyette)
#### Post date: [January 28, 2019, 5:08pm UTC](https://discussions.unity.com/t/editor-error-after-run/730245/3 "2019-01-28T17:08:17Z")

</div>

One thing to check if whether you’ve got “Allow ‘unsafe’ code” checked in the Player project settings.

---

<div class="post-metadata">

### Author: ![Alex1337rus](https://avatars.discourse-cdn.com/v4/letter/a/dc4da7/32.png) [@Alex1337rus](https://discussions.unity.com/u/Alex1337rus)
#### Post date: [January 28, 2019, 5:46pm UTC](https://discussions.unity.com/t/editor-error-after-run/730245/4 "2019-01-28T17:46:21Z")

</div>

> [@dgoyette](#):
>
> One thing to check if whether you’ve got “Allow ‘unsafe’ code” checked in the Player project settings.

Yes, it’s enabled.

---

<div class="post-metadata">

### Author: ![dgoyette](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/dgoyette/32/114815_2.png) [@dgoyette](https://discussions.unity.com/u/dgoyette)
#### Post date: [January 28, 2019, 6:02pm UTC](https://discussions.unity.com/t/editor-error-after-run/730245/5 "2019-01-28T18:02:47Z")

</div>

Oh. So your exception is complaining about the class HashForgetfulChain, which you haven’t shown here. Is that in a DLL you’ve imported? Is it a Native or Managed plugin? Or, where is the HashForgetfulChain class?

---

<div class="post-metadata">

### Author: ![Alex1337rus](https://avatars.discourse-cdn.com/v4/letter/a/dc4da7/32.png) [@Alex1337rus](https://discussions.unity.com/u/Alex1337rus)
#### Post date: [January 28, 2019, 6:17pm UTC](https://discussions.unity.com/t/editor-error-after-run/730245/6 "2019-01-28T18:17:05Z")

</div>

> [@dgoyette](#):
>
> Oh. So your exception is complaining about the class HashForgetfulChain, which you haven’t shown here. Is that in a DLL you’ve imported? Is it a Native or Managed plugin? Or, where is the HashForgetfulChain class?

Oh sorry, I have modified the code and forgot to change the error. Now it’s correct.

---

<div class="post-metadata">

### Author: ![Alex1337rus](https://avatars.discourse-cdn.com/v4/letter/a/dc4da7/32.png) [@Alex1337rus](https://discussions.unity.com/u/Alex1337rus)
#### Post date: [January 29, 2019, 2:19pm UTC](https://discussions.unity.com/t/editor-error-after-run/730245/7 "2019-01-29T14:19:45Z")

</div>

bump

---

<div class="post-metadata">

### Author: ![dgoyette](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/dgoyette/32/114815_2.png) [@dgoyette](https://discussions.unity.com/u/dgoyette)
#### Post date: [January 29, 2019, 3:15pm UTC](https://discussions.unity.com/t/editor-error-after-run/730245/8 "2019-01-29T15:15:28Z")

</div>

Can you show a line of code that’s calling or trying to use the HashForgetfulChain struct? I don’t know much of anything about unsafe code, and I understand that nested classes/structs can be public even if the outer class is private, but maybe see if making ChainClass public changes the behavior?

---

<div class="post-metadata">

### Author: ![Alex1337rus](https://avatars.discourse-cdn.com/v4/letter/a/dc4da7/32.png) [@Alex1337rus](https://discussions.unity.com/u/Alex1337rus)
#### Post date: [January 30, 2019, 10:07am UTC](https://discussions.unity.com/t/editor-error-after-run/730245/9 "2019-01-30T10:07:48Z")

</div>

> [@dgoyette](#):
>
> Can you show a line of code that’s calling or trying to use the HashForgetfulChain struct? I don’t know much of anything about unsafe code, and I understand that nested classes/structs can be public even if the outer class is private, but maybe see if making ChainClass public changes the behavior?

I have modified code and now HashForgetfulChain used only in “m2” method.

---

<div class="post-metadata">

### Author: ![dgoyette](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/dgoyette/32/114815_2.png) [@dgoyette](https://discussions.unity.com/u/dgoyette)
#### Post date: [January 30, 2019, 2:33pm UTC](https://discussions.unity.com/t/editor-error-after-run/730245/10 "2019-01-30T14:33:37Z")

</div>

I just tried out this code to see what was going on, and got the same error. Look carefully at the error and you should hopefully see the issue:

> [@](#):
>
> Value type instance size (3048592) cannot be zero, negative, or bigger than 1Mb

It seems that trying to initialize banks\_ to contain so many elements (about 1.5 million) causes the error. Changing `banks_[1524288];` to `banks_[10];`, for example, caused the code to run without issue.

So you’d have to decide whether that array really needs to be so large, or whether it’ll work fine with a small size.

---

<div class="post-metadata">

### Author: ![Alex1337rus](https://avatars.discourse-cdn.com/v4/letter/a/dc4da7/32.png) [@Alex1337rus](https://discussions.unity.com/u/Alex1337rus)
#### Post date: [January 30, 2019, 3:36pm UTC](https://discussions.unity.com/t/editor-error-after-run/730245/11 "2019-01-30T15:36:06Z")

</div>

This error really explains what the problem is in the size of the structure and not in something else. I will try to do something with this. Thanks for the help!
