Fatal error. System.AccessViolationException: Attempted to read or write protected memory reading Category Display Name

Fatal error. System.AccessViolationException: Attempted to read or write protected memory reading Category Display Name

barasalah
Participant Participant
928 Views
2 Replies
Message 1 of 3

Fatal error. System.AccessViolationException: Attempted to read or write protected memory reading Category Display Name

barasalah
Participant
Participant

I am getting this error while trying to get Display Name of category on some objects in a file.

Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Repeat 2 times:
--------------------------------
   at <Module>.LcOpPropertyNode.GetAttribClassUserNameFast(LcOpPropertyNode*, Int32, LcUWideStringBuffer*)
--------------------------------
   at Autodesk.Navisworks.Api.PropertyCategoryCollection.GetAttribClassUserName(Int32, System.String ByRef)
   at Autodesk.Navisworks.Api.PropertyCategory.get_DisplayName()
   at CleanDups.navisInjectService.deletecheck(Autodesk.Navisworks.Api.PropertyCategory, Autodesk.Navisworks.Api.ModelItem, System.String)
   at CleanDups.navisInjectService.injectAttributes()
   at CleanDups.Program.Main(System.String[])

 the full program stop working when it hit that error and i can't catch it to skip or do anything when it happen.

my Code part

foreach (PropertyCategory oPC in modelItem.PropertyCategories)
{
    CatName = oPC.DisplayName;
}

is there another way to get the display name using Managed code or COMAPI?

0 Likes
Accepted solutions (1)
929 Views
2 Replies
Replies (2)
Message 2 of 3

naveen.kumar.t
Autodesk Support
Autodesk Support

Hi @barasalah ,

 

The information you provided is minimal.

 

One suggestion is to explore the properties of the elements using the NavisLookup tool.

https://github.com/chuongmep/NavisLookup 

 

If nothing helps, Please do your best to isolate the problem and send a small, non-confidential, buildable sample project with a test drawing that demonstrates the behavior. Additionally, provide detailed instructions on how to reproduce the behavior.

 

Note:
1. Do not send us any information that you consider to be a trade secret of your company.
2. Code snippets will not help us as they don't allow us to reproduce the context in which the code runs.


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 3

barasalah
Participant
Participant
Accepted solution

Thank you for the reply
it happens when i have weird data like this only

barasalah_1-1703102379386.png

this is tekla ifc file

i can't share the file sorry.

using combined name instead of display name solved the issue

CatName = oPC.CombinedName.ToString();

 

0 Likes