【问题标题】:Sharpshell issue facing on deployment部署时面临的 Sharpshell 问题
【发布时间】:2016-08-04 22:08:47
【问题描述】:

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

  1. Sharpshell 2.2.0
  2. 64位操作系统
  3. 框架 4.5.1
  4. Vc++ 2010 可再发行版
  5. 部署包基于 x86 架构构建

一旦我查看了错误日志,就会发现“无法初始化 Nativebridge”的错误正在发生,这是一个很棒的库工作,就像 Dev Environment 中的魅力一样。

Machine Config Error Log

【问题讨论】:

    标签: c# deployment sharpshell


    【解决方案1】:

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

    1. 首先采用 GET 形式的 master 分支,并将 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,只是将目标框架更改为x64 并重新构建。

      2. 在我的项目中用上面的替换sharpshell dll 引用。

      3. 将文件“SharpShellNativeBridge32.dll”和“SharpShellNativeBridge64.dll”添加到我项目的工作文件夹中。

    是的,这对我之后的案例工作来说已经足够了

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-05-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-14
      • 2013-10-05
      相关资源
      最近更新 更多