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

eLockViolation error code creating a new layer and make it work from push button

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
corra76
7504 Views, 4 Replies

eLockViolation error code creating a new layer and make it work from push button

Hello,

 

I wrote some code in VB .NET 2010 getting started from Kean Walmsley project to create a new layer. I did it working directly from code and not using a command line as he did.

http://through-the-interface.typepad.com/through_the_interface/2010/01/creating-an-autocad-layer-usi...

 

The problem is that the same code works if I call it directly inside the application code, but doesn't if I throw it from a push button.

 

I get the eLockViolation error code.

I don't understand why it doesn't works and how cold I solve the problem.

 

Does anyone have any suggestion?

 

Thank you

 

Corra

4 REPLIES 4
Message 2 of 5
kob4lt
in reply to: corra76

I think you must use DocumentLock class before you make any changes to database

 

Like this

 

using (DocumentLock docLock = doc.LockDocument())

{

... code where you make changes to db

}

Message 3 of 5
corra76
in reply to: kob4lt

OK, it works!

 

It's not completely clear why there are some cases it works also without lockDocument...

Il'' think about it.

 

Thank you very much!

 

Corra

Message 4 of 5
kdub_nz
in reply to: corra76

 

You'll find that routines run from the 'Application' requires document locking ... modeless dialog, palettes, COM server and commands registered using the CommandMethod attribute 'CommandFlags.Session' run in Application mode.

 

 


// Called Kerry in my other life.

Everything will work just as you expect it to, unless your expectations are incorrect.

class keyThumper<T> : Lazy<T>;      another  Swamper

Message 5 of 5
xaotix
in reply to: kob4lt

solved my problem! thx!

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