Monday, July 19, 2010

Strong name validation failed. (Exception from HRESULT: 0x8013141A)

System.Security.SecurityException: Strong name validation failed. (Exception from HRESULT: 0x8013141A) The Zone of the assembly that failed was "My Computer"

step 1) takeover the following code: http://www.mikevdm.com/BlogEntry/Key/Simple-Gacutil-Replacement
step 2) add a post build event:
- $(SolutionDir)Tools\Gacutil.exe remove $(TargetPath)
- $(SolutionDir)Tools\Gacutil.exe add $(TargetPath)
step 3) run from the console: D:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\NETFX 4.0 Tools\x64>sn.exe -Vr *,[public key token]

estimated time solver: 30 - 60 minutes

assign TFS Workitems to different users

The following code display how it's possible to set the assign-to field from one user to another user. I had to write this code because in my instance the console command did not work:
TFSConfig Identities /change /fromdomain:Contoso1 /todomain:ContosoPrime /account:Contoso1\hholt /toaccount:ContosoPrime\jpeoples

Since the created-by field is a read only field this code will not change the value but if your really need to handle this then I think it should be possible to manipulate the XML of your Workitems and then handle it. Sounds to me like a lot of work.

Add the following using's to your classes:



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation;
using Microsoft.TeamFoundation.Server;
using Microsoft.TeamFoundation.Framework.Client;
using System.Collections.ObjectModel;
using Microsoft.TeamFoundation.Framework.Common;
using Microsoft.TeamFoundation.WorkItemTracking.Client;
using Microsoft.TeamFoundation.VersionControl.Client;



Helper methods:


public static string url = @"https://tfs.yourdomain.com/tfs";

[System.Diagnostics.DebuggerStepThrough]
public static TfsConfigurationServer GetTfsConfigurationServer()
{
return new TfsConfigurationServer(new Uri(url), GetCredentials(), new UICredentialsProvider());
}

[System.Diagnostics.DebuggerStepThrough]
private static ICredentials GetCredentials()
{
return new NetworkCredential("user", "password", "domain");
}

[System.Diagnostics.DebuggerStepThrough]
public static bool EnsureAuthentication(TfsConfigurationServer srv)
{
bool result = true;

try
{
srv.EnsureAuthenticated();
srv.Authenticate();
result = srv.HasAuthenticated;
}
catch (Exception)
{
result = false;
}

return result;
}


The main code to re-assign your workitem assign-to field over all TFS collections:

this code is stright forward without any add ons or so... enjoy



