Corrupted mainData?

Initialize engine version: 4.0.0f7
GfxDevice: creating device client; threaded=1
Direct3D:
Version: Direct3D 9.0c [nvumdshim.dll 8.17.12.9687]
Renderer: NVIDIA GeForce GT 650M
Vendor: NVIDIA
VRAM: 1995 MB (via DXGI)
Caps: Shader=30 DepthRT=1 NativeDepth=1 NativeShadow=1 DF16=0 DF24=0 INTZ=1 RAWZ=0 NULL=1 RESZ=0 SlowINTZ=0
Begin MonoManager ReloadAssembly
Platform assembly: C:\Users\Mossy\Documents\Unity Projects\MZ5_Data\Managed\UnityEngine.dll (this message is harmless)
Loading C:\Users\Mossy\Documents\Unity Projects\MZ5_Data\Managed\UnityEngine.dll into Unity Child Domain
Platform assembly: C:\Users\Mossy\Documents\Unity Projects\MZ5_Data\Managed\Assembly-CSharp-firstpass.dll (this message is harmless)
Loading C:\Users\Mossy\Documents\Unity Projects\MZ5_Data\Managed\Assembly-CSharp-firstpass.dll into Unity Child Domain
Platform assembly: C:\Users\Mossy\Documents\Unity Projects\MZ5_Data\Managed\Assembly-CSharp.dll (this message is harmless)
Loading C:\Users\Mossy\Documents\Unity Projects\MZ5_Data\Managed\Assembly-CSharp.dll into Unity Child Domain
Platform assembly: C:\Users\Mossy\Documents\Unity Projects\MZ5_Data\Managed\Assembly-UnityScript-firstpass.dll (this message is harmless)
Loading C:\Users\Mossy\Documents\Unity Projects\MZ5_Data\Managed\Assembly-UnityScript-firstpass.dll into Unity Child Domain
Platform assembly: C:\Users\Mossy\Documents\Unity Projects\MZ5_Data\Managed\Assembly-UnityScript.dll (this message is harmless)
Loading C:\Users\Mossy\Documents\Unity Projects\MZ5_Data\Managed\Assembly-UnityScript.dll into Unity Child Domain
Platform assembly: C:\Users\Mossy\Documents\Unity Projects\MZ5_Data\Managed\DynNav.dll (this message is harmless)
Loading C:\Users\Mossy\Documents\Unity Projects\MZ5_Data\Managed\DynNav.dll into Unity Child Domain
- Completed reload, in 0.049 seconds
desktop: 1366x768 60Hz; virtual: 1366x768 at 0,0
Initializing input.

<RI> Input initialized.

The file 'C:/Users/Mossy/Documents/Unity Projects/MZ5_Data/mainData' is corrupted! Remove it and launch unity again!
[Position out of bounds! 103604 > 103600]
 
(Filename: C:/BuildAgent/work/812c4f5049264fad/Runtime/Serialize/CacheWrap.cpp Line: 269)

Have tried for ages to sort this issue out

I had a similar issue. Maindata corrupted along with sharedAssets.

The solution was to find script duplicates in my project. After they were deleted the problem was gone.

Sorry, but yeah i fixed it.

I had to delete my script and remake it, and it worked. Seems i corrupted it somehow.

Thanks for the replies.

Duplicate script file names were the problem that caused this. JS files that I transcribed to C# and had the same file name (except for the extension, off course).

I had this problem too and if you have a larger project where multiple people’s been involved, it might be hard to find the files which conflicts. Hence, I wrote a small script that helps you find script name conflicts. Copy the code bellow and place them in scripts located in Assets\Scripts\Editor\

Filename: DuplicateWindow.cs

using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;

/// <summary>
/// Duplicate window.
/// 
/// This script searches for scripts which has naming conflicts.
/// 
/// Created by Simon Jonasson, 
/// Inspiered by Kristian Langelund Helle Jespersen, http://zaxisgames.blogspot.se/2012/02/automatically-locate-all-unused-assets.html
/// </summary>
[ExecuteInEditMode]
public class DuplicateWindow : EditorWindow {
	List<string> m_Strings = new List<string> ();
	static bool m_Init = false;
	static bool m_Found = false;
	
	// Add menu named "CleanUpWindow" to the Window menu 
	[MenuItem("Window/DupesWindow")] 
	static void Init() 
	{ 
		// Get existing open window or if none, make a new one: 
		DuplicateWindow window = (DuplicateWindow)EditorWindow.GetWindow(typeof(DuplicateWindow));
		window.minSize = new Vector2 (200, 300);
		window.Show(); 
		m_Init = false;
		m_Found = false;
	} 

