Message 1 of 4
Unable to import functions from a C compiled file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi !
We are trying to import function from a compiled file written in C. It has been compiled long time ago in x64 and we don't have access to the source code. We are trying from a c# code to import function from this compiled file like so
[DllImport("ScanToBIMLib.dll", SetLastError = true)]
private static extern IntPtr createBlock(float voxelSize, bool useGPU);
All files are compiled in x64 architecture however, when we start Revit 2024 we always get the error Unable to load ScanToBIMLib.dll: module not found. We use this piece of code to get add the .dll file
public class Load
{
public static void LoadLib(string baseDirectory)
{
AppDomain.CurrentDomain.AssemblyResolve += (sender, args) =>
{
string assemblyPath = Path.Combine(baseDirectory, "ScanToBIMLib.dll");
Assembly asm = Assembly.LoadFrom(assemblyPath);
return null;
};
}
}
It works fine for other dll but not this one. Since ScanToBIMLib.dll is a C compiled dll we can't add it directly as a reference to the c# dll. We also tried adding it as embedded resource but still no result 😕
Would any of you already encountered that issue ?
Regards,
Benjamin