In the past ten days, I migrated The Building Coder samples, ADN training labs, MEP and Structural sample material from Revit 2013 to 2014.
In all of these migrations, I lamented the processor architecture mismatch warning MSB3270 saying There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "RevitAPI, Version=2014.0.0.0, Culture=neutral, processorArchitecture=x86", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.
This behaviour is in new in .NET 4.5 and meant to be "helpful", according to Microsoft. Unfortunately, it is not all that helpful for us Revit add-in developers.
Of course, there is some level of "danger" if you reference an architecture-specific DLL with an "AnyCPU" one. But that's exactly what Revit provides in offering a .NET API to its native codebase.
Here are a couple of possibilities how the owner of an add-in project can deal with this warning:
Here is Andrew Potts' take on the issue.
For The Building Coder samples, I am aiming for option 2, setting the following property in the project file to turn the warning off:
<PropertyGroup> <ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch> None </ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch> </PropertyGroup>
I did not see any hint on how to add this to the project file through the Visual Studio IDE, so I simply edited BuildingCoder.csproj as a text file using Notepad and added the lines above as a new property group just above all existing ones.
It works fine, the offending warning is no longer shown, and I am down to just the two expected warnings about use of the obsolete TitleBlocks property and FindReferencesWithContextByDirection method.
Here is the updated version 2014.0.100.4 of The Building Coder samples, in case you would like examine the resulting project file yourself directly.
My fellow ADN DevTech engineer Augusto Goncalves just published a nice sample showing how to capture the Escape key, or any other keyboard interaction, for that matter, by setting a Windows hook using the Win32 SetWindowsHookEx API method in the add-in OnStartup and OnShutdown calls.
It is actually a follow-up of a previous post by Xiaodong Liang for handling the Tab, Enter and Escape keys in a modeless form displayed by an Inventor add-in.
This kind of interaction can be useful e.g. to control or interrupt a long Revit process, either using input from a modeless form or just a keyboard hit with no form at all being displayed.
Thank you Augusto for this useful hint!