I'm an experienced developer with VBA but am now moving everything to .NET, which I'm new to concerning AutoCAD (as of this week new) so this should be a pretty easy stuff that I can't get to work. I built a function that should return a reference to an object that I want to change some properties to, lets say the layer for example. The problem is, the object returns all right, I can read the ObjectId or anything else, but if I try to change the layer an eNotOpenForWrite error pops up and AutoCAD crashes. Why is this happening if I am opening it in a ForWrite mode? Am I perhaps writing a whole lot of nonesense in the GetEntity function that appears to work but really doesn't? I've tried this with existing objects, objects I draw at the moment, and objects created from code... no positive result. Could anyone point me in the right direction? Thanks.
Note: Both routines are in different projects each on it's own class, acadDB and acadTrans are previously declared in the class that GetEntity belongs to cause other functions use them as well. objModelLayout is an instance of the class that contains GetEntity. I am using Visual Studio 2005 and AutoCAD 2006.
Public Function GetEntity(ByVal Prompt As String) As Entity
Dim optEntityOptions As New PromptEntityOptions(vbCrLf & Prompt)
Dim presEntity As PromptEntityResult
Dim dbobjObject As DBObject = Nothing
Dim Command As Editor