	//This ain't pretty, but it works. I am by no means a GUI designer :-P
	void OnGUI() 
	{ 
			
		GUIStyle style = new GUIStyle ();
		style.wordWrap = true;
		style.normal.textColor = Color.white;

		GUILayout.BeginVertical ();
		if (GUILayout.Button("Log dupes")) 
		{ 
			compareAssetList(UsedAssets.GetAllAssets()); 
			m_Init = true;

		} 
		if (m_Init && !m_Found) {
			style.normal.textColor = Color.green;
			GUILayout.Label ("

No duplicates found :smiley:

", style);
style.normal.textColor = Color.white;
} else if ( m_Init && m_Found){
style.normal.textColor = Color.red;
string s = “”;
foreach( string t in m_Strings ){
s = s + t + "
“;
}
GUILayout.Label (”
Duplicates found!!!

" + s, style);
Debug.Log("Found duplicates:
“+s);
style.normal.textColor = Color.white;
} else {
GUILayout.Label (”
Press the button above. The results will be printed in this window and in the console.

The seach might take a few minues. During that time, Unity will freeze

In the case there is a huge amount of conflicts, you might need to expand the window and press the button again

Known issues: This window will sometimes not register clicks and sometimes revert to this ‘Init’ stage after a seach has been done. In that case, just do the search again.", style);
}
GUILayout.EndVertical ();
}

	private void compareAssetList(string[] assetList) 
	{ 

		m_Strings.Clear ();
		List<string> filenames = new List<string> ();
		for (int i = 0; i < assetList.Length; i++) 
		{  
			string s =  assetList_.Substring( assetList*.LastIndexOf("/") +1 ).ToLower();	//Get the filename without path*_

* int idx = s.IndexOf(“.”); //find index of the file-type specifier*

* if( idx > 0 ){*
* string type = s.Substring(idx);*

* if( idx > 0 && (type == “.cs” || type == “.boo” || type == “.js”)){*
* s = s.Substring(0, idx); //get filename without file type*
* filenames.Add(s);*
* }*
* }*
* }*

* filenames.Sort ();*
* for( int i = 1; i < filenames.Count; i++ ){*
_ if( filenames == filenames[i-1] ){ //Since the strings are sorted, if string n and n-1 is identical, two script files has the same name
* m_Found = true;
if( !m_Strings.Contains(filenames) ){
m_Strings.Add(filenames);*

* }
}
}
}
}*

Filename: UsedAssets.cs
using UnityEngine;
using UnityEditor;
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;_

*// Created by Kristian Langelund Helle Jespersen, http://zaxisgames.blogspot.se/2012/02/automatically-locate-all-unused-assets.html*_
public class UsedAssets
{
* public static string GetAllAssets()
{
string[] tmpAssets1 = Directory.GetFiles(Application.dataPath, ".", SearchOption.AllDirectories);
string tmpAssets2 = Array.FindAll(tmpAssets1, name => !name.EndsWith(“.meta”));
string allAssets;*_

* allAssets = Array.FindAll(tmpAssets2, name => !name.EndsWith(“.unity”));*

* for (int i = 0; i < allAssets.Length; i++)*
* {*
allAssets = allAssets_.Substring(allAssets*.IndexOf(“/Assets”) + 1);_
allAssets _= allAssets.Replace(@"", “/”);
}*_

* return allAssets;*
* }*

* public static void GetLists(ref List assetResult, ref List dependencyResult)*
* {*
* assetResult.Clear();*
* dependencyResult.Clear();*

* string LocalAppData = string.Empty;*
* string UnityEditorLogfile = string.Empty;*

* if (Application.platform == RuntimePlatform.WindowsEditor)*
* {*
* LocalAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);*
* UnityEditorLogfile = LocalAppData + “\Unity\Editor\Editor.log”;*
* }*
* else if (Application.platform == RuntimePlatform.OSXEditor)*
* {*
* LocalAppData = Environment.GetFolderPath(Environment.SpecialFolder.Personal);*
* UnityEditorLogfile = LocalAppData + “/Library/Logs/Unity/Editor.log”;*
* }*

* try*
* {*
* // Have to use FileStream to get around sharing violations!*
* FileStream FS = new FileStream(UnityEditorLogfile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);*
* StreamReader SR = new StreamReader(FS);*

* string line;*
* while (!SR.EndOfStream && !(line = SR.ReadLine()).Contains(“Mono dependencies included in the build”));*
* while (!SR.EndOfStream && (line = SR.ReadLine()) != “”)*
* {*
* dependencyResult.Add(line);*
* }*
* while (!SR.EndOfStream && !(line = SR.ReadLine()).Contains(“Used Assets,”));*
* while (!SR.EndOfStream && (line = SR.ReadLine()) != “”)*
* {*

* line = line.Substring(line.IndexOf("% ") + 2);*
* assetResult.Add(line);*
* }*
* }*
* catch (Exception E)*
* {*
* Debug.LogError("Error: " + E);*
* }*
* }*
}

I hadnt done anything to my unity project. It was uploaded and working fine until this morning and I get the content error.
In my log this is the only thing that is conspicuous
desktop: 1366x768 60Hz; virtual: 1366x768 at 0,0
Crash!!!

I saw the same error while using some scripts that did not inherit from MonoBehaviour and had [System.Serializable] on them so that I could inspect their properties in the editor. After removing the Serialized attribute the error went away.

I found the same error while using “#if UNITY_EDITOR” directive to enable some variables just only in Editor mode. I guess that it causes Unity serialization work improperly.

In my case the problem was due to having several generic classes with the same name but different numbers of generic parameters:

abstract class ClassName : MonoBehaviour { }
abstract class ClassName<T> : ClassName { }
abstract class ClassName<T1, T2> : ClassName<T1> { }

Renaming the classes solved the problem for me.