the code :
public override void OnInspectorGUI()
{
            if (null == this.myTarget)
            {
                return;
            }
            PrefabType prefabType = PrefabUtility.GetPrefabType(mCurEditScene);
            if (prefabType == PrefabType.PrefabInstance ||
                prefabType == PrefabType.DisconnectedPrefabInstance)
            {
                GameObject rootUploadGameObject = PrefabUtility.FindValidUploadPrefabInstanceRoot(mCurEditScene.gameObject);
                var prefabParent = PrefabUtility.GetPrefabParent(rootUploadGameObject);
                PrefabUtility.ReplacePrefab(rootUploadGameObject, prefabParent, ReplacePrefabOptions.ConnectToPrefab);
            }
 }
errors :
NullReferenceException: Object reference not set to an instance of an object
UnityEditor.InspectorWindow.GetEditorsWithPreviews (UnityEditor.Editor[] editors)
UnityEditor.InspectorWindow.DrawPreviewAndLabels ()
UnityEditor.InspectorWindow.OnGUI ()
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) 
UnityEditor.HostView.Invoke (System.String methodName)
UnityEditor.HostView.InvokeOnGUI (Rect onGUIPosition)