Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to load IFC file: failed to load Xbim.Geometry.Engine64.dll #479

Open
andremansour opened this issue May 27, 2024 · 8 comments
Open
Labels
needs repro Needs reproduction steps - can't reproduce

Comments

@andremansour
Copy link

andremansour commented May 27, 2024

I am trying to create a revit plugin using xbim. I want to load an ifc file to a model viewer using WPF and xbim
however I am getting the following error:

Failed to load IFC file: failed to load Xbim.Geometry.Engine64.dll

here are the versions of the packages I am using:

Xbim.Common version=6.0.445
Xbim.Geometry version=5.1.437
Xbim.Geometry.Engine.Interop version=5.1.437
Xbim.Ifc version=6.0.445
Xbim.Ifc2x3 version=6.0.445
Xbim.Ifc4 version=6.0.445
Xbim.IO.MemoryModel version=6.0.445
Xbim.ModelGeometry.Scene version=5.1.437
Xbim.Tessellator version=6.0.445
Xbim.WindowsUI version=5.1.228

I have tried to add the Xbim.Geometry.Engine64.dll to the project but it still doesn't work.

here is my code for loading the ifc file:

xaml


<Window x:Class="BoundingBoxXYZExtraction.BoundingBoxForm"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
        xmlns:presentation="http://schemas.Xbim.com/Presentation"
        mc:Ignorable="d"
        x:Name="MainWindow"
        DataContext="{Binding RelativeSource={RelativeSource Self}}"
        Title="" Height="1080" Width="1920"
        Background="#FF2D2D30" TextElement.Foreground="#FFFFFF">

        <!-- Main Content Area for IFC Model Viewer -->
        <DockPanel Grid.Column="1" Grid.Row="2" Margin="0,0,0,0">
            <presentation:DrawingControl3D x:Name="DrawingControl" 
                               x:FieldModifier="public" 
                               Model="{Binding ModelProvider.ObjectInstance}" 
                               Focusable="True"
                               ModelOpacity="1"/>
        </DockPanel>


    </Grid>
</Window>

xaml.cs

using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using Octokit;
using LibGit2Sharp;
using System.Windows.Media.Imaging;
using System.Text.RegularExpressions;
using Xbim.Common;
using Xbim.Ifc;
using Xbim.Ifc4.Interfaces;
using Xbim.ModelGeometry.Scene;
using Microsoft.Extensions.Logging;
using Xbim.Presentation;
using GitHubRepo = Octokit.Repository;
using GitCredentials = Octokit.Credentials;
using GitHubBranch = Octokit.Branch;
using Newtonsoft.Json.Linq;
using Xbim.IO;
using System.Windows.Data;

namespace BoundingBoxXYZExtraction
{
    public partial class BoundingBoxForm : Window
    {

        private UIDocument _uiDoc;
        private ModelViewModel viewModel = new ModelViewModel();
        private const string SettingsFilePath = "appsettings.json";

        public event EventHandler<ProjectCreatedEventArgs> ProjectCreated;

        public BoundingBoxForm(ExternalCommandData commandData)
        {
            InitializeComponent();
            _uiDoc = commandData.Application.ActiveUIDocument;
            this.DataContext = viewModel;

        }


        private ObjectDataProvider ModelProvider
        {
            get
            {
                return MainFrame.DataContext as ObjectDataProvider;
            }
        }

        private void LoadIfcFile(string ifcFilePath)
        {
            try
            {
                if (!File.Exists(ifcFilePath))
                {
                    MessageBox.Show($"IFC file not found at {ifcFilePath}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                using (var model = IfcStore.Open(ifcFilePath))
                {
                    var context = new Xbim3DModelContext(model); // Updated constructor call 
                    context.CreateContext();

                    ModelProvider.ObjectInstance = context;  // Set to the context
                    ModelProvider.Refresh();
                }

                MessageBox.Show("IFC file loaded successfully.", "Success", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Failed to load IFC file: {ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
    }
}
@martin1cerny
Copy link
Member

What is the exact error message?

@andremansour
Copy link
Author

The exact message is "Failed to load IFC file: failed to load Xbim.Geometry.Engine64.dll"

@andyward
Copy link
Member

andyward commented Jun 6, 2024

Which version of Revit is this? Or is it multiple?

I'm assuming you've ruled out the usual deployment issues that can cause this issue: #312 (comment)

In Revit is sometimes due to a clash of dependencies with other addins loaded into revit. E.g. your addin and another each use Microsoft.Extensions.Logging but with different versions and you can get assembly binding issues that cause the xbim dlls to fail to load. Try unloading other addins to test.

A useful tool to see what is going on is Microsoft's fuslogvw

@andremansour
Copy link
Author

andremansour commented Jun 10, 2024

Sorry for the late response. I am using Revit 2024. Also, I have made sure that all my .dll files are up to par with the ones that Revit is using. Currently I am using addin manager and then loading up my addin using it. I tried using fuslogvw however nothing is coming up.

@andremansour
Copy link
Author

Which version of Revit is this? Or is it multiple?

I'm assuming you've ruled out the usual deployment issues that can cause this issue: #312 (comment)

In Revit is sometimes due to a clash of dependencies with other addins loaded into revit. E.g. your addin and another each use Microsoft.Extensions.Logging but with different versions and you can get assembly binding issues that cause the xbim dlls to fail to load. Try unloading other addins to test.

A useful tool to see what is going on is Microsoft's fuslogvw

please check this error report.
XbimError

@andyward
Copy link
Member

Are you sure you enabled fuslogvw? You need to turn it on to log failed assembly bindings.

You can't tell anything from that stack trace. Fuslogvw will tell you what assembly actually failed to bind. In all likelihood it is the ILogger though.

@Rachvel
Copy link

Rachvel commented Aug 27, 2024

The exact message is "Failed to load IFC file: failed to load Xbim.Geometry.Engine64.dll"

You may try also #312. This ensures to copy correct .dll in output folder after build. But your problem can be different.

I have tried to add the Xbim.Geometry.Engine64.dll to the project but it still doesn't work.

Make you sure that for this file you use property:
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
Or instead of PreserveNewest use Always.

@andyward
Copy link
Member

@andremansour Did you get this resolved?

@andyward andyward added the needs repro Needs reproduction steps - can't reproduce label Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs repro Needs reproduction steps - can't reproduce
Projects
None yet
Development

No branches or pull requests

4 participants