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

GetXDataForApplication

14 REPLIES 14
Reply
Message 1 of 15
Jan1
2007 Views, 14 Replies

GetXDataForApplication

Hi together,

I have a problem with reading xData information.
This is my code:

...
Dim xData() As TypedValue
Dim res As ResultBuffer
Try
res = ent.GetXDataForApplication(_sAppName)
If res IsNot Nothing Then
Try
xData = res.AsArray
Catch ex As Exception
_ed.WriteMessage(vbCrLf & ex.Message & vbCrLf)
End Try
sSuf1 = CType(xData(1), TypedValue).Value
sSuf2 = CType(xData(2), TypedValue).Value
End If
Catch ex As Exception
_ed.WriteMessage(vbCrLf & ex.Message & vbCrLf)
End Try
...


The entity was opened in read mode before and my program is iterating through all entities from all blocks. The program is working without any problem in debug mode, but with the release version I am getting errors like:

Fehler: Ausnahmebedingung aufgetreten: 0xC0000005 (Zugriffsverletzung)
System.Reflection.TargetInvocationException: Ein Aufrufziel hat einen Ausnahmefehler verursacht.
---> System.NullReferenceException: Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.
bei Autodesk.AutoCAD.DatabaseServices.ResultBuffer.ResbufToTypedValue(resbuf* item)
bei Autodesk.AutoCAD.DatabaseServices.ResultBuffer.AsArray()

I have added some debug output to my code that prints out the Handle for each entity. Through this I could see that the program stops at different objects. So I can be sure that this has nothing to do with invalide objects.

What is the problem? Any ideas?

Regards, Jan
14 REPLIES 14
Message 2 of 15
Anonymous
in reply to: Jan1

what's going on in "GetXDataFor.."?
ResultBuffer rb = ent.Xdata;

wrote in message news:5467013@discussion.autodesk.com...
Hi together,

I have a problem with reading xData information.
This is my code:

...
Dim xData() As TypedValue
Dim res As ResultBuffer
Try
res = ent.GetXDataForApplication(_sAppName)
If res IsNot Nothing Then
Try
xData = res.AsArray
Catch ex As Exception
_ed.WriteMessage(vbCrLf & ex.Message & vbCrLf)
End Try
sSuf1 = CType(xData(1), TypedValue).Value
sSuf2 = CType(xData(2), TypedValue).Value
End If
Catch ex As Exception
_ed.WriteMessage(vbCrLf & ex.Message & vbCrLf)
End Try
...


The entity was opened in read mode before and my program is iterating
through all entities from all blocks. The program is working without any
problem in debug mode, but with the release version I am getting errors
like:

Fehler: Ausnahmebedingung aufgetreten: 0xC0000005 (Zugriffsverletzung)
System.Reflection.TargetInvocationException: Ein Aufrufziel hat einen
Ausnahmefehler verursacht.
---> System.NullReferenceException: Der Objektverweis wurde nicht auf eine
Objektinstanz festgelegt.
bei
Autodesk.AutoCAD.DatabaseServices.ResultBuffer.ResbufToTypedValue(resbuf*
item)
bei Autodesk.AutoCAD.DatabaseServices.ResultBuffer.AsArray()

I have added some debug output to my code that prints out the Handle for
each entity. Through this I could see that the program stops at different
objects. So I can be sure that this has nothing to do with invalide objects.

What is the problem? Any ideas?

Regards, Jan
Message 3 of 15
NathTay
in reply to: Jan1

GetXDataForApplication is a method of database objects it reurns a result buffer of the XData for the specific application name. The Xdata property returns a result buffer of XData for all application names.

Regards - Nathan
Message 4 of 15
Jan1
in reply to: Jan1

Thanks Nathan.
This is a method from Autodesk.AutoCAD.DatabaseServices.DBObject

Regards, Jan
Message 5 of 15
Jan1
in reply to: Jan1

Hello,

is there anybody who can help me with the problem.
There seems to be a difference between the debug and the release version. What can it be?

Regards, Jan
Message 6 of 15
chad.randall
in reply to: Jan1

I know this is old, but I am experiencing the exact same problem.

If you iterate through large numbers of Xrecords, the release version starts to return random errors. I get errors such as lock violations, memory corruption, invalid resbufs, etc. You can run the exact same test 5 times in a row and get completely different results.

