Why do I get an error when changing the parent of instaitaed object?

I get this error Setting the parent of a transform which resides in a prefab is disabled to prevent data corruption. UnityEngine.Transform:set_parent(Transform) Spawner:Spawn() (at Assets/Scripts/Spawner.cs:77) Spawner:Start() (at Assets/Scripts/Spawner.cs:53)

[/Users/build/builds/unity-iphone-1.5/iphone-1.1/Projects/../Runtime/Graphics/Transform.cpp line 161]

when I do this code

    public GameObject monster1;
public GameObject monster2;
public Transform monster1Holder;
public Transform monster2Holder;

.... ...

    	GameObject monster = monster1;
	int m = 1;
	if (currentMonsterRatio > Random.RandomRange(0 , 100)) {
		monster = monster2;
		m = 2;
	GameObject mn = (GameObject)Instantiate(monster,SpawnPoint(),Quaternion.identity);
	((Monster)mn.GetComponent(typeof(Monster))).velocity += curentSpeedIncrease;
	if (m==1) mn.transform.parent = monster1Holder;
	else mn.transform.parent = monster2Holder;

line 77 is the second last line of code here. Also the parent is not changed. I know this code used to work because I could see the objects in the correct place in the hierarchy. I had to change prefab I was instantiating and now I get this error.

What's in monster1Holder and monster2Holder? are they transforms from gameobjects in your scene, or from prefabs?

Your problem could be that if they're prefabs, you're attempting to set your newly instantiated objects as children of these prefabs (which is probably just as invalid as setting parents of prefabs!).