CADmep 2021 - A procedure imported by 'FabricationAPI.dll' could not be loaded
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I keep getting the error message "System.IO.FileLoadException: A procedure imported by 'FabricationAPI.dll' could not be loaded." when I try to run the add-in that I have written in CADmep 2021.
The add-in runs fine in CADmep 2019 for many years. I am trying to create a version for CADmep 2023. It loads OK in CADmep 2023. But it fails whenever it needs to get access to anything related to Fabrication API. Because I am not making any headway with running my add-in in CADmep 2023, I want to try my luck with CADmep 2021.
Unfortunately the add-in behaves even worse in CADmep 2021. In the IExtensionApplication.Initialize() of my add-in, I ask it to explicitly load the correct version of FabricationAPI.dll -- that is the one in C:\Program Files\Autodesk\Fabrication 2021\CADmep folder. But I immediately get the error "A procedure imported by 'FabricationAPI.dll' could not be loaded" when CADmep is starting up. The following is the IExtensionApplication.Initialize() that tries to explicitly load FabricatonAPI.dll:
void IExtensionApplication.Initialize()
{
try
{
String sFullPathFabApiDllFileForCAD = "C:\\Program Files\\Autodesk\\Fabrication 2021\\CADmep\\FabricationAPI.dll";
// Of course the folder name is changed for 2019/2021/2023.
Assembly oAsm = System.Reflection.Assembly.LoadFrom( sFullPathFabApiDllFileForCAD );
if ( oAsm == null )
{
MessageBox.Show( "Fail to load FabricationAPI.dll",
"MyAddin", MessageBoxButtons.OK, MessageBoxIcon.Exclamation );
}
}
catch( System.Exception ex )
{
Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
ed.WriteMessage( "\n" + ex.Message );
return;
}
finally
{
}
}
And I notice that the commands exposed from my add-in are not available. Use NETLOAD to manually load my add-in seemingly helps because the commands exposed from my add-in start showing up. Unfortunately I encounter the same error when I try to run any command exposed from my add-in. Seem like FabricationAPI.dll is not loaded.
I also try commenting out the code that tries to explicitly load FabricationAPI.dll, and let CADmep to implicitly load FabricationAPI.dll. This avoids the error during starting up of CADmep. And I also notice that the commands exposed from my add-in start showing up. But I encounter the exact same error when I try to run any command exposed from my add-in.
I have tried Dependency-Walker to examine 2021 FabricationAPI.dll, and I see a long list of errors. But I also see the same long list of errors when I examine 2019 FabricationAPI.dll (and my add-in works fine in 2019 Fabrication API). Therefore, I don't know if those errors are relevant or not.
I have checked using Resource Monitor and found that FabricationAPI.dll indeed was not loaded with CADmep 2021. Only FabricationCore.dll (2021 version) is loaded.
Would you please let me know what else that I should try? Thanks.
JC_BL