Home Contact

O(geek)

Running in time proportional to Geek.

News

Archives

Post Categories

Syndication:

SharePoint RSS Reader – Authenticated Feeds

If you are trying to setup a blog in SharePoint and want to aggregate its feed to a parent site, you’ll find that if you’re using NTLM you’ll get the following error:

The RSS webpart does not support authenticated feeds

This seems frustrating at first as you begin to wonder why you can create a blog, add RSS feed viewers, but can’t combine the two.  Basically this appears to come down to an authentication issue, and NTLM’s lack of ability to delegate credentials.  The solution:  Kerberos, and what appears to be a very simple solution at that. 

Basically just change the default Authentication Provider in SharePoint Central admin to Negotiate (Kerberos), use SetSPN to register an SPN for your App Pool account on your domain controller and allow that App Pool account to delegate through “trusted through delegation.”

More details on this can be found at:

Mark Arend: RSS Viewer web part and authenticated feeds

The referenced MSDN article from the above with more details on the setspn is at (4th question):

Credentials and Delegation

The download for the setspn tool for Server 2003 is at:

Windows Server 2003 Service Pack 1 32-bit Support Tools


SSL Host Headers

In case you happen to be needing to do host headers with a wildcard SSL Certificate, here is the article from Microsoft on how to do it in IIS 6:

http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/596b9108-b1a7-494d-885d-f8941b07554c.mspx?mfr=true

The basic command line call is:

cscript.exe adsutil.vbs set /w3svc/<site identifier>/SecureBindings ":443:<host header>"

Where <site identifier> is the numeric identifier displayed in IIS, and <host header> is the header you’re trying to capture for the given site. 

Also for reference, the full path to:

cscript.exe  is c:\windows\cscript.exe

adsutil.vbs is c:\inetpub\adminscripts\adsutil.vbs


SSRS Global Variable "Trick"

We are working through a beta release of an internal project so I'm getting a chance to solve many different problems right now.  Today I had to update a report that has an issue where its count at the bottom was displaying the total number or records instead of just those that were visible. 

Basically this is a report of applicants who have passed all tests during a job recruitment process.  If they fail any step then they shouldn't show on the list.  I did some tricks with the data of the report to check to see if the failed any test and hide a rectangle if they have.  This formula used a few aggregates to get the job done.  Of course anyone who's used SSRS 2005 knows you can't do aggregates of aggregates, so that makes getting the count at the bottom much more difficult. 

The trick I used was to create a "global" variable in the code of the report.  I wrapped that variable in a Function that looked like:

public dim passedCount as int32 = 0

public function IncreasePassedCount(a as boolean, b as boolean) as boolean
    if a or b then
        return true
    end if

    passedCount = passedCount + 1
    return false

end function

a and b are flags that specify whether or not there was a failure, since there's 2 possible ways an applicant could fail on a given row.  If they have failed then we return true (so that way hidden = true, somewhat counter intuitive for web and windows programmers).  Otherwise they have passed everything and we want to keep everything visible.

This code is then called via the Visibility expression on the rectangle that holds all the data.  That expression looks like:

=Code.IncreasePassedCount(
Sum(Fields!PassedByScore.Value) <> Count(Fields!TestScoreId.Value),
Sum(Fields!PassedByFlag.Value) <> Count(Fields!TestScoreId.Value))

The IncreasePassedCount function serves double duty for me; a. it increases the passedCount variable as needed b. it returns a boolean to hide or show the rectangle.  This way I can guarantee my code is being called only when it needs to be to increase my counter.  If you try to call this method in an IIF statement the method always seems to get called, even when it is only in the true or only the false clause.  I'm guessing this is just how SSRS resolves its code behind. 

Now with that in place I have a very simple text box that has my total count, now based on what's visible not on all the records.

=Code.passedCount

DataGridView DropDown Column Index -1 Exception

