关于 DotNetBar for Windows Forms 11.8.0.8_冰河之刃重打包版
基于 官方原版的安装包 + http://www.cnblogs.com/tracky 提供的补丁DLL制作而成。 安装之后,直接就可以用了。 省心省事。不必再单独的打一次补丁包了。
本安装包和补丁包一样都删除了官方自带的示例程序【我的文档 中 已经编译好的exe文件】。因为示例程序引用的是官方原版的DLL。处理过的DLL和原版DLL的强签名不同,如果再打开示例程序就会报找不到对应强签名的官方原版DLL的错。索性删除,省的大家再手动删除!可用示例代码再次编译生成示例程序。 所以开始菜单中官方的 示例程序查看 链接方式打不开。这是正常的。因为没有示例程序了。【感兴趣的可以分析一下安装目录下面的RunDotNetBarSampleExplorer.exe文件,就会想明白了。】本安装包和补丁包都依然保留了这一个链接。 在此说明和强调这一点!避免某些 小白用户 说处理过的DLL或者是本安装包有问题。
做事要低调!切勿随意传播,导致不必要的麻烦! 因使用本安装包所导致的一切后果由使用者自身承担,补丁DLL作者和安装包作者皆不承担任何责任!!!
本安装包仅供学习使用,请在下载后24小时之内删除。
安装包里面的补丁DLL版权归tracky所有。
本安装包版权归本人所有。
作者:冰河之刃 博客:http://www.cnblogs.com/binghe021 2014年7月25日 13:06:07 于上海
-----------------------------华丽的分隔线-----------------------------------------------------------------------------------------
发现tracky的博客上面并没有发布出来DotNetBar for Windows Forms 11.8.0.8版本【他说当时好像博客园有故障发布不了】,今天下午灵感一现。
不如索性将处理过的补丁DLL直接打包到官方原版的安装包里面,一次性安装后就能直接使用那多方便呀。于是乎就有了这个安装包。
俺上次做了一个11.8.0.4版本的补丁DLL,不过没有删除注册表里面的残余信息,所以安装后工具箱有一点问题。多谢tracky的提示,在此表示感谢。
DotNetBar for Windows Forms 11.8.0.8_冰河之刃重打包版 下载地址:
链接: http://pan.baidu.com/s/1dD5Xu2t 密码: n5bh
-----------------------------华丽的分隔线-----------------------------------------------------------------------------------------
做11.8.0.4版本的补丁DLL的时候产生了一个小工具。顺带发一下。
小工具功能:读取同名但后缀名不同的配置文件 把指定的DLL从GAC中移除或添加到GAC中。灵活方便,更新软件或做补丁包时可以用上。
配置文件类
/// <summary>
/// 配置文件类
/// </summary>
[Serializable]
public class ConfigModel
{
public ConfigModel()
{
} /// <summary>
/// 配置文件的名字
/// </summary>
private string _configFileName; /// <summary>
/// 要删除的dll集合
/// </summary>
private List<DllModel> _listDllModelsDel; /// <summary>
/// 要添加的dll集合
/// </summary>
private List<DllModel> _listDllModelsAdd; /// <summary>
/// 要删除的dll集合
/// </summary>
public List<DllModel> ListDllModelsDel
{
get { return _listDllModelsDel; }
set { _listDllModelsDel = value; }
} /// <summary>
/// 要添加的dll集合
/// </summary>
public List<DllModel> ListDllModelsAdd
{
get { return _listDllModelsAdd; }
set { _listDllModelsAdd = value; }
} /// <summary>
/// 配置文件的名字
/// </summary>
public string ConfigFileName
{
get
{
//_configFileName ="AddGAC_MSIL"+ ".config";
return _configFileName;
}
set { _configFileName = value; }
}
}
Dll的Model信息
/// <summary>
/// Dll的Model信息
/// </summary>
[Serializable]
public class DllModel
{
public DllModel()
{
} /// <summary>
///
/// </summary>
/// <param name="dllName"></param>
/// <param name="version"></param>
/// <param name="publicKeyToken"></param>
public DllModel(string dllName, string version, string publicKeyToken)
{
DllName = dllName;
PublicKeyToken = publicKeyToken;
Version = version;
} /// <summary>
/// dll的文件名【不带.dll的后缀名】
/// </summary>
public string DllName { get; set; } /// <summary>
/// 签名PublicKeyToken
/// </summary>
public string PublicKeyToken { get; set; } /// <summary>
/// 版本号
/// </summary>
public string Version { get; set; } /// <summary>
/// 获取 版本号加上PublicKeyToken
/// </summary>
/// <returns></returns>
public string GetVersionAddPublicKeyToken()
{
return Version + "__" + PublicKeyToken;
} /// <summary>
/// 获取添加了.dll后缀的文件名
/// </summary>
/// <returns></returns>
public string GetDllNameWithDll()
{
return DllName + ".dll";
} /// <summary>
/// 获取最终的dll的路径 如:【DevComponents.DotNetBar2\\11.8.0.4__7eb7c3a35b91de04\\DevComponents.DotNetBar2.dll】
/// </summary>
/// <returns></returns>
public string GetDllPath()
{
return DllName + "\\" + GetVersionAddPublicKeyToken() + "\\" + GetDllNameWithDll();
} /// <summary>
/// 获取第二级的文件夹名称=dll的文件名加上版本号和PublicKeyToken 如:【DevComponents.DotNetBar2\\11.8.0.4__7eb7c3a35b91de04】
/// </summary>
/// <returns></returns>
public string GetDirPathTwo()
{
return DllName + "\\" + GetVersionAddPublicKeyToken();
} /// <summary>
/// 获取第一级文件夹的名称=dll的文件名 如:【DevComponents.DotNetBar2】
/// </summary>
/// <returns></returns>
public string GetDirPathOne()
{
return DllName;
}
}
序列化帮助类
public class SerializeHelper<T>
{
public SerializeHelper()
{
} public static T Deserialze(byte[] buff)
{
T t;
using (MemoryStream memoryStream = new MemoryStream(buff))
{
memoryStream.Position = (long);
t = (T)(new BinaryFormatter()).Deserialize(memoryStream);
}
return t;
} public static byte[] Serialze(T t)
{
byte[] array;
using (MemoryStream memoryStream = new MemoryStream())
{
(new BinaryFormatter()).Serialize(memoryStream, t);
array = memoryStream.ToArray();
}
return array;
} public static T StringDeserialze(string rs)
{
T t;
try
{
XmlSerializer xmlSerializer = new XmlSerializer(typeof(T));
using (XmlReader xmlReader = XmlReader.Create(new StringReader(rs)))
{
t = (T)xmlSerializer.Deserialize(xmlReader);
}
}
catch
{
t = default(T);
}
return t;
} public static string StringSerialze(T obj)
{
StringBuilder stringBuilder = new StringBuilder();
try
{
XmlSerializer xmlSerializer = new XmlSerializer(typeof(T));
using (XmlWriter xmlWriter = XmlWriter.Create(stringBuilder))
{
xmlSerializer.Serialize(xmlWriter, obj);
}
}
catch (Exception exception)
{
return exception.Message;
}
return stringBuilder.ToString();
} public static DataTable ToDataTable(IEnumerable<T> varlist)
{
object value;
DataTable dataTable = new DataTable();
PropertyInfo[] properties = null;
if (varlist == null)
{
return dataTable;
}
foreach (T t in varlist)
{
if (properties == null)
{
properties = t.GetType().GetProperties();
PropertyInfo[] propertyInfoArray = properties;
for (int i = ; i < (int)propertyInfoArray.Length; i++)
{
PropertyInfo propertyInfo = propertyInfoArray[i];
Type propertyType = propertyInfo.PropertyType;
if (propertyType.IsGenericType && propertyType.GetGenericTypeDefinition() == typeof(Nullable<>))
{
propertyType = propertyType.GetGenericArguments()[];
}
dataTable.Columns.Add(new DataColumn(propertyInfo.Name, propertyType));
}
}
DataRow dataRow = dataTable.NewRow();
PropertyInfo[] propertyInfoArray1 = properties;
for (int j = ; j < (int)propertyInfoArray1.Length; j++)
{
PropertyInfo propertyInfo1 = propertyInfoArray1[j];
DataRow dataRow1 = dataRow;
string name = propertyInfo1.Name;
if (propertyInfo1.GetValue(t, null) == null)
{
value = DBNull.Value;
}
else
{
value = propertyInfo1.GetValue(t, null);
}
dataRow1[name] = value;
}
dataTable.Rows.Add(dataRow);
}
return dataTable;
} public static DataTable ToDataTable(T obj)
{
object value;
DataTable dataTable = new DataTable();
if (obj == null)
{
return dataTable;
}
PropertyInfo[] properties = typeof(T).GetProperties();
PropertyInfo[] propertyInfoArray = properties;
for (int i = ; i < (int)propertyInfoArray.Length; i++)
{
PropertyInfo propertyInfo = propertyInfoArray[i];
Type propertyType = propertyInfo.PropertyType;
if (propertyType.IsGenericType && propertyType.GetGenericTypeDefinition() == typeof(Nullable<>))
{
propertyType = propertyType.GetGenericArguments()[];
}
dataTable.Columns.Add(new DataColumn(propertyInfo.Name, propertyType));
}
DataRow dataRow = dataTable.NewRow();
PropertyInfo[] propertyInfoArray1 = properties;
for (int j = ; j < (int)propertyInfoArray1.Length; j++)
{
PropertyInfo propertyInfo1 = propertyInfoArray1[j];
DataRow dataRow1 = dataRow;
string name = propertyInfo1.Name;
if (propertyInfo1.GetValue(obj, null) == null)
{
value = DBNull.Value;
}
else
{
value = propertyInfo1.GetValue(obj, null);
}
dataRow1[name] = value;
}
dataTable.Rows.Add(dataRow);
return dataTable;
} public static T XMLDeserialze(string filePath)
{
T t;
try
{
XmlSerializer xmlSerializer = new XmlSerializer(typeof(T));
using (XmlReader xmlReader = XmlReader.Create(filePath))
{
t = (T)xmlSerializer.Deserialize(xmlReader);
}
}
catch
{
t = default(T);
}
return t;
} public static void XMLSerialze(T obj, string filePath)
{
try
{
XmlSerializer xmlSerializer = new XmlSerializer(typeof(T));
using (XmlWriter xmlWriter = XmlWriter.Create(filePath))
{
xmlSerializer.Serialize(xmlWriter, obj);
}
}
catch
{
}
}
}
Main方法所在类
public class Program
{
/// <summary>
/// 要删除的dll集合
/// </summary>
private static readonly List<DllModel> listDllModelsDel = new List<DllModel>(); /// <summary>
/// 要添加的dll集合
/// </summary>
private static readonly List<DllModel> listDllModelsAdd = new List<DllModel>(); private static ConfigModel configModel = new ConfigModel(); private static readonly string path = AppDomain.CurrentDomain.BaseDirectory + "\\" +
"AddGAC_MSIL_Log.log"; private static readonly FileStream fileStream = new FileStream(path, FileMode.Create, FileAccess.Write,
FileShare.Read); private static readonly StreamWriter streamWriter = new StreamWriter(fileStream); public static void Main(string[] args)
{
streamWriter.WriteLine("--------------------------------------------------------------------------");
streamWriter.WriteLine("本工具可以读取配置文件,灵活的删除和添加GAC文件。" +
"\r\n使用之前务必关掉Visual Studio工具,并且使用管理员权限运行。");
streamWriter.WriteLine("方便为程序打补丁,方便制做安装包等等");
streamWriter.WriteLine("本工具由冰河之刃开发");
streamWriter.WriteLine("本人博客:http://www.cnblogs.com/binghe021");
streamWriter.WriteLine("--------------------------------------------------------------------------");
LoadConfig();
//InitDllModels();
GAC_MSIL_Del();
GAC_MSIL_Add(); streamWriter.Close();
fileStream.Close(); Console.WriteLine("文件注册到GAC中完成");
Console.WriteLine("注册日志在:"+path);
Console.WriteLine("准备打开注册日志");
Process.Start(path);
Console.WriteLine("日志若显示注册到GAC中成功,则说明补丁应用成功");
Console.WriteLine("本补丁不会备份原文件【官方有限制版】,请注意。");
Console.ReadLine();
} /// <summary>
/// 添加
/// </summary>
private static void GAC_MSIL_Add()
{
streamWriter.WriteLine("开始添加 配置文件中 要添加到GAC中 的文件");
if (configModel.ListDllModelsAdd!=null && configModel.ListDllModelsAdd.Count>)
{
foreach (DllModel dllModel in configModel.ListDllModelsAdd)
{
streamWriter.WriteLine(AddGacFile(dllModel));
}
}
streamWriter.WriteLine("添加完毕");
} /// <summary>
/// 删除
/// </summary>
private static void GAC_MSIL_Del()
{
streamWriter.WriteLine("开始删除 配置文件中 要删除的 GAC中文件");
if (configModel.ListDllModelsDel != null && configModel.ListDllModelsDel.Count > )
{
foreach (DllModel dllModel in configModel.ListDllModelsDel)
{
streamWriter.WriteLine(DelGacFile(dllModel.GetDllPath()));
streamWriter.WriteLine(DelGacDir(dllModel.GetDirPathTwo()));
streamWriter.WriteLine(DelGacDir(dllModel.GetDirPathOne()));
}
}
streamWriter.WriteLine("删除完毕");
////删除本次要添加到GAC里面的DLL,不想覆盖拷贝,避免产生不可预知的问题
////不需要执行。因为在删除的时候第一级的大文件夹的名字是相同的,所以会将一个dll的所有版本都删除的。
//if (configModel.ListDllModelsAdd != null && configModel.ListDllModelsAdd.Count > 0)
//{
// foreach (DllModel dllModel in configModel.ListDllModelsAdd)
// {
// streamWriter.WriteLine(DelGacFile(dllModel.GetDllPath()));
// streamWriter.WriteLine(DelGacDir(dllModel.GetDirPathTwo()));
// streamWriter.WriteLine(DelGacDir(dllModel.GetDirPathOne()));
// }
//} } /// <summary>
/// 加载
/// </summary>
private static void InitDllModels()
{
//del
listDllModelsDel.Add(new DllModel("DevComponents.DotNetBar.Design", "11.8.0.4", "90f470f34c89ccaf"));
listDllModelsDel.Add(new DllModel("DevComponents.DotNetBar.Keyboard", "11.8.0.4", "7eb7c3a35b91de04"));
listDllModelsDel.Add(new DllModel("DevComponents.DotNetBar.Layout", "11.8.0.4", "7eb7c3a35b91de04"));
listDllModelsDel.Add(new DllModel("DevComponents.DotNetBar.Layout.Design", "11.8.0.4", "7eb7c3a35b91de04"));
listDllModelsDel.Add(new DllModel("DevComponents.DotNetBar.Schedule", "11.8.0.4", "7eb7c3a35b91de04"));
listDllModelsDel.Add(new DllModel("DevComponents.DotNetBar.SuperGrid", "11.8.0.4", "7eb7c3a35b91de04"));
listDllModelsDel.Add(new DllModel("DevComponents.DotNetBar2", "11.8.0.4", "7eb7c3a35b91de04"));
listDllModelsDel.Add(new DllModel("DevComponents.Instrumentation", "11.8.0.4", "f90dc37c26666a67"));
listDllModelsDel.Add(new DllModel("DevComponents.Instrumentation.Design", "11.8.0.4", "76cb4c6eb576bca5"));
listDllModelsDel.Add(new DllModel("DevComponents.SuperGrid.Design", "11.8.0.4", "26d81176cfa2b486"));
listDllModelsDel.Add(new DllModel("DevComponents.TreeGX", "11.8.0.4", "055db68f670cfeab")); //add
listDllModelsAdd.Add(new DllModel("DevComponents.DotNetBar.Design", "11.8.0.4", "86742bc79fd2768a"));
listDllModelsAdd.Add(new DllModel("DevComponents.DotNetBar.Keyboard", "11.8.0.4", "86742bc79fd2768a"));
listDllModelsAdd.Add(new DllModel("DevComponents.DotNetBar.Layout", "11.8.0.4", "86742bc79fd2768a"));
listDllModelsAdd.Add(new DllModel("DevComponents.DotNetBar.Layout.Design", "11.8.0.4", "86742bc79fd2768a"));
listDllModelsAdd.Add(new DllModel("DevComponents.DotNetBar.Schedule", "11.8.0.4", "86742bc79fd2768a"));
listDllModelsAdd.Add(new DllModel("DevComponents.DotNetBar.SuperGrid", "11.8.0.4", "86742bc79fd2768a"));
listDllModelsAdd.Add(new DllModel("DevComponents.DotNetBar2", "11.8.0.4", "86742bc79fd2768a"));
listDllModelsAdd.Add(new DllModel("DevComponents.Instrumentation", "11.8.0.4", "86742bc79fd2768a"));
listDllModelsAdd.Add(new DllModel("DevComponents.Instrumentation.Design", "11.8.0.4", "86742bc79fd2768a"));
listDllModelsAdd.Add(new DllModel("DevComponents.SuperGrid.Design", "11.8.0.4", "86742bc79fd2768a"));
listDllModelsAdd.Add(new DllModel("DevComponents.TreeGX", "11.8.0.4", "86742bc79fd2768a")); configModel.ListDllModelsDel = listDllModelsDel;
configModel.ListDllModelsAdd = listDllModelsAdd; configModel.ConfigFileName = Process.GetCurrentProcess().MainModule.FileName + ".gfl"; SerializeHelper<ConfigModel>.XMLSerialze(configModel, configModel.ConfigFileName);
} public bool SaveConfig()
{
bool isSaveOk = true;
try
{
if (configModel != null)
{
configModel.ConfigFileName = Process.GetCurrentProcess().MainModule.FileName + ".gfl"; SerializeHelper<ConfigModel>.XMLSerialze(configModel, configModel.ConfigFileName);
}
}
catch (Exception)
{
isSaveOk = false;
} return isSaveOk;
} public static bool LoadConfig()
{
configModel.ConfigFileName = Process.GetCurrentProcess().MainModule.FileName + ".gfl";
streamWriter.WriteLine("配置文件是"+configModel.ConfigFileName);
bool isLoadOk = true;
try
{
if (File.Exists(configModel.ConfigFileName))
{
configModel = SerializeHelper<ConfigModel>.XMLDeserialze(configModel.ConfigFileName);
streamWriter.WriteLine("读取配置文件成功");
}
else
{
streamWriter.WriteLine("没有发现配置文件");
}
}
catch (Exception)
{
streamWriter.WriteLine("读取配置文件失败");
isLoadOk = false;
} return isLoadOk;
} #region GAC /// <summary>
/// 删除GAC中文件夹
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public static string DelGacDir(string str)
{
string environmentVariable = Environment.GetEnvironmentVariable("WINDIR");
environmentVariable = string.Concat(environmentVariable, "\\assembly\\GAC_MSIL\\", str); if (Directory.Exists(environmentVariable))
{
Directory.Delete(environmentVariable, true);
return str + " 文件夹从GAC中删除成功";
}
return str + " 文件夹在GAC未发现,不处理,已跳过";
} /// <summary>
/// 删除GAC中文件
/// </summary>
/// <param name="fileName"></param>
/// <returns></returns>
public static string DelGacFile(string fileName)
{
string environmentVariable = Environment.GetEnvironmentVariable("WINDIR");
environmentVariable = string.Concat(environmentVariable, "\\assembly\\GAC_MSIL\\", fileName);
if (File.Exists(environmentVariable))
{
File.Delete(environmentVariable);
return fileName + " 从GAC中删除成功";
}
return fileName + " 文件未加入GAC,不处理,已跳过";
} /// <summary>
/// 添加文件到GAC中
/// </summary>
/// <param name="dllModel"></param>
/// <returns></returns>
public static string AddGacFile(DllModel dllModel)
{
try
{
string environmentVariable = Environment.GetEnvironmentVariable("WINDIR");
environmentVariable = string.Concat(environmentVariable, "\\assembly\\GAC_MSIL\\", Path.GetFileNameWithoutExtension(dllModel.GetDllNameWithDll()));
Directory.CreateDirectory(environmentVariable);
string str1 = environmentVariable;
string[] strArrays = new string[] { str1, "\\", GetFileVersion(dllModel.GetDllNameWithDll()), "_", GetFileCultureInfo(dllModel.GetDllNameWithDll()), "_", dllModel.PublicKeyToken };
environmentVariable = string.Concat(strArrays);
Directory.CreateDirectory(environmentVariable);
File.Copy(dllModel.GetDllNameWithDll(), string.Concat(environmentVariable, "\\", Path.GetFileName(dllModel.GetDllNameWithDll())), true);
}
catch (Exception exception)
{
return dllModel.GetDllNameWithDll() + " 加入GAC失败" + exception.Message;
}
return dllModel.GetDllNameWithDll()+" 加入GAC成功";
} public static string GetFileVersion(string str)
{
//Path.GetFileName(str);
return AssemblyName.GetAssemblyName(str).Version.ToString();
} public static string GetFileCultureInfo(string str)
{
//Path.GetFileName(str);
return AssemblyName.GetAssemblyName(str).CultureInfo.Name;
}
#endregion GAC
}
小工具【AddGAC_MSIL】下载地址
感觉本文对你有用,请点个赞哦^_^,推荐一下下。
建议关注tracky的博客和本人博客,获取最新的DotNetBar补丁及安装包。