i wrote this code.
SPWeb currentWeb = SPControl.GetContextWeb(HttpContext.Current);
string currentUserName = currentWeb.CurrentUser.LoginName;
LiteralControl message = new LiteralControl();
message.Text = "currentUserName";
Controls.Add(message);
After that Webpart is throwing this error :
Web Part Error: Unhandled exception was thrown by the sandboxed code wrapper's Execute method in the partial trust app domain: An unexpected error has occurred.
Syed Shujaat Ali