When I try to set reference point using "DWGImportOptions.SetRefPoint" in Revit 2012, it throws InternalException at SetRefPoint saying that: "Attempt to read or write Protected Memory. This is often an indicating that other memory is corrupt.". Below is the minimal test case:
public class CreateFamilyFile : IExternalCommand
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
DWGImportOptions dwgImportOptions = new DWGImportOptions();
dwgImportOptions.SetRefPoint(new XYZ(0.0, 0.0, 0.0));
Same test case is performed in Revit 2013 and it worked just fine. So I wonder whether is a bug in SDK or anything? Any helps would be much appreciated.
may it be that you have interchanged the referenced RevitAPI.dlls ?
Since you code both for 2012 and 2013, it may be that you have referenced the false one.
Running in 2013 but not in 2012 sounds like you try to use a 2013 addin with a 2012 Revit.
This error occured when I'm using RevitAPI.dll 2012 and run the add-in in Revit 2012. The weird part is it works fine for Revit 2013 add-in. Any ideas?
I know this issue has remained unresolved for some time but I am responding to it because I see a similar question logged with Autodesk Developer Networks separately and here is my response to that:
I did a little bit of research to see if this is a known issue but unfortunately, I do not see a lot of information about this issue.
It looks like you or one of your colleagues posted it a couple of years ago.
Without a reproducible sample, the only thing I can say is that the memory is already corrupt in the running instance of Revit by the time "dwgImportOptions.SetRefPoint" is run so either other portions of your application or some other application is not using memory properly.
Probably the first and easiest thing to do is to update to the latest service pack and see if it resolves the issue: http://usa.autodesk.com/adsk/servlet/ps/dl/index?s
If this does not help, please provide us with a minimal, buildable, non-confidential sample to reproduce the problem.
Sorry for not being more helpful.