I have code that works just fine (visual web part). I had deleted the testing console application, and now I have need for it again. The browser will open up once running the console application, but then nothing happens. My breakpoint is not hit, and yet there are no errors.
1) I am an admin 2) console app is .net 3.5 and x64 3) no errors
class Program
{
static void Main(string[] args)
{
List<string> displayNames = new List<string>();
List<string> branch = new List<string>();
List<string> department = new List<string>();
string dept;
using (SPSite site = new SPSite("http://mysite"))
{
//using (SPWeb web = site.OpenWeb())
//{
// the line below has a breakpoint - never hit
SPServiceContext context = SPServiceContext.GetContext(site);
UserProfileManager profileManager = new UserProfileManager(context);
foreach (UserProfile profile in profileManager)
{
// checks if work phone is empty - this relates to vendors in AD and are not employees
if (!string.IsNullOrEmpty(string.Format("{0}", profile["WorkPhone"].Value)))
{
Console.WriteLine(string.Format("{0}", profile["PreferredName"].Value));
displayNames.Add(string.Format("{0} - {1}", profile["PreferredName"].Value, profile["WorkPhone"].Value));
}
dept = string.Format("{0}", profile["Department"].Value);
if (!string.IsNullOrEmpty(dept))
{
if (dept.StartsWith("Branch -"))
{
branch.Add(dept);
}
else
{
department.Add(dept);
}
}
}
//}
Console.Read();
department = department.Distinct().OrderBy(x => x).ToList();
branch = branch.Distinct().OrderBy(x => x).ToList();
displayNames.Sort();
}
}
thanks
Debugconfiguration ? Where is your breakpoint ? If you wrap the whole content ofMainin atry/catch, do you see any exception ? Which one ? – Steve B Jun 8 '12 at 13:32