Posts: 4
Registered: ‎05-25-2012
Message 1 of 4 (745 Views)

RealDWG 2013 - InvalidProgramException

745 Views, 3 Replies
05-25-2012 06:48 AM



My company recently purchased RealDWG 2013 so we can import/export DWG/DXF files, obviously


I've hit a small stumbling block when integrating RealDWG 2013 into our application, we keep getting an InvalidProgramException.


Below is the code I have so far, not much but it throws the exception everytime on the line importTransaction = realDwgDatabase.TransactionManager.StartTransaction();


The dumpdwg sample that is installed with RealDWG 2013 is encountering this problem. Also the issue is the same using both 32/64-Bit versions of RealDWG 2013.


Is there some initialisation I'm missing or a licensing issue at play here? Any help would be much appreciated.


using (RealDWGImportHost host = new RealDWGImportHost())
    RuntimeSystem.Initialize(host, 1337);
    using (Database realDwgDatabase = new Database(false, true))
        Transaction importTransaction = null;
            realDwgDatabase.ReadDwgFile(mFileName, FileShare.None, false, null);
            HostApplicationServices.WorkingDatabase = realDwgDatabase;
            importTransaction = realDwgDatabase.TransactionManager.StartTransaction();                        
        catch (System.Exception ex)
            if (importTransaction != null)


Board Manager
Posts: 419
Registered: ‎05-22-2006
Message 2 of 4 (738 Views)

Re: RealDWG 2013 - InvalidProgramException

05-25-2012 08:34 AM in reply to: CarterN

It sounds like your executable isn't finding the RealDWG components it needs. As an example, you'd get this exception if the only version of AcDbMdg.dll on the search path for your application was the stripped down version shipped with the SDK (i.e. your application can't find the full version shipped with the RealDWG installation components). You might be able to confirm this by running something like Dependency Walker (dependes.exe) on your application.


Make sure you've correctly installed RealDWG and that you've set your search paths so your app can find the RealDWG components.





Stephen Preston
Autodesk Developer Network
Posts: 4
Registered: ‎05-25-2012
Message 3 of 4 (719 Views)

Re: RealDWG 2013 - InvalidProgramException

05-26-2012 09:57 AM in reply to: StephenPreston

Firstly thank you for your response Stephen.


I managed to get the DumpDwg sample working by dropping the built exe in the RealDWG root folder.


As for my my application I'm still having trouble. I changed my reference from the stripped down AcDbMgd.dll found in the include folder of the RealDWG folder to the acdbmgd.dll found in the root of the RealDWG. Now I cannot build by application with it saying that 'An attempt was made to load an assembly with an incorrect format'.


So now I'm a bit stuck on what to do next, there seems to be no documentation on how to set up a project with RealDWG. 

Active Member
Posts: 6
Registered: ‎11-24-2010
Message 4 of 4 (531 Views)

Re: RealDWG 2013 - InvalidProgramException

11-26-2012 07:48 AM in reply to: CarterN

"So now I'm a bit stuck on what to do next, there seems to be no documentation on how to set up a project with RealDWG."


Have you not read the documentation that comes with RealDWG? There is actually quite a bit of material there on how to create a project. Down to details on specific settings for each project. You appear to be copying DLLs around. Why not use the merge modules (MSMs) to merge in needed dependencies at build time?


I could be misunderstanding your issue. I spent quite a bit of time wandering the help files while working on our RealDWG solution.


Good luck,


Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!