March 2010 - Posts
UPDATE: The command
devenv /ResetSkipPkgs helped out one person - try this first
This has bitten several of our team members – can’t track down the cause, but to address
1. Remove/Rename the C:\Users\[accountname]\AppData\Local\Microsoft\Team Foundation\2.0\Cache folder
2. Run “devenv /resetuserdata".
Thanks to
http://codeclimber.net.nz/archive/2008/11/12/red-x-on-build-folder-on-team-explorer.aspx
I run my development server by boot to VHD (Windows Server 2008 R2 x64). In that instance, I also have an attached VHD (I attach via script at boot up time using Task Scheduler). That VHD I have my SQL instances installed.
So, the other day, acting hasty, I chmod my ACLS – wow, what a day after that.
So, in order to fix it I created this set of BAT commands that resets it back to operational state – not 100% of all what you get, I also didn’t want to run a “repair” – but, all operational again.
setlocal
SET Inst100Path=H:\Program Files\Microsoft SQL Server\100
REM GOTO SQLE
SET InstanceName=MSSQLSERVER
SET InstIdPath=H:\Program Files\Microsoft SQL Server\MSSQL10.%InstanceName%
SET Group=SQLServerMSSQLUser$SCICORIA-HV1$%InstanceName%
SET AgentGroup=SQLServerSQLAgentUser$SCICORIA-HV1$%InstanceName%
ICACLS "%InstIdPath%\MSSQL" /T /Q /grant "%Group%":(OI)(CI)FX
ICACLS "%InstIdPath%\MSSQL\backup" /T /Q /grant "%Group%":(OI)(CI)F
ICACLS "%InstIdPath%\MSSQL\data" /T /Q /grant "%Group%":(OI)(CI)F
ICACLS "%InstIdPath%\MSSQL\FTdata" /T /Q /grant "%Group%":(OI)(CI)F
ICACLS "%InstIdPath%\MSSQL\Jobs" /T /Q /grant "%Group%":(OI)(CI)F
ICACLS "%InstIdPath%\MSSQL\binn" /T /Q /grant "%Group%":(OI)(CI)RX
ICACLS "%InstIdPath%\MSSQL\Log" /T /Q /grant "%Group%":(OI)(CI)F
ICACLS "%Inst100Path%" /T /Q /grant "%Group%":(OI)(CI)RX
ICACLS "%Inst100Path%\shared\Errordumps" /T /Q /grant "%Group%":(OI)(CI)RXW
ICACLS "%InstIdPath%\MSSQL" /T /Q /grant "%AgentGroup%":(OI)(CI)RX
ICACLS "%InstIdPath%\MSSQL\binn" /T /Q /grant "%AgentGroup%":(OI)(CI)F
ICACLS "%InstIdPath%\MSSQL\Log" /T /Q /grant "%AgentGroup%":(OI)(CI)F
ICACLS "%Inst100Path%" /T /Q /grant "%AgentGroup%":(OI)(CI)RX
REM THIS IS THE SQL EXPRESS INSTANCE
:SQLE
SET InstanceName=SQLEXPRESS
SET InstIdPath=H:\Program Files\Microsoft SQL Server\MSSQL10.%InstanceName%
SET Group=SQLServerMSSQLUser$SCICORIA-HV1$%InstanceName%
SET AgentGroup=SQLServerSQLAgentUser$SCICORIA-HV1$%InstanceName%
ICACLS "%InstIdPath%\MSSQL" /T /Q /grant "%Group%":(OI)(CI)FX
ICACLS "%InstIdPath%\MSSQL\backup" /T /Q /grant "%Group%":(OI)(CI)F
ICACLS "%InstIdPath%\MSSQL\data" /T /Q /grant "%Group%":(OI)(CI)F
ICACLS "%InstIdPath%\MSSQL\FTdata" /T /Q /grant "%Group%":(OI)(CI)F
ICACLS "%InstIdPath%\MSSQL\Jobs" /T /Q /grant "%Group%":(OI)(CI)F
ICACLS "%InstIdPath%\MSSQL\binn" /T /Q /grant "%Group%":(OI)(CI)RX
ICACLS "%InstIdPath%\MSSQL\Log" /T /Q /grant "%Group%":(OI)(CI)F
ICACLS "%Inst100Path%" /T /Q /grant "%Group%":(OI)(CI)RX
ICACLS "%Inst100Path%\shared\Errordumps" /T /Q /grant "%Group%":(OI)(CI)RXW
ICACLS "%InstIdPath%\MSSQL" /T /Q /grant "%AgentGroup%":(OI)(CI)RX
ICACLS "%InstIdPath%\MSSQL\binn" /T /Q /grant "%AgentGroup%":(OI)(CI)F
ICACLS "%InstIdPath%\MSSQL\Log" /T /Q /grant "%AgentGroup%":(OI)(CI)F
ICACLS "%Inst100Path%" /T /Q /grant "%AgentGroup%":(OI)(CI)RX
endlocal
I’m not sure where I had seen some of this base code, but this comes up time & time again on projects.
Here’s a little method that copies all the R/W properties (public) between 2 distinct class definitions:
It’s called as follows:
private static void Test1()
{
MyClass obj1 = new MyClass()
{
Prop1 = "one",
Prop2 = "two",
Prop3 = 100
};
MyOtherClass obj2 = null;
obj2 = CopyClass(obj1);
Console.WriteLine(obj1);
Console.WriteLine(obj2);
}
namespace Space1
{
public class MyClass
{
public string Prop1 { get; set; }
public string Prop2 { get; set; }
public int Prop3 { get; set; }
public override string ToString()
{
var rv = string.Format("MyClass: {0} Prop2: {1} Prop3 {2}", Prop1, Prop2, Prop3);
return rv;
}
}
}
namespace Space2
{
public class MyOtherClass
{
public string Prop1 { get; set; }
public string Prop2 { get; set; }
public int Prop3 { get; set; }
public override string ToString()
{
var rv = string.Format("MyOtherClass: {0} Prop2: {1} Prop3 {2}", Prop1, Prop2, Prop3);
return rv;
}
}
Source of the method:
///
/// Provides a Copy of Public fields between 2 distinct classes
///
/// Source class name
/// Target class name
/// Instance of type Source
/// An instance of type Target copying all public properties matching name from the Source.
public static T CopyClass<s , T>(S source) where T : new()
{
T target = default(T);
BindingFlags flags = BindingFlags.Public | BindingFlags.Instance;
if (source == null)
{
return (T)target;
}
if (target == null) target = new T();
PropertyInfo[] objProperties = target.GetType().GetProperties(flags);
foreach (PropertyInfo pi in objProperties)
{
string name = pi.Name;
PropertyInfo sourceProp = source.GetType().GetProperty(name, flags);
if (sourceProp == null)
{
throw new ApplicationException(string.Format("CopyClass - object type {0} & {1} mismatch in property:{2}", source.GetType(), target.GetType(), name));
}
if (pi.CanWrite && sourceProp.CanRead)
{
object sourceValue = sourceProp.GetValue(source, null);
pi.SetValue(target, sourceValue, null);
}
else
{
throw new ApplicationException(string.Format("CopyClass - can't read/write a property object types {0} & {1} property:{2}", source.GetType(), target.GetType(), name));
}
}
return target;
}