Based on your code I'm not sure what you are trying to do. I don't think you shouldn't/can't initialize proxies that way.
There are several alternatives to dynamically delete objects. For example this one that we use. It removes objects based on a OQL query (which you can build dynamically).
IDataTable table = Core.retrieveOQLDataTable(this.getContext(), this.oql);
List<IDataRow> rows = (List<IDataRow>) table.getRows();
ArrayList<IMendixIdentifier> ids = new ArrayList<IMendixIdentifier>();
for(IDataRow row : rows){
ids.add((IMendixIdentifier) row.getValue(this.getContext(), 0));
}
Core.remove(this.getContext(), ids);
return Long.valueOf(rows.size());
You question is vague, you want to delete a 'certain' object, but only specify the type of that object, using model reflection, so I guess you want to delete all objects of 'a certain type'?
Note that your class tries to just delete a new object that you just created, which is a bit pointless.
To delete all items of a certain type, use community commons:
XPath.create(getContext(), "MyModule.EntityName").deleteAll()