Ignore the AccessViolationException for a moment and fix your code, because it doesn't make a good sense. Maybe the AccessViolationException will disappear when we fix known problems. There are indeed weird things in your code that may get the system confused.
First of all, your method is now called myPrefixItemClass(), therefore you must update the value in DataMethod.
Then, your display method will always return the same thing, because it has no information about the InventSum record which is should be related to. It takes no input at all.
In your previous version, you referred to the current InventSum record by 'this' variable, which is a good approach. Switching to a static method isn't necessary, but if you want, you can do it - but then you must add a method parameter for the current record and using it instead of 'this'. Then you would also refer to the method by MyPrefixInventSum_Extension.::myPrefixItemClass instead of MyPrefixInventSum_Extension.myPrefixItemClass.
Now you're refering to the method as if it was not static, but it is, and it's not implemented correctly.
Try something like this instead:
display String15 myPrefixItemClass()
{
EcoResProduct product;
InventTable inventTable;
select firstonly MyPrefixItemClass from product
exist join inventTable
where inventTable.Product == product.RecId
&& inventTable.ItemId == this.ItemId;
return enum2Str(product.MyPrefixItemClass);
}
Using a single joined select rather than two separate statements may be an improvement, nevertheless it may be even worse because of less caching. What I meant was using joined data sources in a form rather then display methods.