In developing one of our new applications I ran into an interesting issue with the DataGridView, which contained a DropDown (ComboBox) column that was bound to a different BindingSource.  The basic issue is that the user would click a LinkButton and select a file.  That process would create a new instance of an object on the backend, which would be added to a list that was then bound to the DataGridView.  The drop down option on this new item would be left null however.  When the user would go to click the drop down to make a selection, they would receive the following exception:

System.IndexOutOfRangeException: Index -1 does not have a value. at
System.Windows.Forms.CurrencyManager.get_Item(Int32 index) at
System.Windows.Forms.DataGridView.DataGridViewDataConnection.OnRowEnter
(DataGridViewCellEventArgs e) at System.Windows.Forms.DataGridView.OnRowEnter(DataGridViewCell&
dataGridViewCell, Int32 columnIndex, Int32 rowIndex, Boolean canCreateNewRow, Boolean
validationFailureOccurred) at System.Windows.Forms.DataGridView.SetCurrentCellAddressCore(Int32
columnIndex, Int32 rowIndex, Boolean setAnchorCellAddress, Boolean validateCurrentCell, Boolean
throughMouseClick) at System.Windows.Forms.DataGridView.OnCellMouseDown(HitTestInfo hti, Boolean
isShiftDown, Boolean isControlDown) at System.Windows.Forms.DataGridView.OnCellMouseDown
(DataGridViewCellMouseEventArgs e) at System.Windows.Forms.DataGridView.OnMouseDown
(MouseEventArgs e) at System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button,
Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at
System.Windows.Forms.DataGridView.WndProc(Message& m) at
System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at
System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

This really didn't seem to make any sense.  We had done this many times before and it worked perfectly fine, it was just this specific code that was causing an issue.  The code at issue was the following:

recruitmentBindingSource.DataSource = recruitments;

dataGridViewAttachments.DataSource = null;
dataGridViewAttachments.DataSource = attachments;

The recruitmentBindingSource was used for the drop down, and the gridview was where our problem was.  Well it turns out the 2nd line where we set the DataSource of the gridview to null was the source of the exception.  We had placed that line in there to force the gridview to refresh its display data.  We were updating that attachments list in a service, and the one way to make the gridview refresh is to set its DataSource to null, then to the object you want to work with.  Well this appears to cause more problems than its worth!  (Especially since I closed another issue today that was being caused by this null "refresh hack.") 

After doing a little research I came across the following code, namely the ResetBindings(), which appears to be just what the doctor ordered in this case.  I hadn't used this method again, since I ran into issues with it a few months back on non-datagridview controls, but for gridviews that call seems to refresh the data nicely and force the grid to reread the data in the object collection.  The new code that resolves this issue now looks like:

recruitmentBindingSource.DataSource = recruitments;
recruitmentBindingSource.ResetBindings(false);

attachmentBindingSource.ResetBindings(false);
attachmentBindingSource.DataSource = attachments;
dataGridViewAttachments.DataSource = attachmentBindingSource;

Notice I've changed the gridview to now use a BindingSource rather than directly binding to my list collection. 


The case of the disappearing ibeam cursor

I've been setting up and configuring my brand new Toshiba M700 TabletPC, a very nice upgrade from the M200, though lacking in screen resolution.  The main reason I went for a larger Tablet was for the performance to run Virtual PC images.  This was great until I noticed that the ibeam cursor in all of my virtual machines would disappear.  This is extremely disconcerting especially since most of my work is in Visual Studio, where guess what, there is an editor that displays the ibeam cursor.  Not good.

This issue appears for me on a variety of guest operating systems (Server 2003, Vista) using Virtual PC 2007 SP1 on a Vista Ultimate host.  I don't know if it is a Virtual PC issue specifically or a combined problem between bugs in video card drivers and an issue in Virtual PC itself.  I can take the exact same virtual image and put it on another computer and run it with no issue at all.  So there is definitely something with the combination of hardware and software causing the problem. 

