Forum Discussion
Dmitry_Nikolaev
14 years agoStaff
Hi GJ,
There is no built-in way to do this in TestComplete as well as in the .NET Framework. However, it is possible to get this information using the 'Gacutil' tool which is shipped along with the .NET Framework SDK. This SDK is installed along with Visual Studio or with the SDK of the operating system. The below script demonstrates how this tool can be used in TestComplete.
function test()
{
// var items = getInstalledAssembliesList(); // Get all assemblies
var items = getInstalledAssembliesList("MyCompany.MyNamespace.MyAssembly");
Log.Message("Total " + items.length + " assemblies");
for (var i = 0; i < items.length; i++) {
Log.Message(items.Name, items.Version + "\r\n" + items.Culture + "\r\n" + items.PublicKeyToken);
}
}
function getInstalledAssembliesList(assemblyName)
{
if (null == assemblyName) {
assemblyName = "";
}
var gacutilPath = "\"c:\\Program Files\\Microsoft SDKs\\Windows\\v7.0\\Bin\\gacutil.exe\"";
var header = "The Global Assembly Cache contains the following assemblies:";
var footer = "Number of items =";
var WshShellObj = new ActiveXObject("WScript.Shell");
var WshShellExecObj = WshShellObj.Exec(gacutilPath + " /l " + assemblyName);
var out = "";
while (!WshShellExecObj.StdOut.AtEndOfStream) {
out += WshShellExecObj.StdOut.Read(1);
}
var strList = aqString.Trim(out.match(new RegExp("^.*" + header + "((\\s|\\S)*)" + footer + ".*$", "im"))[1]);
var strArr = strList.split("\r\n");
var assembliesList = new Array();
for (var i = 0; i < strArr.length; i++) {
var line = strArr.split(",");
var item = new Object();
item.Name = aqString.Trim(line[0]);
item.Version = aqString.Trim(line[1].split("=")[1]);
item.Culture = aqString.Trim(line[2].split("=")[1]);
item.PublicKeyToken = aqString.Trim(line[3].split("=")[1]);
assembliesList.push(item);
}
return assembliesList;
}
Related Content
Recent Discussions
- 19 hours agodhundley