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

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

Anonymous
Not applicable
8,250 Views
4 Replies
Message 1 of 5

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

Anonymous
Not applicable

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

0 Likes
Accepted solutions (1)
8,251 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
Accepted solution

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

Anonymous
Not applicable

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

0 Likes
Message 4 of 5

kerry_w_brown
Advisor
Advisor

 

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 or kdub in my other life.

Everything will work just as you expect it to, unless your expectations are incorrect. ~ kdub
Sometimes the question is more important than the answer. ~ kdub

NZST UTC+12 : class keyThumper<T> : Lazy<T>;      another  Swamper
Message 5 of 5

xaotix
Contributor
Contributor

solved my problem! thx!

0 Likes