Changing a shader's texture (albedo) with C#

Getting no from this, other than the cube im applying it to is solid white as if no shader is applied. I’m just looking for a very simple way to change the (albedo) texture on a model’s shader. All I found by searching was outdated syntax that Visual Studio changed to the below code. “atexture” is just the asset name of an imported graphic, I’m not sure if something needs to be done to it via syntax first.

GameObject myobject;
Texture thetexture;

myobject = GameObject.Find(gameObject.name);
thetexture = (Texture2D)Resources.Load(“atexture”);
myobject.GetComponent().material.mainTexture = thetexture;

edit: I should point out this is a script attached to a cube primitive

It might have something to do with the way the cube primitive is uv-mapped. Does it work with another mesh?