I am developing a console program.
If open a different version file, it will throw "Autodesk.Revit.Exceptions.InvalidOperationException:“The document can not be opened".
How to open different version Revit files
You should be able to open an earlier version but you will not be able to open a later version.
If your console app was based on Revit 2020, it should be able to open a Revit 2019, however it will not be able to open a Revit 2021.
I am sure that Revit 2018 can open an RVT file stored by Revit 2015. The problem must lie elsewhere.
By the way, The Building Coder recently shared a solution to automatically open correct RVT file version:
https://thebuildingcoder.typepad.com/blog/2020/05/automatically-open-correct-rvt-file-version.html
It avoids updating the RVT file versions, assuming that you have all the required versions of Revit.exe installed.
Sorry, there is something wrong with my description.
It's not open a file in Revit.
My console app want open the file to get "document".
Using the "OpenDocumentFile" will be failed.
At present, using "RevitAPI.dll"(2018) and "RevitNET.dll"(2018), "Application.OpenDocumentFile(rvtPath)" can open Revit 2018 file to get the "document". But can't open Revit 2015 file.
So you are loading those two DLLs from your own console application and not starting Revit.exe at all?
Well, that is very interesting information. Thank you for sharing it.
However, as said, that constellation is completely unsupported.