I spent most of the morning on this issue and finally found a satisfactory resolution for my specific case.  Bottom line, if you run an M700 with the "Mobile Intel 965 Express Chipset Family" adapter "Mobile Intel GMA X3100" mosey on over to Intel's web site and download the latest video card drivers.  The version that comes with the M700 and is available "officially" from the Toshiba site is:  7.15.10.1272.  Intel however has a newer version: 7.15.10.1472.  There are some tricks to getting it installed since this is an Intel release and not supported by Toshiba, but here is a link to a forum with all the info you need:

Toshiba M700 - Video Driver Update

  1. Basically download the latest zipped drivers from:  Mobile Intel® 965 Express Chipset Family
  2. Extract the zip files to your tablet
  3. Manually update the driver following similar instructions to:  Intel Manual Driver Install  Note that you may have to select the option to "List Available Drivers", and then select "Have Disk" on Vista, otherwise it'll just tell you that the latest drivers are already installed. 

After you reboot you'll get a series of requests to run .exe's.  This is because they were downloaded from the web.  Track each one that prompts to be run.  Copy those .exe's from the system32 folder, unblock them (Properties -> Unblock), and then copy them back into the system32 folder.

 

For those running a different piece of hardware or can't upgrade their driver for whatever reason here are some other workaround suggestions to getting the problem temporarily fixed:

Disappearing Cursors in Virtual PC

These all are workaround and don't really solve the core problem. 

SharePoint Template Learning

I sat through a session by Heather Solomon at TechEd 2008 where she talked about creating custom templates for SharePoint 2007, something that definitely isn't a quick weekend project.  She has some great resources to get started on that process.

  • CSS Reference Chart for SharePoint 2007 - This is an amazingly detailed drill down into all the CSS options that are available for use in SharePoint.  What's even better is she includes screen shots for where each CSS style gets applied.
  • Minimal or Base Master Pages - As she described in her session, many of the content panes are a required part of any SharePoint template even if you're not going to use them.  Here she provides the bare minimum required for any template.  One important thing is that you can place unused content panes into a panel that has its visibility set to hidden.

Both of these also applies in various forms to WSS 3.0.

Office 2007 documents on TFS 2005 WSS 2.0 Team Site

I'm sure a few people want to get their Office 2007 documents into WSS 2.0, especially anyone using TFS 2005.  I found a great article that steps you through the process of helping WSS understand the document types associated with Office 2007:

How to get Companyweb (Windows SharePoint Services v2) to work with Office 2007

Windows Server 2003 .NET clr20r3 Error

This is more for personal reference, but also just in case anyone else sees the error from the event log below.  This appears to be a catch all exception for a variety of different problems that might occur in a .NET app running on Server 2003.  The application in question is a .NET 3.5 application, and would just not start when copied to 2003.  The running exe would disappear from Taskman and be replaced by DW20.exe (Dr. Watson), which would place the following error into the event log.

Event Type:    Error
Event Source:    .NET Runtime 2.0 Error Reporting
Event Category:    None
Event ID:    5000
Date:        6/17/2008
Time:        7:43:36 AM
User:        N/A
Computer:    PATS
Description:
EventType clr20r3, P1 pats.exe, P2 1.0.0.0, P3 48585526, P4 infrastructure.library, P5 1.0.0.0, P6 4856e351, P7 54, P8 3b, P9 lekhqnpdiyzpb1zxlxqlmnyaxftzwyry, P10 NIL.

A few things to remember when seeing this:

  • Ensure all related DLLs are either in the GAC or bin directory of the given application.  This can happen when there is a failure to load a DLL.  You can use Filemon to see if there are any file not found errors during start.  In my case I had some DLLs from Infragistics that weren't being copied to the bin directory.
  • Reboot after installing .NET 3.5.  If you are starting on a clean image or PC, I have seen this issue crop up if there hasn't been a reboot on the machine after the installation of the .NET Framework.  Note that 3.5 installs 2.0 SP1 and 3.0 SP1 at the same time it installs itself.
  • Finally the error specific to my case, is the wrong database server was setup in the connection string in the app.config.  Why this caused a generic error like this rather than an exception I'm not 100% sure.  But check the connection string if there's data being loaded on startup.

