InvalidCastException

i get an InvalidCastException on a=(News)myLoadedAssetBundle.Load(“News”) as News;

Code:
private void Newsload(){

	w = WWW.LoadFromCacheOrDownload ("file://"+FileLocation+"/news.unity3d",1); 

	 if (w.error != null)

    {

        Debug.Log (w.error);

        return;

    }

	

	

}

private void  News(){

	GUI.Box(new Rect(0,0, 500, 500),"");

	if(a == null){

		Newsload();

		AssetBundle myLoadedAssetBundle = w.assetBundle;

		

		a=(News)myLoadedAssetBundle.Load("News") as News;

		

	}

	else{

	

	}

}

news.cs
Code:
using UnityEngine;
using System.Collections;

public class News : MonoBehaviour {

// Update is called once per frame
public void gui() {
	GUI.Label(new Rect(10, 50, 100, 100), "Username: ");
}

}
this is te file that is in the assetBundle does anyone have solution for this??

First of all you should know exactly what you put into the AssetBundle. Most likely it will be a GameObject. In this case you have the answer already - you can't cast a GameObject to a MonoBehaviour.

Try the following code:

IEnumerator LoadAsset()  
{  
    WWW w = WWW.LoadFromCacheOrDownload("file://" + FileLocation + "/news.unity3d", 1);  

    //wait until the loading process finished! (you missed that one)
    yield return w;

    //check if there was an error
    if (string.IsNullOrEmpty(w.error))
    {
        AssetBundle myLoadedAssetBundle = w.assetBundle;

        //instantiate the gameobject
        GameObject obj = GameObject.Instantiate(myLoadedAssetBundle.Load("News")) as GameObject;
        if (obj != null)
        {
            //NOW access the component of the instantiated asset!
            News news = obj.GetComponent<News>();

            //.. do something
        }
    }
}

Cheers, Tommy

Blockquote
First of all you should know exactly what you put into the AssetBundle. Most likely it will be a GameObject. In this case you have the answer already - you can’t cast a GameObject to a MonoBehaviour.

I only added the News.cs file in my asset bundle
how do you add GameObjects??