Error:Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))

418
0
10-30-2012 06:18 PM
TaiBui
by
Occasional Contributor II
Hi,

I am trying to save (and load) IPersistStream into byte[] format in SQL Server. But, I got an error: Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)) in the loading function.

Please see my below codes:

public void save(AxPageLayoutControl pageControl)
{
            IPersistStream perStream;
            IMemoryBlobStream mebStream = new MemoryBlobStreamClass();

            IGraphicsContainer graphicsContainer = pageControl.ActiveView.GraphicsContainer;
            graphicsContainer.Reset();
            IElement pElement = graphicsContainer.Next();
            while (pElement != null)
            {
                if (pElement is IMapFrame)
                {
                    perStream = (IPersistStream)pElement;

                    perStream.Save(mebStream, 0);

                    byte[] map = new byte[mebStream.Size];
                    mebStream.AttachToMemory(map [0], (uint)map .Length, 0);

                    // codes to insert "map" into a sql table
                    //.....
                    break;

                }
                pElement = graphicsContainer.Next();
            }
}


For loading:

public void load(AxPageLayoutControl pageControl)
{
            IPersistStream perStream;
            IMemoryBlobStream mebStream = new MemoryBlobStreamClass();
            IGraphicsContainer graphicsContainer = pageControl.ActiveView.GraphicsContainer;
            graphicsContainer.Reset();
            IElement pElement = graphicsContainer.Next();
            while (pElement != null)
            {
                if (pElement is IMapFrame)
                {
                    // Get byte[] data from database (execute a select statement)
                    byte[] map = GetDataFromDatabase();
                    mebStream.ImportFromMemory(map [0], (uint)map .Length);
                    perStream = (IPersistStream)pElement;

                    perStream.Load(mebStream);  // Throw error 

                    IMapFrame frame = new MapFrameClass();
                    frame = (IMapFrame)perStream;
                    pElement = (IElement)frame;                   
                    break;

                }
                pElement = graphicsContainer.Next();
            }
            pageControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
}


Are there anyone can help ?

Thanks and regards,
0 Kudos
0 Replies