IssueVision Scrolling Problem

I ran across this following bug on WindowsForms.com, while having the same *exact* issue in a control I had created for an app.  This was posted by SteveOrr:

http://www.windowsforms.com/Forums/ShowPost.aspx?tabIndex=1&tabId=41&PostID=23285

1) Start IssueVision
2) in the middle pane select the top item in the second "Computer" group.
3) Then click on the last item in the above group "Telecommunications."
Notice you'll see the list "jump" and draw the Telecommunications group starting at the top, when the top of that section had scrolled off the screen.
It is disorienting to the user for their selection to be moved to a new location when they click on it.

Worse, if you adjust the data so that there is more than a full screen's worth of data in the top "Telecommunications" group and then follow the above instructions then the item you select will be scrolled completely off the screen as soon as you select it.
This is an unacceptable user experience.

I've looked all through the code trying to fix this bug, but I find no references to any scrollbars or anything else that looks like it would be helpful to keep the list from auto-scrolling.

Does anyone have any idea why this is happening or how to fix it?

 

This was my response:

I was about to post yesterday that I was having the same problem.  We've use the IssueList as a base for a listview we've created and had the same exact issue in our control.  It was getting really frustrating because most cases we only had one group and would have 100 - 200 items in that group.  So the you would scroll to the bottom 200 items down and then click, of course the view would jump right back to the top. 

I think we've found a solution here to this problem.  It has to do when you click on a different section control.  That control becomes active.  When the active control changes and the AutoScroll is set to true it looks like a series of internal work happens that looks for the Top,Left point of the new active control.  Of course this doesn't always work well for this IssueVision control, because the Top/Left corner of the Section Control could be hundreds or thousands of pixels away from the item we just selected. 

To fix the prob. we ended up settling on making sure the control just didn't scroll at all when the active control changed.  This looks like the same behavior Outlook has.  To do this just add the following lines of code to the IssueList, or prob the ExpandableList:

protected override Point ScrollToControl(Control activeControl)
{
    return this.AutoScrollPosition;
}

It looks like that protected method is called each time the active control changes, and requests a new position to scroll to.  Rather than scrolling to the top/left of the control (which if you use Reflector you'll see the base class method does essentially), you can move to any point you wish.  We just decided to use the last scroll position so nothing moves. 

 

I couldn't find anything on Google about the issue, so hopefully this will get out there and help anyone else who has a similar issue.  Not knowing the nitty gritty details of the ScrollableControl base class it took a while to figure this out. 


Menustrip & Toolstrip Redux

Since the question came up in the comments for my first Menustrip & Toolstrip entry, I went ahead and wrapped up the Menustrip project.  You can now download it here. 

The solution was written and built in the May 2004 CTP released at TechEd 2004, build 40426.16.  I won't come near claiming that this is “good” code, other than it does what I set out to do.  So feel free to drop any suggestions. 


MenuStrip & ToolStrip

After watching Joe Stegman's DEV260 overview of Windows Forms “2.0” I was fascinated by the new MenuStrip and ToolStrip controls.  I love the fact that MS is giving us access to controls that will have a very similar look and feel, by default, to the current MS applications.  What's even better is these new strips can use a custom renderer to create your own look and feel.  That means when Office v.next comes out we'll immeidately be able to update our own look and feel to match the new UI. 

I've included a sample of an Xbox theme I hacked together just to get a basic feel for creating a custom renderer.  I'm sure I'm far off best practices, but I'm happy to get this working for a start. 

The following code you'll need in your Form with the ToolStrip and MenuStrip objects. 

            MyRenderer rend = new MyRenderer();
            ToolStripManager.Renderer = rend;
            toolStrip1.Renderer = rend;
            menuStrip1.Renderer = rend;

The important thing to note in this code is the ToolStripManager.Renderer = rend;  line.  This seems to be the key to having the OnRenderRaftingContainerBackground event called in your customer renderer.  Without it you'll end up with a rafting container that is blue or the system colors.  (The rafting container I've picked up is the object under the MenuStrip and ToolStrip that tie things together.  This is pretty much the area no drawn over by the strips.) 

