I have a blob file which I take from a database. This blob is actually an MXD file. I want to load this MXD to an axLayoutControl (ArcGIS Engine). But for security reasons I do not want to write this on disk and then load it with LoadMXD(string path) method. I want to pass it to my layout control directly. So I need to convert it to some interface like IMXDContents. Below is the code I use. But the exception "Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))" is thrown on ObjectStream.LoadObject(ref guid, k) . I googled this and the only thing I found was that I should change my platform target to x86 instead of Any CPU. Believe me I tried this in every posible way. And still not working. Can anyone please help?

IXMLStream pXMLStream = new XMLStreamClass();
pXMLStream.LoadFromBytes(ref bytes); //bytes is the cast of blob file to bytes array

IObjectStream ObjectStream = new ObjectStreamClass();
ObjectStream.Stream = pXMLStream as IStream;

IMxdContents k = new PageLayoutClass();
Guid guid = typeof(IMxdContents).GUID;

ObjectStream.LoadObject(ref guid, k);
  • 2
    Either it's a BLOB or a file, it can't be both at the same time. This is the heart of your issue, since the map document readers are all file-based. If you really want to implement this questionable "security" algorithm, you'll need to capture the information represented in the MXD, store that in the BLOB, and reinvent the entire map document in your application. – Vince Nov 1 '16 at 19:14
  • 1
    This is basically what ArcFM stored displays are/do. Did you try: var mxd = ObjectStream.LoadObject(ref guid, null) as IMxdContents; // then get the map from the mxd and load into the ArcEngine page layout control – Chris Kushnir Nov 2 '16 at 2:08
  • Thank you. You're right. That's not the right way to do. I took IPageLayout and saved it to database. Now I can retrieve it properly. @Vince – Steve Nov 4 '16 at 12:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.