Hi,
I use to call the revit api from external application and was working around 2 years before but if I use the same call its failing .
Exception is .....
System.BadImageFormatException was unhandled
FileName=RevitAPIUI.dll
FusionLog=""
HResult=-2147023898
Message=Could not load file or assembly 'RevitAPIUI.dll' or one of its dependencies. Invalid access to memory location. (Exception from HRESULT: 0x800703E6)
Source=COMPAS_BIM
StackTrace:
at COMPAS_BIM.Drawing3D.Genearate3DDrawings()
at COMPAS_BIM_Client.Program.Main(String[] args) in D:\Revit\COMPAS_BIM_Client\Program.cs:line 15
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
Solved! Go to Solution.
Solved by jeremytammik. Go to Solution.
Dear Krisnx,
Thank you for your query.
Calling directly into the Revit API from an external context is, was and always has been illegal.
If you were doing so successfully in the past, you were putting yourself and all your users at severe risk of file corruption and data loss.
The Revit API cannot ever be used except within a valid Revit API context.
Such a context is provided exclusively by Revit call-back methods.
You need to subscribe to a Revit event, such as an external command Execute method.
Within the event handler, the Revit API can be used.
You can also use the Revit API to set up an external event that can be raised from a non-Revit-API context, such as your standalone external application.
This is demonstrated by the ModelessDialog/ModelessForm_ExternalEvent SDK sample.
A large number of examples and further explanations are provided in The Building Code topic group on Idling and External Events for Modeless Access and Driving Revit from Outside:
http://thebuildingcoder.typepad.com/blog/about-the-author.html#5.28
I hope this helps.
Best regards,
Jeremy
Don't miss the update on this topic here:
http://thebuildingcoder.typepad.com/blog/2017/05/e
Cheers,
Jeremy
Can't find what you're looking for? Ask the community or share your knowledge.