xBimTeam / XbimGeometry

XbimGeometry contains the CLR interop libraries and the c++ engine used to compute the 3D geometry of models.
https://xbimteam.github.io/
Other
260 stars 132 forks source link

Could not load file or assembly 'Xbim.Geometry.Engine32' or one of its dependencies. #263

Closed korab8 closed 4 years ago

korab8 commented 4 years ago

Short summary describing the issue. (3-5 sentences) I get this error when building XbimWebUI project. I added my own files that convert IFC to Wexbim and this won't go away. The web app is configured to run on 64bit, but the same error is with the default/any cpu. When I manually delete the file the project runs fine, but after running it copies the same file again.

Assemblies and versions affected:

Xbim.Geometry 5.1.317 Xbim.Geometry.Engine.Interop 5.1.317

Steps (or code) to reproduce the issue:

A simple set of steps to reproduce the issue. Provide a small sample file is required and/or a small sample of the failing code (or reference a commit / gist)

protected void ConvertIFC(String fileName)
        {
            using (var model = IfcStore.Open(fileName))
            {
                var context = new Xbim3DModelContext(model);
                context.CreateContext();

                var wexBimFilename = System.IO.Path.ChangeExtension(fileName, "wexbim");
                using (var wexBiMfile = File.Create(wexBimFilename))
                {
                    using (var wexBimBinaryWriter = new BinaryWriter(wexBiMfile))
                    {
                        model.SaveAsWexBim(wexBimBinaryWriter);
                        wexBimBinaryWriter.Close();
                    }
                    var splitString = wexBiMfile.Name.Replace("\\", "/").Split('/');
                    ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", string.Format("loadIfc('{0}');", splitString[splitString.Length - 1]), true);
                    wexBiMfile.Close();
                }
            }
        }

Expected behavior:

I want to prevent the project from copying the Xbim.Geometry.Engine32.dll on startup, that causes the error.

Additional Details

I tried all the related issues opened. None of them work. If it is needed I can create a github repository with the code, but it's just the XbimWebUI Code: https://github.com/xBimTeam/XbimWebUI with one WebForm that pretty much has that function.

andyward commented 4 years ago

Make sure the platform solution is set to one of x86 or x64. If you build for AnyCPU it will copy both 32 & 64 bit versions of the native dll - which won't work under ASP.NET. If your we app is running x64 then build for the x64 platform.

For how this works, see: https://github.com/xBimTeam/XbimGeometry/blob/master/Xbim.Geometry.Engine.Interop.targets#L18

I've just tested with the same xbim dependencies in a test project at https://github.com/andyward/XbimWebDemo to prove it works - feel free to try that out.

korab8 commented 4 years ago

Hello andy,

I tried to build the demo but it shows me a Parsing error in runtime. Parser Error Message: Could not load type 'MvcApplication'. Source File: /global.asax Line: 1 Line 1: <%@ Application Codebehind="Global.asax.cs" Inherits="XbimDemoWebApp.MvcApplication" Language="C#" %>

CBenghi commented 4 years ago

This does not seem an xbim issue, try googling the solution, most people seem to suggest that it goes away doing the right sequence of re-build actions on the solution projects.

andyward commented 4 years ago

At a guess you're missing the ASP.NET MVC dependencies. I'm going to close this issue here as I think I've shown it's not an xbim team issue. If you can't get my demo loading, please raise a issue in that repo (after you've checked you've got MVC installed in the VS Installer)