static void Main(string[] args)
{

List<Identity> tfsIdentities = Helper.GetAllTfsUsers();

Console.WriteLine("Connecting to Server: " + Helper.url);
TfsConfigurationServer srv = Helper.GetTfsConfigurationServer();

Console.WriteLine("Ensure Authenticated: " + Helper.url);
srv.EnsureAuthenticated();

srv.Authenticate();
int counter = 0;

if (srv.HasAuthenticated)
{
CatalogNode configurationServerNode = srv.CatalogNode;

// Query the children of the configuration server node for all of the team project collection nodes
ReadOnlyCollection<CatalogNode> tpcNodes = configurationServerNode.QueryChildren(
new Guid[] { CatalogResourceTypes.ProjectCollection },
false,
CatalogQueryOptions.None);

foreach (CatalogNode tpcNode in tpcNodes)
{
Guid tpcId = new Guid(tpcNode.Resource.Properties["InstanceId"]);
TfsTeamProjectCollection tpc = srv.GetTeamProjectCollection(tpcId);


// Do your tpc work here.
Console.WriteLine("{0}", tpc.Name);



// get a reference to the work item tracking service
var workItemStore = tpc.GetService<WorkItemStore>();

if (workItemStore.Projects.Count <= 0)
{
// go over the next project
continue;
}

// iterate over the projects
foreach (Project project in workItemStore.Projects)
{
Console.WriteLine("\tProject: {0}", project.Name);

VersionControlServer versionControl = (VersionControlServer)tpc.GetService(typeof(VersionControlServer));
TeamProject teamProject = versionControl.GetTeamProject(project.Name);
IGroupSecurityService gss = (IGroupSecurityService)tpc.GetService<IGroupSecurityService>();
Identity[] appGroups = gss.ListApplicationGroups(teamProject.ArtifactUri.AbsoluteUri);

foreach (Identity group in appGroups)
{
Identity[] groupMembers = gss.ReadIdentities(SearchFactor.Sid, new string[] { group.Sid }, QueryMembership.Expanded);
foreach (Identity member in groupMembers)
{
if (member.Members != null)
{
foreach (string memberSid in member.Members)
{
Identity memberInfo = gss.ReadIdentity(SearchFactor.Sid, memberSid, QueryMembership.None);

if (memberInfo.Type == IdentityType.WindowsUser)
{
// Console.WriteLine("\t" + memberInfo.AccountName + " - " + memberInfo.DisplayName + " - " + memberInfo.Domain);
if (!tfsIdentities.Contains(memberInfo))
tfsIdentities.Add(memberInfo);
}
}
}
}
}

WorkItemCollection workItemCollection = workItemStore.Query(
" SELECT [System.Id], [System.WorkItemType]," +
" [System.State], [System.AssignedTo], [System.Title] " +
" FROM WorkItems " +
" WHERE [System.TeamProject] = '" + project.Name +
"' ORDER BY [System.WorkItemType], [System.Id]");

foreach (WorkItem item in workItemCollection)
{
counter++;

bool containsOldDomain = item[CoreField.AssignedTo].ToString().Contains(@"OldValidUser");

if (containsOldDomain)
{
WorkItem item1 = workItemStore.GetWorkItem(item.Id);
item1.Fields[CoreField.AssignedTo].Value = "NewValidUser";

try
{
bool a = (item1.Validate().Count == 0);

if (a)
{
Console.WriteLine("\t\tValid: " + item.Id + item.Title);
item1.Save();
}
else
{
Console.WriteLine("\t\tNot Valid: " + item.Id + item.Title);
}
}
catch (Exception ex)
{
Console.WriteLine(item.Id + ": " + ex.Message);
}
}
}
// clear users
tfsIdentities.Clear();

}
}
}

Console.WriteLine("Workitem count {0}", counter);
Console.WriteLine("Press enter to exit");
Console.ReadLine();
}

Retrieve a list with all your TFS Users

The following code demonstrates how to read all users from different TFS collections.

namespace Migrator
{

using System;
using System.Linq;
using System.Reflection;
using Microsoft.TeamFoundation.Client;
using System.Net;
using Microsoft.TeamFoundation.Server;
using System.Collections.Generic;
using Microsoft.TeamFoundation.Framework.Client;
using System.Collections.ObjectModel;
using Microsoft.TeamFoundation.Framework.Common;
using Microsoft.TeamFoundation.WorkItemTracking.Client;
using Microsoft.TeamFoundation.VersionControl.Client;


public static class Helper
{
// without collection name
public static string url = @"http://tfs.yoururl.com/tfs";

[System.Diagnostics.DebuggerStepThrough]
public static TfsConfigurationServer GetTfsConfigurationServer()
{
return new TfsConfigurationServer(new Uri(url), GetCredentials(), new UICredentialsProvider());
}

[System.Diagnostics.DebuggerStepThrough]
private static ICredentials GetCredentials()
{
return new NetworkCredential("adminuser", "password", "YourDomain");
}

[System.Diagnostics.DebuggerStepThrough]
public static bool EnsureAuthentication(TfsConfigurationServer srv)
{
bool result = true;

try
{
srv.EnsureAuthenticated();
srv.Authenticate();
result = srv.HasAuthenticated;
}
catch (Exception)
{
result = false;
}

return result;
}

public static List<Identity> GetAllTfsUsers()
{
List<Identity> result = new List<Identity>();
TfsConfigurationServer srv = Helper.GetTfsConfigurationServer();

if (EnsureAuthentication(srv))
{
CatalogNode configurationServerNode = srv.CatalogNode;

// Query the children of the configuration server node for all of the team project collection nodes
ReadOnlyCollection<CatalogNode> tpcNodes = configurationServerNode.QueryChildren(
new Guid[] { CatalogResourceTypes.ProjectCollection },
false,
CatalogQueryOptions.None
);

foreach (CatalogNode tpcNode in tpcNodes)
{
Guid tpcId = new Guid(tpcNode.Resource.Properties["InstanceId"]);
TfsTeamProjectCollection tpc = srv.GetTeamProjectCollection(tpcId);

Console.WriteLine("{0}", tpc.Name);

// get a reference to the work item tracking service
var workItemStore = tpc.GetService<WorkItemStore>();

// go over the next node if no projects available
if (workItemStore.Projects.Count <= 0)
{
continue;
}

// iterate over the projects
foreach (Project project in workItemStore.Projects)
{
Console.WriteLine("\tProject: {0}", project.Name);
try
{
VersionControlServer versionControl = (VersionControlServer)tpc.GetService(typeof(VersionControlServer));
TeamProject teamProject = versionControl.GetTeamProject(project.Name);
IGroupSecurityService gss = (IGroupSecurityService)tpc.GetService<IGroupSecurityService>();
Identity[] appGroups = gss.ListApplicationGroups(teamProject.ArtifactUri.AbsoluteUri);

foreach (Identity group in appGroups)
{
Identity[] groupMembers = gss.ReadIdentities(SearchFactor.Sid, new string[] { group.Sid }, QueryMembership.Expanded);
foreach (Identity member in groupMembers)
{
if (member.Members != null)
{
foreach (string memberSid in member.Members)
{
Identity memberInfo = gss.ReadIdentity(SearchFactor.Sid, memberSid, QueryMembership.None);
if (memberInfo.Type == IdentityType.WindowsUser)
{
if (!result.Contains(memberInfo))
{
result.Add(memberInfo);
Console.WriteLine("\t\t" + memberInfo.AccountName + " - " + memberInfo.DisplayName + " - " + memberInfo.Domain);
}
else
{
Console.WriteLine("\t\tUser already available " + memberInfo.AccountName);
}

}
}
}
}
}
}
catch (Exception ex)
{
Console.WriteLine("\tThe Project: '{0}' throws an exception: {1} and will be ignored.", project.Name, ex.Message);
}
} // foreach (Project project in workItemStore.Projects)
} // foreach (CatalogNode tpcNode in tpcNodes)

}
else
{
Console.WriteLine("Authentication problem!");
}

return result;
}



}
}

