Posts Tagged ‘ Autodesk ’

Error report after user closes Revit

I got  bug report, where the customer was saying, that Revit is crashing when our addin is installed. After discussion, I got some more information, but still not enough to solve it. It was indeed problem with our addin – Revit didn’t crash, but the user got an error report, when Revit was closing.

After some more investigation, I found out, that this wasn’t happening on development machines, since we got UAC turned off. Once I got UAC to “Always notify”, I got the same problem.

The reason behind this was, that we are creating log file in SpecialFolder.CommonApplicationData directory (C:\ProgramData\ on on Windows 7 ) , which is where Windows does not allow us to write anything. Problem was solved once I moved log file to current user’s application data (SpecialFolder.ApplicationData). I might add, that I am on Windows 7 64bit.

Below are the directories, which are affected by UAC setting (Windows Vista & Windows 7):

SpecialFolder.CommonApplicationData: C:\ProgramData
SpecialFolder.ProgramFiles: C:\Program Files

This one is safe:

SpecialFolder.ApplicationData:        C:\Documents and Settings\myusername\Application Data

If for some reason you wan to keep your file in these directories, you can try with UAC elevation.
And those folders on Windows XP:

SpecialFolder.CommonApplicationData:  C:\Documents and Settings\All Users\Application Data
SpecialFolder.ProgramFiles:           C:\Program Files
SpecialFolder.ApplicationData:        C:\Documents and Settings\myusername\Application Data

Another interesting thing is, that any Revit shared parameter definition file stored in CommonApplicationData isn’t affected by this setting.

Enhanced by Zemanta

Obfuscate Revit addins

EDIT: What is described below, does not work, if you have UAC enabled – you can not copy files in C:\Program Files\ directory or subdirectories – see this post for more information.


All of you that develop Revit addins have or will at one point need some obfuscation tool to protect your intellectual property. Jeremy and Kean have already written about what obfuscation is and how to do it for either Revit or AutoCAD addins.

I would like to add few notes which may be useful for you. Since I was on a tight budget, the only option for me was free obfuscator. I chose Eazfuscator.NET.

When I ran the obfuscation, I got an error saying “Unable to find type…” – see this post for more info. Daren had the similar problem and he solved it with free version of Babel.NET.

The solution was, to copy all the assemblies in Revit directory (e.g. C:\Program Files\Autodesk\Revit Architecture 2011\Program\) obfuscate it there and then move it back to working directory. Here is the BATCH file which does the trick (the file has to be located in your bin directory):

rem copy libraries
set file=Library1.dll
copy /y %file% "C:\Program Files\Autodesk\Revit Architecture 2011\Program\"
set file=Library2.dll
copy /y %file% "C:\Program Files\Autodesk\Revit Architecture 2011\Program\"

rem copy addin
set assembly=Addin.dll
copy /y %assembly% "C:\Program Files\Autodesk\Revit Architecture 2011\Program\"

rem obfuscate
"C:\Program Files (x86)\Eazfuscator.NET\eazfuscator.net.exe" "C:\Program Files\Autodesk\Revit Architecture 2011\Program\%assembly%"
move /y "C:\Program Files\Autodesk\Revit Architecture 2011\Program\%assembly%"

rem cleanup libraries
set file=Library1.dll
del "C:\Program Files\Autodesk\Revit Architecture 2011\Program\%file%"
set file=Library2.dll
del "C:\Program Files\Autodesk\Revit Architecture 2011\Program\%file%"

I haven’t tried it yet, but I guess the method works also for AutoCAD addins.

Enhanced by Zemanta