.NET

.NET

Reply
Contributor
cvaught
Posts: 12
Registered: ‎01-25-2012
Message 1 of 8 (252 Views)

AccessViolationException for PublishExecute

252 Views, 7 Replies
06-01-2012 08:18 AM

I have created a batch publishing plugin that is causing the following error:

 

AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

 

The execption occurs at PublishExecute in the following abbreviated code snippet:

 

DsdData dsdd = newDsdData();

dsdd.ReadDsd(dsdFile);

 

Publisher publisher = Application.Publisher;

PlotConfig pc = PlotConfigManager.SetCurrentConfig("DWG To PDF.pc3");

 

publisher.PublishExecute(dsdd, pc);

 

This error does NOT occur in my development environment - AutoCAD 2010, Window XP, 32-bit.  It does occur on a customers machine - AutoCAD 2011, Win7, 64-bit.

 

Any ideas on what I need to change to solve this problem?  Any help would be greatly appreciated.

 


Valued Mentor
fieldguy
Posts: 368
Registered: ‎03-31-2005
Message 2 of 8 (238 Views)

Re: AccessViolationException for PublishExecute

06-01-2012 10:37 AM in reply to: cvaught

I have never used publish or sheet sets in .net.  You can read more >>here<<.  If you add a try/catch you should get more detailed exception information.

 

My 1st guess would be access to the pc3 file.  Check to make the sure the client has access to (example is Map 3d 2011 on Win 7 Pro x64) C:\Users\"username"\AppData\Roaming\Autodesk\AutoCAD Map 3D 2011\R18.1\enu\Plotters. 

 

If you wanted to try moving the pc3 file to a folder you know the user has full access to, you can add a shortcut to the path you want to use in the folder above.  In other words, autocad will find PC3 files in an alternate path if a shortcut to that path is found in the folder specified in Options->Files->Printer Support File Path->Printer Configuration Search Path.  You have to do the same with the associated PMP file.  We use this approach but we also rename the PC3 & PMP files.

Contributor
cvaught
Posts: 12
Registered: ‎01-25-2012
Message 3 of 8 (235 Views)

Re: AccessViolationException for PublishExecute

06-01-2012 11:46 AM in reply to: fieldguy

I should have mentioned that the error is not constant.  Sometimes the publishing works and no error is thrown.  I would say that the error occurs greater than 50% of the time.  Since it works sometimes I assume that would mean it isn't likely to be related to the pc3 file but I will investigate it.

Valued Mentor
fieldguy
Posts: 368
Registered: ‎03-31-2005
Message 4 of 8 (228 Views)

Re: AccessViolationException for PublishExecute

06-01-2012 01:53 PM in reply to: cvaught

Are you using "backgroundplot" = 0?

 

Autodesk.Autocad.ApplicationServices.Application.SetSystemVariable("BACKGROUNDPLOT", 0) sets plot and publish to foreground.

Contributor
cvaught
Posts: 12
Registered: ‎01-25-2012
Message 5 of 8 (226 Views)

Re: AccessViolationException for PublishExecute

06-01-2012 01:56 PM in reply to: fieldguy

Yes

Contributor
cvaught
Posts: 12
Registered: ‎01-25-2012
Message 6 of 8 (208 Views)

Re: AccessViolationException for PublishExecute

06-03-2012 11:37 AM in reply to: cvaught

I have determined that this error only occurs when I netload the plugin dll into AutoCAD from a standalong application that is connected to AutoCAD.  If I manually open AutoCAD, netload the plugin, the PublishExecute works without an issue.  What is affected by the fact that I am controlling AutoCAD from a standalong application?

Valued Mentor
fieldguy
Posts: 368
Registered: ‎03-31-2005
Message 7 of 8 (198 Views)

Re: AccessViolationException for PublishExecute

06-04-2012 07:59 AM in reply to: cvaught

You will have to search here.  External access uses COM and internal access uses .NET.  I have not created any standalone exe that accesses autocad.  There is a link >>here<<.

 

There are several discussions in this forum on standalone vs internal, com vs. net, exe and dll, etc.

 

The problem is mixing managed api (internal) like acmgd, and acdmgd with external (com).

 

Good luck!

Contributor
csludtke
Posts: 24
Registered: ‎03-17-2003
Message 8 of 8 (72 Views)

Re: AccessViolationException for PublishExecute

09-30-2013 11:41 AM in reply to: fieldguy

Did you ever resolve your issue?

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 or visit the Installation and Licensing Forum to get help installing your software.