Unfortunately, at least to me, this seems a little unintuitive.  I was expecting to be able to set a Renderer property on the instance of the RaftingContainer object.  Instead there is this static property that gets set.  I'm sure there is something under the hood I don't understand yet that has led to this implementation. 

The next piece is inheriting from ToolStripRenderer to create your own renderer.  I've included below a sample of one of the more interesting events that is fired.  This is the code that implements the drawing of the greenish yellow gradient when the user hovers over a toolbar button with the mouse, and clicks on a button.

        //The drawing that happens on the background of the button.
        protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e)
        {
            base.OnRenderButtonBackground(e);

            Graphics g = e.Graphics;
           
            //if the mouse is over the given buttin
            if (e.Item.Selected)
            {
                //if the mouse has been pressed on the button,
                //
we want to make the colors a little
                //darker so the user knows something happened.
                if (e.Item.Pressed)
                {
                    using (LinearGradientBrush b = new LinearGradientBrush(new Rectangle(0, 0, e.Item.Bounds.Width, e.Item.Bounds.Height), Color.FromArgb(Color.Yellow.R, Color.Yellow.G, Color.Yellow.B + 50), Color.DarkGreen, 90))
                    {
                        g.FillRectangle(b, new Rectangle(0, 0, e.Item.Bounds.Width, e.Item.Bounds.Height));
                    }
                }
                //draw the case when the mouse is just hovering. 
                else
                {
                    using (LinearGradientBrush b = new LinearGradientBrush(new Rectangle(0, 0, e.Item.Bounds.Width, e.Item.Bounds.Height), Color.Yellow, Color.Green, 90))
                    {
                        g.FillRectangle(b, new Rectangle(0, 0, e.Item.Bounds.Width, e.Item.Bounds.Height));
                    }
                }
            }
        }

Hopefully this will get a few people started writing custom renderers.  I was really surprised at how easy it is to write one.  Please feel free to let me know what you think.  I'm learning as I go, so I'm sure there are some places that I can definitely learn a litle more.

BTW this was built and runs on Visual Studio 2005 CTP May, the version released at TechEd and on MSDN at the same time. 


Want to know where Windows Forms 2.0 is at?

Now this is some good transparency-like information:  Feature Status in Windows Form in Visual Studio 2005.  Thanks to Chris Sells for the original link.  (Be sure to check that out for lots of cool VS 2005 info, including the new Express release betas.)

After reading through the status list I saw: 

Rafting Poor

That explains pretty quickly why there are some weird issues with docking of ToolStrips and MenuStrips in the CTP of VS 2005.  If you just draw the rafting container background and move the toolstrip around you'll end up with the regular old blue gradient background, not your cool custom rendered background. 

