TF30063: You are not authorized to access tfs\projects

TF30063 Access Unauthorized on TFS

Now thats an issue that can bamboozle the Windows Administrator also :)

Thanks to Ryan Hanisco’s blog,  http://ryanhanisco.com/2011/03/14/tfs-service-authentication-tf30063/, I resolved this issue.

Simple steps performed were: -

  • Click Start, click Run, type regedit, and then click OK.
  • Locate and then click the following registry subkey:
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\MSV1_0
  • Create new Multi-String Value and name it as BackConnectionHostNames
  • In the Value data box, type the CNAME or the DNS alias, that is used for the local shares on the computer, and then click OK.
    Note
    - Type each host name on a separate line.
    - If the BackConnectionHostNames registry entry already exists as a REG_DWORD type then delete and recreate as Multi-String Value.
  • Exit Registry Editor, and then restart the computer.

Unable to cast object of type ‘System.Byte[]‘ to type ‘System.Drawing.Image’.

I had saved a logo in a varbinary field for report header. While using ActiveReports, I placed a picture object and on reportstart method tried to assign the DataRow image column to this object. Kept getting the Unable to cast of object type ‘System.Byte[]‘ to type ‘System.Drawing.Image‘ exception.

Finally resolved it using MemoryStream. Here is the code excerpt,

byte[] imgData = (byte[])dt.Rows[0]["MyLogo"];
MemoryStream ms = new MemoryStream(imgData);
reportLogo.Image = Image.FromStream(ms);

Have fun!

Enumerating a StringBuilder object

While trying to list all the string values within a stringbuilder object, I got an exception saying -

foreach statement cannot operate on variables of type ‘System.Text.StringBuilder’ because ‘System.Text.StringBuilder’ does not contain a public definition for ‘GetEnumerator’

But finally thought of a workaround. Using an array of string object. For example,


StringBuilder sColumns = new StringBuilder();
foreach (DataColumn col in dt.Columns)
{
sColumns.Append(col.ColumnName);
sColumns.Append(",");
}


string[] nameIDs = sColumns.ToString().Split(',');
foreach (string nameID in nameIDs)
{
Debug.WriteLine(nameID);
}

Configuring Office365 smtp on ASP.NET 1.1 web applications

If you are still having that frustrating exception “The transport failed to connect to the server” while trying to use an Office365 smtp server settings with ASP.NET 1.1 websites or web applications, then here is the quick fix.

