C# 部署时面临的Sharpshell问题

C# 部署时面临的Sharpshell问题,c#,deployment,sharpshell,C#,Deployment,Sharpshell,我在客户端机器上部署sharpshell时遇到了一些问题,非常感谢有人能帮我解决。配置如下所示 夏普壳牌2.2.0 64位操作系统 框架4.5.1 Vc++2010可再发行 部署包是基于x86体系结构构建的 一旦我查看了错误日志,发现一个错误“初始化Nativebridge失败”正在发生,这是一个很棒的库工作,就像Dev环境中的charm一样 最后。。我找到了解决我所面临问题的方法:) 首先,采用主分支形式GET,将Nativebridge项目改为x64可压缩 在文件SharpShell\Na

我在客户端机器上部署sharpshell时遇到了一些问题,非常感谢有人能帮我解决。配置如下所示

  • 夏普壳牌2.2.0
  • 64位操作系统
  • 框架4.5.1
  • Vc++2010可再发行
  • 部署包是基于x86体系结构构建的
  • 一旦我查看了错误日志,发现一个错误“初始化Nativebridge失败”正在发生,这是一个很棒的库工作,就像Dev环境中的charm一样


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

  • 首先,采用主分支形式GET,将Nativebridge项目改为x64可压缩

  • 在文件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;
    }
    
  • 将sharpshell、servermanager等项目压缩为x64,将目标框架更改为x64并重新构建

  • 在我的项目中将sharpshell dll引用替换为上述内容

  • 将文件“SharpShellNativeBridge32.dll”和“SharpShellNativeBridge64.dll”添加到我的项目的工作文件夹中
  • 是的,这对我以后的案子来说已经足够了