3 Replies Latest reply on May 21, 2014 7:24 PM by John Kangas

    x64 Solidworks add-in with x86 reference dependencies

    John Kangas

      I have a C# task pane add-in, which is working as it should, except that when it invokes a dependency on an x86 dll I'm getting the following error:

       

      Could not load file or assembly '<reference library>' or one of its dependencies. The system cannot find the file specified.

       

      This function doesn't interact with Solidworks in any way at this point, other than being a hosted task pane add-in. I'm interacting with another software's SDK, and the references from that SDK which I'm using are x86. I've written custom dll shells to help my other applications handle this transition, and haven't run into this error outside of Solidworks since then. I've also encapsulated this add-in project so that I could host it in a generic application shell which is compiled for "any CPU", and everything works there. I only get this error when my add-in is hosted in Solidworks. I've also monitored activity related to the library in question in process monitor, and all of the references load successfully whether it's run inside or outside of Solidworks, which leads me to assume that it's a framework mismatch error.

       

      Am I overlooking something? Is there a way that Solidworks can work with x86 references? I clearly can't recompile this other SDK's dll's; we have to work with them as they are.

        • Re: x64 Solidworks add-in with x86 reference dependencies
          Simon Turner

          There is no way around this. Your addin is a 64 bit process and cannot access 32 bit dlls.

          Either the dll will have to be recompiled for "Any CPU", or you will have to create a 32 bit executable which gets the information from the x86 dll and then passes it back to the addin (via a file).

          If you had written custom dlls for other 64 bit applications (such as Office x64) then you would have had the same problem.

            • Re: x64 Solidworks add-in with x86 reference dependencies
              John Kangas

              It's not possible with direct references, no. And these are third party libraries, so I'm stuck with them as they are. I took a swing at importing the functions with a few interop methods. These old dll's don't play nicely with my interop skills as they are, although I'm honestly not an interop expert.

               

              Maybe later I'll set up an intermediate service to run them, but yeah, for now we're going to get by with console applications. Thanks for the response, Simon!