.NET

Reply
Member
CarterN
Posts: 4
Registered: ‎05-25-2012
Message 1 of 4 (691 Views)

RealDWG 2013 - InvalidProgramException

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

Hello,

 

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;
        try
        {
            realDwgDatabase.ReadDwgFile(mFileName, FileShare.None, false, null);
            HostApplicationServices.WorkingDatabase = realDwgDatabase;
            importTransaction = realDwgDatabase.TransactionManager.StartTransaction();                        
        }
        catch (System.Exception ex)
        {
            Console.Write(ex.Message);
        }
        finally
        {
            if (importTransaction != null)
            {
                importTransaction.Dispose();
            }
        }
    }
}

 

Board Manager
StephenPreston
Posts: 368
Registered: ‎05-22-2006
Message 2 of 4 (684 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.

 

 

 

Cheers,

Stephen Preston
Autodesk Developer Network
Member
CarterN
Posts: 4
Registered: ‎05-25-2012
Message 3 of 4 (665 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
darrell.ross
Posts: 6
Registered: ‎11-24-2010
Message 4 of 4 (477 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,

-Darrell

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community