Ejemplo n.º 1
0
        static public void Initialize(string hoops_license, string bin_folder)
        {
            if (!Library.Load(bin_folder))
            {
                var sb = new StringBuilder();
                sb.AppendLine("Unable to load Exchange.");
                if (null == bin_folder)
                {
                    sb.AppendLine("Because a folder was not specified, the platform-specific library");
                    sb.AppendLine("search method was used. For this to work, you must ensure the");
                    sb.AppendLine("Exchange library " + Library.GetLibraryName() + " can be found.");
                }
                else
                {
                    sb.AppendLine(Path.Combine(bin_folder, Library.GetLibraryName()));
                    sb.AppendLine("Please check the path you specified.");
                }
                throw new InitializationException(sb.ToString());
            }

            if (A3DStatus.A3D_SUCCESS != API.A3DLicPutUnifiedLicense(hoops_license))
            {
                throw new InitializationException("Unable to unlock HOOPS Exchange.");
            }

            int major_version, minor_version;

            if (A3DStatus.A3D_SUCCESS != API.A3DDllGetVersion(out major_version, out minor_version))
            {
                throw new InitializationException("Unable to retrieve DLL version information.");
            }

            if (major_version != Constants.A3D_DLL_MAJORVERSION || minor_version != Constants.A3D_DLL_MINORVERSION)
            {
                var sb = new StringBuilder();
                sb.AppendLine("The DLL version does not match the C# version.");
                sb.AppendLine(
                    "DLL: (" + major_version + ", " + minor_version + ")"
                    + " != " +
                    "C# (" + Constants.A3D_DLL_MAJORVERSION + ", " + Constants.A3D_DLL_MINORVERSION + ")");
                throw new InitializationException(sb.ToString());
            }

            var init_result = API.A3DDllInitialize(major_version, minor_version);

            if (A3DStatus.A3D_SUCCESS != init_result)
            {
                throw new InitializationException("Failed to initialize the Exchange DLL: " + Marshal.PtrToStringAnsi(API.A3DMiscGetErrorMsg(init_result)));
            }
        }