.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

RealDWG 2013 - InvalidProgramException

3 REPLIES 3
Reply
Message 1 of 4
CarterN
1524 Views, 3 Replies

RealDWG 2013 - InvalidProgramException

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();
            }
        }
    }
}

 

3 REPLIES 3
Message 2 of 4
StephenPreston
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
Message 3 of 4
CarterN
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. 

Message 4 of 4
darrell.ross
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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost