b.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
Texture2D tex = Texture2D.Load(g.device, ms);
The Save() call leaves the memory stream positioned at the end of the stream. Which will confuzzle the Load() method, it can't read any data from the stream. You'll have to rewind the stream explicitly. Insert this statement between the two lines of code:
ms.Position = 0;