Friday, October 19, 2007

Set the "Custom Tool" property for a project file.

Recently I came across the need to create a custom tool that codegen a string resource from an xml file. The problem that i got into was to find a way to set the "Custom Tool" property of the xml file. Below is the code that I used after spending some effort in searching. I hope this can help to save some of your time too. If you want to know what other properties are in, you can loop through the collection.

31 public void Execute(object Application, int hwndOwner, ref object[] ContextParams, ref object[] CustomParams, ref EnvDTE.wizardResult retval)

32 {

33 //If you want to create project, code should be included in this function.

34 ProjectItems projectItems = (ProjectItems)ContextParams[2];

35 ProjectItem projectItemXML = projectItems.AddFromTemplate((string)CustomParams[0] + "\\StringResourceTemplate.xml", (string)ContextParams[4] + ".xml");


37 projectItemXML.Properties.Item("CustomTool").Value = "StringResourceGenerator";

Tuesday, October 16, 2007

Visual Studio Test Team Results is not that portable.....

Recently i ran some stress tests for a web site and was trying to export the test result to some portable format such as a picture file so that the "bos" can see the result. To my amazed, there's no function provided by Visual Studio that can do so. The only way that i can see a graphical presentation is through the Visual Studio interface. I hope Visual Studio can be enhanced in the future to provide a good "Export" functionality.

Dead Schedule in SharePoint???

Recently i am experiencing some SharePoint schedule not able to wake up after the time was elapsed even though i have applied the Microsoft KB932394 patch that fixes a bug related to the timer. After doing some investigations, i discovered that the main root cause was because of the SMTP server not able to response when multiple mails were sent simultinousely. This has caused the SharePoint workflow process to be blocked. I solved this problem by converting the workflow to a asynchronous process and by adding some retry logics that can help to resend an unsent email. Below is the code that i applied:

  374 //Assign a callback function

  375 AsyncCallback callback = new AsyncCallback(CallBack);

  376 //Create a delegate that trigger the send mail function

  377 SendEmailHandler handler = new SendEmailHandler(SendEmailUsingSmtp);

  378 //Call the function with all the related parameters

  379 IAsyncResult result = handler.BeginInvoke(this.SmtpServer, this.Port, this.From, callback, null);

  380 //Wait for 30 seconds, else timeout

  381 result.AsyncWaitHandle.WaitOne(new TimeSpan(0, 0, 30), true);

  382 //end of function invoke.

  383 handler.EndInvoke(result);

Wow!!! Here i am

After seeing my friend created a stunning blog, I can't resist to create one for myself.