C# 部署时面临的Sharpshell问题
我在客户端机器上部署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
最后。。我找到了解决我所面临问题的方法:)
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;
}