Hello Sandy,
as @Daril sugested in other your post (Can't Set Attribute Domain in LER Model via JS script), the corect way how to assign DataType (or Domain) to another attribute is via
NewAttribute.ChangeDataType(DTorDomain);
I've tried this approach and it should fix also this issue with access violation.
I hope this will help,
Michal