SmtpMail.SmtpServer = pod0000.outlook.com; //your smtp server
webMail.Fields.Add(“http://schemas.microsoft.com/cdo/configuration/sendusing”,”2″);
webMail.Fields.Add(“http://schemas.microsoft.com/cdo/configuration/smtpauthenticate”, “1″);
webMail.Fields.Add(“http://schemas.microsoft.com/cdo/configuration/sendusername”, myusername@email.com);
webMail.Fields.Add(“http://schemas.microsoft.com/cdo/configuration/sendpassword”, mypassword);
webMail.Fields.Add(“http://schemas.microsoft.com/cdo/configuration/smtpserverport”, 25); //the confusing part is here
webMail.Fields.Add(“http://schemas.microsoft.com/cdo/configuration/smtpusessl”,”true”);

We know that Office365 uses SSL and the port should be 587 (or 465 in some cases) but unfortunately for some reason 587 port does not work in ASP.NET 1.1 when using CDONTS. So just plain luck, tried port 25 and the emails went through. This scenario only applies to ASP.NET 1.1 whereas ASP.NET 2.0 or later work fine with 587 port.

NetTiers generates methods for custom stored procedures that require nullable parameters

When generating methods for custom stored procedures using NetTiers all the paramters of Int, Decimal, etc get defined as Int32?, Decimal? as nullable parameters.

NetTiers says,

The problem is that a param of a stored procedure is always nullable.  You can’t have it not accept a null, you can however, have it use a default value.  So CodeSmith’s AllowDbNull property on the object is always true.
CSPUseDefaultValForNonNullableTypes, set that to true, and it will attempt to use see if the DefaultValue is not = NULL, then it will not make it a regular value type.  This of course only works for value types.

So the fix was to edit the template and
in section #07. CRUD – Advanced
change the value for CSPUseDefaultValForNonNullableTypes to True.

NetTiers ‘layerExceptionPolicy’ is inaccessible due to its protection level

I kept getting this exception while trying to build the generated classes from NetTiers.

To solve this mystery, here is my 20 cents :)

Open nettiers-2.3.1 (the version I am using) template in CodeSmith Generator Studio and browse to Components>ComponentDataAccess.cst file. You could even open this file in notepad.

In the region Fields you will see the following code,

  private static SecurityContext<<%= className %>> securityContext = new SecurityContext<<%= className %>>();
  private static readonly string layerExceptionPolicy = “<%= ComponentPattern %>ExceptionPolicy”;
  private static readonly bool noTranByDefault = false;

Change the highlighted code to the following

  protected static readonly string layerExceptionPolicy = “<%= ComponentPattern %>ExceptionPolicy”;

 

Handler Mappings for ActiveReports 3.0 on IIS7

If you are still facing that 404 – File Not Found exception when trying to open an ActiveReport in a ASP.NET 2.0 integrated website in a IIS7 hosting, then try the following mappings  – tried and verified -

<system.web>
…..
…..
<httpHandlers>
      <add verb=”*” path=”*.rpx” type=”DataDynamics.ActiveReports.Web.Handlers.RpxHandler, ActiveReports.Web, Version=5.3.1436.1, Culture=neutral, PublicKeyToken=cc4967777c49a3ff” />
      <add verb=”*” path=”*.ActiveReport” type=”DataDynamics.ActiveReports.Web.Handlers.CompiledReportHandler, ActiveReports.Web, Version=5.3.1436.1, Culture=neutral, PublicKeyToken=cc4967777c49a3ff” />
      <add verb=”*” path=”*.ArCacheItem” type=”DataDynamics.ActiveReports.Web.Handlers.WebCacheAccessHandler, ActiveReports.Web, Version=5.3.1436.1, Culture=neutral, PublicKeyToken=cc4967777c49a3ff” />
</httpHandlers>
…..
…..

<system.webServer>
…..
…..
<handlers accessPolicy=”Read, Execute, Script”>
      <add name=”ActiveReports RPX Handler” path=”*.rpx” verb=”*” type=”DataDynamics.ActiveReports.Web.Handlers.RpxHandler” resourceType=”Unspecified” requireAccess=”Script” />
      <add name=”ActiveReports WebCache Handler” path=”*.ArCacheItem” verb=”*” type=”DataDynamics.ActiveReports.Web.Handlers.WebCacheAccessHandler” resourceType=”Unspecified” requireAccess=”Script” />
      <add name=”ActiveReports Compiled Report Handler” path=”*.ActiveReport” verb=”*” type=”DataDynamics.ActiveReports.Web.Handlers.CompiledReportHandler” resourceType=”Unspecified” requireAccess=”Script” />
</handlers>

Commands and the Composite Application Library

I was asked once what Delegate Commands are. And I stumbled J. So finally decided to jot down this phenomena.

Simply put in MSDN terms, Commands are a way to handle user interface (UI) actions. They are a loosely coupled way to bind the UI to the logic that performs the action.

Where would these Commands apply then practically, you think? – In composite applications we have design patterns such as Model-View-Presenter (MVP), Model-View-Controller (MVC), and Model-View-ViewModel (MVVM). Because these design patterns are normally used to separate the UI layout and code/logic. Taking example of WPF, the presenter or controller handles commands outside the WPF logical tree. To learn more about trees, visit this url http://msdn.microsoft.com/en-us/library/ms753391.aspx.

WPF routed commands deliver objects or messages within the tree and even require a command handler in the code behind to access them. But with Composite Application Library we get two commands that can be routed outside the WPF logical tree and do not require the handlers in code behind. These commands are DelegateCommand and CompositeCommand. These commands are custom implementations of ICommand interface defined by WPF and have their own routing mechanism to communicate with objects outside the logical tree.

DelegateCommand: it allows delegation of invoking a target handling method.

CompositeCommand: it has multiple child commands. Is better used in scenarios where you have a view with multiple rows having their own submit or delete button functionality and you would prefer running a selected event on the rows in one go.

My favorite question on commands would be: – (taken AS IS from MSDN)

Why are WPF routed commands not used?
WPF routed commands have a number of limitations. They are coupled to elements in the logical tree because they use routed events to deliver the command messages. This means you cannot directly connect a separate class, such as a presentation model, presenter, or controller, to be the direct command handler. The view would have to be the routed command handler, and it would have to forward the call to the presenter or controller through a method call or event. Additionally, the command handler that the routed event is delivered to is determined by the current focus in the UI. This works fine if the command handler is at the window level, because the window is always in the focus tree of the currently focused element, so it gets called for command messages. However, it does not work for child views who have their own command handlers unless they have the focus at the time. Finally, only one command handler is ever consulted with routed commands. After one command handler is invoked (for CanExecute or Execute), no other handlers are consulted, even if they are in the focus tree of the focused element. For scenarios where multiple views (or their presenters) need to handle the command, there is no decoupled way to address it with routed commands.

Journey to MCTS 70-515: Lesson 5 – Themes

Developer Featured Image
Precedence

If you use the StyleSheetTheme attribute, settings can be overridden because properties defined by StyleSheetTheme are applied before a page’s control property set. If you use the Theme attribute, settings cannot be overridden because properties defined by Theme are applied after a page’s properties.

Applying themes take precedence in the following order: -

  1. @ Page directive theme attributes
  2. Web.config <pages Theme=themeName”>
  3. Control attributes
  4. @ Page directive StyleSheetTheme attributes
  5. Web.config <pages StyleSheetTheme=”themeName”>

 

To enable or disable themes in an ASP.NET page the following code directive can be used,

<%@ Page EnableTheming=”false” %>

Skins

A skin file differs from a style sheet in that the skin file uses the attributes of the actual control and not just a set of standard HTML style elements. In addition, skin files will be applied at the control level automatically by ASP.NET. Style elements, on the other hand, can be applied automatically only to HTML items. For ASP.NET controls, you must set the style class manually in your markup code.

Skin files can have two types of skins:

  • Default skins
    A default skin automatically applies to all controls of the same type when a theme is applied to a page. A skin is considered a default skin if it does not have a SkinID attribute.
  • Named skins
    A named skin is a control skin with a SkinID property set to a specific name value. To apply a named skin to a control set the ASP.NET control’s SkinID property.

 Actual Scenario: -

Question 1:

 An ASP.NET application has a default.skin file. All buttons within the application use the default style. If you wanted a help button to have a different style, how could that be done?

a)      Add <asp:Button ID=”Info” /> to the default.skin file
b)      Add <asp:Button ID=”Info” /> to the Signup.aspx page
c)       Add <asp:Button ID=”Help” /> to the default.skin file
d)      Add <asp:Button ID=”Help” /> to the Signup.aspx file
e)      Add <asp:Button SkinID=”Info” /> to the default.skin file
f)       Add <asp:Button SkinID=”Help” /> to the Signup.aspx page

Disable Browser Cache on ASP.NET webpage

How to make sure secured pages do not appear after Logoff in a ASP.NET web application

It’s very annoying when you hit back button in the browser and the ASP.NET web page displays a cached result instead of refreshing itself.

To force the browser not to cache the ASP.NET web page you need to add this line to the Page_Load event in order to disable browser caching.

Response.Cache.SetCacheability(HttpCacheability.NoCache)
Follow

Get every new post delivered to your Inbox.