部署时遇到的锐鼻问题

时间:2016-08-04 22:08:48

标签: c# deployment sharpshell

我在客户端计算机上部署sharpshell时遇到了一些问题,如果有人可以帮助我,我真的很感激。配置如下

  1. Sharpshell 2.2.0
  2. 64Bit OS
  3. Framework 4.5.1
  4. Vc ++ 2010 redistributable
  5. 部署包基于x86架构构建
  6. 一旦我查看错误日志发现错误“无法初始化Nativebridge”正在发生这是一个非常棒的库工作,就像Dev环境中的魅力一样。

    Machine Config Error Log

1 个答案:

答案 0 :(得分:0)

最后..我找到了解决我面临的问题的工作:)。

  1. 首先采用GET的主分支格式,将Nativebridge项目改为x64 Compactable。 thanks to the ref

  2. 在SharpShell \ NativeBridge \ NativeBridge.cs文件下进行了一些微小的更改,函数Initialise(),即nativeBridge库试图加载的行。在我编辑期间,函数如下所示我写这篇文章。

            public bool Initialise()
    {
        //  Get the manifest resource name.
        var resouceName = GetBridgeManifestResourceName();
    
        //  We'll now try and get the bridge library path.
        string bridgeLibraryPath = string.Empty;
    
        try
        {
           int index = resouceName.LastIndexOf('.') > 0 ? resouceName.LastIndexOf('.', resouceName.LastIndexOf('.') - 1) : -1;
           string resouceNameTrimed = resouceName.Substring(index+1,resouceName.Length - (index+1));
           string ResourcePath = String.Format(@"{0}\{1}", System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),resouceNameTrimed);
    
           using (var resourceStream = File.OpenRead(ResourcePath))
            {
                //  Set the temporary path..
                bridgeLibraryPath = Path.GetTempPath() + Guid.NewGuid().ToString() + ".dll";
                using (var tempStream = File.Create(bridgeLibraryPath))
                {
                    resourceStream.CopyTo(tempStream);
                }
            }
        }
        catch (Exception exception)
        {
            //  Log the exception.
            Logging.Error("NativeBridge: Failed to extract the bridge library. The manifest path is '" +
                          bridgeLibraryPath + "'", exception);
            return false;
        }
    
        //  Load the bridge library.
        try
        {
            libraryHandle = Kernel32.LoadLibrary(bridgeLibraryPath);
    
        }
        catch (Exception exception)
        {
            //  Log the exception.
            Logging.Error("NativeBridge: Exception loading the bridge library.", exception);
        }
    
        //  If the library hasn't been loaded, log the last windows error.
        if (libraryHandle == IntPtr.Zero)
        {
            Logging.Error("NativeBridge: Failure to load the brige library.",
                          new Win32Exception(Marshal.GetLastWin32Error()));
            return false;
        }
    
        Logging.Log("Bridge Initialised");
    
        //  We've successfully loaded the bridge library.
        return true;
    }
    
    1. 将sharpshell,servermanager项目等制作成x64 compactable,只需将目标框架工作更改为x64并重建。

    2. 将sharpshell dll引用替换为我的项目中的上述内容。

    3. 添加了文件" SharpShellNativeBridge32.dll"和#34; SharpShellNativeBridge64.dll"到我项目的工作文件夹。
  3. 是的,这足以让我的案子像魅力一样工作