I'm thinking the internal collection of DbDictionaryEntry's are changing while the iteration is taking place?
Message 7 of 15
Anonymous
in reply to: Jan1

Are you disposing of the ResultBuffers after
you're done with them?

ResbufToTypedValue is a beast, and there
can be things in the native resbuf chain
that may be causing problems there.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

wrote in message news:5640242@discussion.autodesk.com...
I know this is old, but I am experiencing the exact same problem.

If you iterate through large numbers of Xrecords, the release version starts to return random errors. I get errors such as lock violations, memory corruption, invalid resbufs, etc. You can run the exact same test 5 times in a row and get completely different results.

I'm thinking the internal collection of DbDictionaryEntry's are changing while the iteration is taking place?
Message 8 of 15
CarloLGW
in reply to: Jan1

The question are very very old but i've the same problem.
I've attached the code.

Sometimes the error is eInvalidresbuf with str1=2 str2 =-1, sometimes error is einvalidresbuf with str1=2b str2=5 and sometimes str1=4 str2=5

N.B.
str2=5 is the correct number of elements that i expect

I'm using Vb.net 2005 and autocad 2007

best regards
Message 9 of 15
Anonymous
in reply to: Jan1

You problem is most likely a result of bad coding habits.

Many places in your code, you are calling 'xrec.Data.AsArray'
on the same XRecord object.

You should call the 'xrec.Data.AsArray' once, and assign the
result to a variable (typed as an array of TypedValue), and
use that variable in your code, rather than repeatedly calling
xrec.Data.AsArray.

If you did that, you would probably find the error (sorry, I do
not have time to debug that code).

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2011

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:6388317@discussion.autodesk.com...
The question are very very old but i've the same problem.
I've attached the code.

Sometimes the error is eInvalidresbuf with str1=2 str2 =-1, sometimes error is
einvalidresbuf with str1=2b str2=5 and sometimes str1=4 str2=5

N.B.
str2=5 is the correct number of elements that i expect

I'm using Vb.net 2005 and autocad 2007

best regards
Message 10 of 15
CarloLGW
in reply to: Jan1

Thanks for your prompt response.
I modified the code according to its specifications but the result has not changed.
I attach the modified code.
NB
The error appears in a sporadic and only dwg containing many objects. (Over 10000).
I hope it can help.

Yours sincerely
Message 11 of 15
Anonymous
in reply to: Jan1

You need to write code to do an audit of the
xrecord data to ensure that all of it was written
out correctly. The bug could be in the code
that writes the xrecord data, and the fact that
it happens in drawings with a large number
of objects could be merely because the odds
that the bug exists in one or more xrecords
increases along with the number of xrecords.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2011

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:6389036@discussion.autodesk.com...
Thanks for your prompt response.
I modified the code according to its specifications but the result has not
changed.
I attach the modified code.
NB
The error appears in a sporadic and only dwg containing many objects. (Over
10000).
I hope it can help.

Yours sincerely
Message 12 of 15
CarloLGW
in reply to: Jan1

Thank you for your prompt response.
I checked the write function of xrecord as you advised me but I find no errors.
What I do not understand is how it is possible that the function wrong at times (2 or 3 in 1000) by running repeatedly 1000 times on the same design and only if it is large.
And especially if done without the help of VisualStudio.

Sincerely
Message 13 of 15
Anonymous
in reply to: Jan1

So you say that it's giving different results with the
same object, when used multiple times?

That could suggest you're having a memory issue.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2011

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:6389057@discussion.autodesk.com...
Thank you for your prompt response.
I checked the write function of xrecord as you advised me but I find no errors.
What I do not understand is how it is possible that the function wrong at times
(2 or 3 in 1000) by running repeatedly 1000 times on the same design and only if
it is large.
And especially if done without the help of VisualStudio.

Sincerely
Message 14 of 15
CarloLGW
in reply to: Jan1

I also have this feeling but I really do not know where I can be the problem. The function is so simple that it seems impossible not to find the solution.
It seems that sometimes find the xrecord but this is empty.
I hope you can help me
Message 15 of 15
Anonymous
in reply to: Jan1

I'm afriad that I can't without being able to reproduce it,
even if I had the time to do that.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2011

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:6390563@discussion.autodesk.com...
I also have this feeling but I really do not know where I can be the problem.
The function is so simple that it seems impossible not to find the solution.
It seems that sometimes find the xrecord but this is empty.
I hope you can help me

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