Ejemplo n.º 1
0
            /// <summary>
            /// Try finding the right path for the p/invoked DLLs before p/invoke tries to.
            /// <param name="loadJointClientKitDlls">True, if you wish to load joint client kit DLLs as well.</param>
            /// </summary>
            static public void PreloadNativeLibraries(bool loadJointClientKitDlls)
            {
#if !MANAGED_OSVR_INTERNAL_PINVOKE
                // This line based on http://stackoverflow.com/a/864497/265522
                var assembly     = System.Uri.UnescapeDataString((new System.Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase)).AbsolutePath);
                var assemblyPath = Path.GetDirectoryName(assembly);
                System.Diagnostics.Debug.WriteLine("[OSVR] ClientKit assembly directory: " + assemblyPath);
                LibraryPathAttempter attempt;
                if (IntPtr.Size == 8)
                {
                    attempt = new LibraryPathAttempter(assemblyPath, loadJointClientKitDlls).Attempt("x86_64").Attempt("x64").Attempt("64");
                }
                else
                {
                    attempt = new LibraryPathAttempter(assemblyPath, loadJointClientKitDlls).Attempt("x86").Attempt("32");
                }
                if (attempt.Success)
                {
                    if (attempt.Dir.Length > 0)
                    {
                        System.Diagnostics.Debug.WriteLine("[OSVR] Loaded ClientKit native libraries from directory: " + attempt.Dir);
                    }
                    else
                    {
                        System.Diagnostics.Debug.WriteLine("[OSVR] Loaded ClientKit native libraries from default search path.");
                    }
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine("[OSVR] Could not preload ClientKit native libraries");
                }
#endif
            }
Ejemplo n.º 2
0
            /// <summary>
            /// Try finding the right path for the p/invoked DLLs before p/invoke tries to.
            /// </summary>
            public static void PreloadNativeLibraries()
            {
                #if !MANAGED_OSVR_INTERNAL_PINVOKE

                // This line based on http://stackoverflow.com/a/864497/265522
                var assembly = System.Uri.UnescapeDataString((new System.Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase)).AbsolutePath);
                var assemblyPath = Path.GetDirectoryName(assembly);
                System.Diagnostics.Debug.WriteLine("[OSVR] ClientKit assembly directory: " + assemblyPath);
                LibraryPathAttempter attempt;
                if (IntPtr.Size == 8)
                {
                    attempt = new LibraryPathAttempter(assemblyPath).Attempt("x86_64").Attempt("x64").Attempt("64");
                }
                else
                {
                    attempt = new LibraryPathAttempter(assemblyPath).Attempt("x86").Attempt("32");
                }
                if (attempt.Success)
                {
                    if (attempt.Dir.Length > 0)
                    {
                        System.Diagnostics.Debug.WriteLine("[OSVR] Loaded ClientKit native libraries from directory: " + attempt.Dir);
                    }
                    else
                    {
                        System.Diagnostics.Debug.WriteLine("[OSVR] Loaded ClientKit native libraries from default search path.");
                    }
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine("[OSVR] Could not preload ClientKit native libraries");
                }
                #endif
            }