Error Creating Texture and Sprite

I created this very basic script so I could easily add Rectangles to my game, but for some reason when I run the game the rectangles give me the following errors:

rd->texture.IsValid()

And

rd->texture.IsValid()
UnityEditor.DockArea:OnGUI()

The rectangles display and work fine during gameplay, so why am I getting these errors?

using UnityEngine;
using UnityEditor;
using System.Collections;

public class CreateSprite : MonoBehaviour {

    [MenuItem("GameObject/2D Object/Rectangle")]
    static void CreateRectangle(){
        GameObject obj = new GameObject("Rectangle");
        SpriteRenderer spr = obj.AddComponent<SpriteRenderer>();
        BoxCollider2D bx = obj.AddComponent<BoxCollider2D>();
        bx.size = new Vector2(1f, 1f);
        Texture2D texture = Texture2D.whiteTexture;
        Sprite sprite = Sprite.Create(texture, new Rect(0, 0, 100f, 100f), new Vector2(.5f, .5f), 100f);
        sprite.name = "Rectangle";
        spr.sprite = sprite;
    }
}

I have no idea yet but thats an unusual short error message you got. There must be also an output of the involved script name and line where the error obviously appears. Can you post your full error message pls?

Oddly, that is the whole error message, which is why I can not figure it out.

I have similar problem.
But I have the error log:
!hasError
UnityEngine.Sprite:Create(Texture2D, Rect, Vector2)
Is anybody know what happen?