Sunday, July 18, 2010

What is System Engineering

System Engineering is an interdisciplinary field of engineering that focus on how complex engineering projects should be designed and managed. Coordination of different teams and automatic control of machinery become more difficult when dealing with large, complex and a big amount of projects.
System Engineering deals with work processes and tools to handle projects, and it overlaps with both technical and human-centric disciplines such as control engineering and project management.

Concept
System Engineering signifies both an approach and, more recently, as a discipline in engineering. The aim of education in System Engineering is to simply formalize the approach and in doing so, identify new methods and research opportunities similar to the way it occurs in other fields of engineering. As an approach, System Engineering is holistic and interdisciplinary in flavor.

Holistic View
System Engineering focus on defining customer needs and required functionality early in the development cycle, documenting requirements, then proceeding with design synthesis and system validation while considering the complete problem, the system lifecycle. System Engineering process can be decomposed into:
• a System Engineering Technical Process
• a System Engineering Management Process

Managing complexity
The need for system engineering arose with the increase in complexity of systems and projects. When speaking in this complexity incorporates not only engineering systems, but also the logical human organization of data. At the same time, a system can become more complex due to an increase in size as well as with an increase in the amount of data, variables, or the number of fields that are involved in the design.



Scope
One way to understand the motivation behind system engineering is to see it as a method, or practice, to identify and improve common rules that exist within a wide variety of systems. Keeping this aspect in mind, the principles of System Engineering can be applied to any system, complex or otherwise, provided system thinking is employed at all levels.

System engineering encourages the use of modeling and simulation to validate assumptions or theories on systems and the interactions with and within them.
Use of methods that allow early detection of possible failures, in Safety engineering, are integrated into the design process. At the same time, decisions made at the beginning of a project whose consequences are not clearly understood can have enormous implications later in the life cycle of a system, and it is the task of the modern system engineer to explore these issues and make critical decisions. There is no method which guarantees that decisions made today will stay be valid when a system goes into service years or decades after it is first conceived but there are techniques to support the process of system engineering.

Add Bookmark over JS

//add-bookmark
//function bookmark(anchor){
if(window.external)
{
window.external.AddFavorite(anchor.getAttribute('href'), anchor.getAttribute('title'));
return false;
}
return true;
}
//]]>

Shared Cache - .Net Caching made easy

All information about Shared Cache is available here: http://www.sharedcache.com/. Its free and easy to use, we provide all sources at codeplex.

Facebook Badge