(BTW don't try dragging the ToolStrip around in the code I just released for the CustomRenderer, there is definitely a bug there that crashes the app.)

Also I'm not sure if the MenuStrips are supposed to be dockable, but at this point they stay achored to the top.  Not that I necessarily think draggable menu's are great from a usability perspective, especially to new users, but it's something not there.

I have to say good job to MS for adding this piece of info out on the web.  Helps to give us a much clearer picture of the state of different areas of VS 2005. 


Cool XmlSerializer Features

Tim Ewald is back to blogging with a great new article:  XmlSerializer sans XSD

After recently playing with the XML Serialization attributes on classes for a project in InfoPath, this article hits perfectly to show you how to create classes based on an existing XML File.  For my project in InfoPath I pretty much worked the opposite way and created a class with the attributes to be serialized down through a web service.  The Invoicing sample with the InfoPath SDK gives a great example of this.  I was absolutely amazed at how easy it was to point to a web service, pull down my class schema, build an InfoPath form, and shove it back up to the server without ever needing to touch XML other than the attributes.  Now it is very cool to see that it is just as easy working the opposite direction, when you are given an existing XML file like an RSS feed. 

The more I work with .NET the more I'm amazed at all the features there are. 


Microsoft Security Summit

Just got back this evening from the Microsoft Security Summit in Anaheim.  Once again Microsoft had some great content and presenters.  I'm amazed that they had an entirely free event that included breakfast and lunch!  While not the quality of TechEd, it was certainly on par with the $75 DevDays we attended in LA. 

My one grip about the day though was that all of the content was a virtual repeat of a previous MSDN security event at a local movie theater.  While the information was definitely good, it would have been nice to have a little warning that the content was going to be reused, and the same exact slide decks shown.  It was nice to have Michele Leroux Bustamante (the San Deigo area RD) use her own demos for the 4th presentation.  Even though she ran out of time there was some great content in what she showed. 

I don't know if there's any way that Microsoft could provide a little better information on what is coming.  I might have known by reading the session absctracts a little better too.  It is always good to see another perspective on the same content though, as each presenter highlights what they see as important. 

Console.WriteLine("Hello World!");

As has become customary in the blogsphere here is my introductory post giving you a little background for the future posts on O(geek).

I am a software developer working for a local city government for a city of about 37,000 residents.  We do all of our new projects in .NET, and have been using the platform since .NET 1.0 went RTM February of 2002.  Of course an MSDN subscription was in order at that time so we could download the release bits ASAP, instead of the terribly long wait for CD's. 

I began my programming career in High School, learning, as most programmers do, BASIC using Microsoft QBasic.  Luckily I also learned at the time Visual Basic 3.0 was around, so I could take that new knowledge directly to the Windows world.  The first “big” application I wrote was with a friend, where, in Asteriods style, the user was an IBM PC that was required to fend off the invasion of Apple Machintosh computers.  This game was of course simply another jab at our friends who actually used Apple computers in the 90's. 

The Apple vs. IBM rivalry kept us quite entertained at lunch each day.  Of course the favorite discussion was the relative merits of OS/2 and Windows NT with theit preemptive multitasking, protected memory and 32-bit architectures, and how this compare to the Mac OS at the time.  This was also the era of the Windows 95 launch, and while we did attempt to argue for the new operating system, some of the obvious “features” of this platform didn't typically help in the discussion.  Amazingly I really did have a laptop at this time with OS/2 installed for a quick jaunt into IBM's interesting world.

Those were also the years of swearing never to own an Apple computer, while of course today I have a G5 and iBook surrounded by too many Windows based PC's.

As I have heard echoed may times on .NET Rocks I have to say I absolutely love .NET.  As a former ASP developer ASP.NET has revolutionized my day to day work.  Windows Forms have given an amazingly clean and highly productive API.  (I was one of the brave...or stupid who tried to learn C++ and MFC at the same time.  Hungarian notation for al its merits during that time is confusing as hell for a beginning programmer.  lpszptrobjlbltxtMyVariable, means what?!?  Not that MFC was all that clear to someone who didn't quite grasp OO concepts.)  It is very refreshing to have an easy to use, powerful, and object oriented platform on which to build new applications. 

Hopefully this will be my resting place for a while.  I started a blog on Blogger before TechEd, only to realize Google dropped support for RSS.  I also have done the moblog thing for TechEd with pictures from a Canon S410.  .Text should give me what I need for a while, now just to get the oofgeek.com domain name pointed to this new blog. 

Also wanted to give a *big* thanks to Jeff Julian for running this site.  It's nice to have a .Text blog available and for such an amazing price!