NSilverBullet

Complex solutions for simple problems.

  • Posts in category: Net

Talk on Migrating ASP.NET 1.x to ASP.NET 2.0 at DevDays 2006


Thursday 07 December, 2006 (.Net | Speaking | Tips | Web)

A couple of days ago I did my first big talk, a colleague and I held a 50 minute session on migrating from ASP.NET 1.x to ASP.NET 2.0 at DevDays 2006 in Stockholm. Luckily it was a big success! I credit our success almost entirely (obviously we had some part in it...) to Scott Hanselman, we found many tips and links on the topic of public speaking on Scott's blog. The most important tip and what we worked on most was "be prepared", we studied our subject vigorously the days before, preparing for any questions that the audience might ask. We also practised our talk, including all the demos, about 6 or 7 times to get the timing right and just feel confident with the content.

In order to Google-boost these great resources and to make it easier for myself to find them again I list them here:
http://www.hanselman.com/blog/content/radiostories/2003/01/22/scottHanselmansTipsForASuccessfulMsftPresentation.html
http://www.hanselman.com/blog/PresentationTipsPPT.aspx
http://www.hanselman.com/blog/PowerPointTipsBeyondBullets.aspx
http://www.toastmasters.org/pdfs/top10.pdf
http://sociablemedia.typepad.com/beyond_bullets/
http://www.venkatarangan.com/blog/PermaLink.aspx?guid=dab57735-2976-40d7-a5d0-2e641ddea515
http://www.presentationzen.com/
http://www.hanselman.com/blog/InSearchOfThePerfectMonospacedProgrammersFontInconsolata.aspx
http://www.hanselman.com/blog/ReadySetVSNETChrisKinsmanAHrefhttpwww.aspx
http://www.hanselman.com/blog/PresentationTipsForPeopleRunningVirtualPCOrVMWare.aspx
http://www.hanselman.com/tools

Comments [0]


Migrating Asp.Net 1.1 to .Net 2.0 - DevDays 2006


Wednesday 29 November, 2006 (.Net | Speaking | Web)

I will be speaking at DevDays 2006 here in Sweden next week on the topic of migrating Asp.Net 1.1 applications to Asp.Net 2.0. It is an interesting topic especially when you really start looking under the covers at what has changed at a lower level. The whole session will be recorded and may be made publicly available at a later date.

For anyone else who is interested in this topic these are some of the resources I have used for my presentation:
What's New in ASP.NET
ASP.NET 2.0 Internals
Codebehind and Compilation in ASP.NET 2.0
Master Pages in ASP.NET 2.0
Understanding Page Inheritance in ASP.NET 2.0
Migrating from ASP.NET 1.1 to ASP.NET 2.0

Comments [0]


Messing with dasBlog content folder


Tuesday 28 November, 2006 (.Net | Bugs | dasBlog)

Basically avoid changing the xml files under content for dasBlog, you will mess up your blog. I did this in an attempt to make a post that I started on the 7th but posted on the 8th go back to being on the 7th... First I just changed the CreatedDate in the content xml and this almost worked, the post would intermittently disappear from the site (and the file). Luckily I had made a backup of the content files before I did this so I could just put the post back up when it disappeared. I quickly realised that this was a suboptimal solution! So I moved the post over to a new file with the correct date in the name. This file was eaten up by dasBlog and mysteriously disappeared, although I didn't notice it for about a week. What had happened was that I had got the date for the outer element set to another day in conflict with another file. So dasBlog just kicked it. Once I had got the date right it still took several updates for the change to propagate. Now I hope I have saved all my posts!

Comments [0]


Two Minute Timer Update


Friday 24 November, 2006 (.Net | GTD)

I found a couple of other Two Minute Timers:
http://www.avesh.com/blog/TwoMinuteTimer.aspx
http://blog.brettkelly.org/?p=215

On lifehacker there is a reference to an article about beating procrastination, this is something that I have a problem with so I am going to try it out: Just start doing it but only do it for 10 minutes. After that decide if you want to continue or not. With this in mind I have released a new version of my timer with a 10 minute option...

I have deployed this as a ClickOnce application now so you can get automatic updates if you want. The new version is 0.2.2

Features:
Customisable opacity.
Tray icon.
Start a 2 or 10 minute timer from a context menu.

System requirements:
Windows 2000, XP (probably 2003 Server also but not tested)
.Net 2 (the install should download .Net 2 if you don't have it)

Planned features:
Customisable alarm behaviour (flash window, system sounds, audio files).
Custom count-down enter hour, minute, seconds.
Autostart up on login option

Download now


Comments [0]


GTD two minute timer


Wednesday 22 November, 2006 (.Net | GTD | Office)

I have been trying to use David Allen's GTD (Getting Things Done) technique over the last few weeks to better manage my time at work and at home. I have used OneNote extensively and Microsoft's FolderShare to synchronise notes between home and work. One of the things in GTD is to perform any action that needs to be done and can be completed in less than two minute immediately so as to not clutter up your brain and or task store him lots of stuff that take next to no time to complete. The theory is that tracking them takes more time than just doing it.

To help me with this I have created a small two minute timer in .Net 2. You can download it here.

Just run the exe to start the application and it will place itself in your tray.
Two minute timer in tray

Double click on the icon and the timer will start.
Two mminute timer running

This is the first version and it is not very polished but it does work. I am planning on adding a few small additional features in the future like customised alarm sounds and a nicer skin.

Update: There is a newer version available here.

Comments [0]


Upgrading Team Foundation Server to WSS 3


Wednesday 15 November, 2006 (.Net | SharePoint | Team System)

Unfortunately it will not be possible to upgrade Team Foundation Server to Windows SharePoint Services 3 when it is released, see Jason Bariles blog for more info. This feature will not be added in the upcoming Service Pack (SP1) either. So for the time being we will all just have to make do with WSS 2 features and add any additional functionality that we need through TFS extensibility and custom SharePoint features. :'(

Comments [0]


First shot at fixing dasBlog medium trust issues


Tuesday 14 November, 2006 (.Net | AJAX | Blogging | Bugs | dasBlog | Fixes)

So far I have managed to get my dasBlog up and running. But in doing so I have disabled and broken several features:

  • No HttpCompression
  • No date picker while editing
  • No Pingback/trackback support

It seems that I have also broken my FreeTextBox editing control. I believe that this may be an unrelated issue to the medium trust fixes and wont get into that in this post.

How could I get the broken features back up again? The strong naming issues that affect SharpZipLib and BasicDatePicker are easy to fix since there is a new free version of BasicDatePicker available BasicDatePicker Lite, the new version is not strong named and may require you to recompile dasBlog. SharpZipLib is open source so you can download it and add:

using System.Security;
[assembly:AllowPartiallyTrustedCallers]

to assemblyinfo.cs then just recompile and these functions should be up and running again, you may have to install SharpDevelop to compile the code for SharpZipLib. Any changes that were made to web.config or aspx pages to disable the functions need to be reverted and recompiled. Your web.config will need to be updated with a new version for SharpZipLib:

<dependentAssembly>
<assemblyI entity name="ICSharpCode.SharpZipLib" publicKeyToken="1b03e6acf1164f73" culture="neutral"/>
<bindingReirect oldVersion="0.5.0.0-0.84.0.0" newVersion="0.85.0.0"/>
</dependentAssembly>

After doing this I received an "Invalid use of response filter" exception (more info at dasBlog.us) which turns out to be because my host already implements httpCompression, but disabling the blowery handler sorted it out.

TrackBack support

The main problems that remain are getting TrackBack and PingBack support. I will start by looking at getting TrackBacks working. The problem with TrackBacks is that they require dasBlog to call a web page on another site and network access to other servers is not allowed by default under medium trust so this jut won't work. I checked the TrackBack protocol to see if I could find any workarounds that could be applied. Reading the spec I realised that TrackBacks do not require the call to originate from the server that hosts the blog, if we could implement this as a client call then we could theoretically allow TrackBacks under medium trust.

I started by implementing a very simple html page to post a trackback call to localhost.

<html><body>
  <
form method=post action=http://localhost/Trackback.aspx?guid=3d9f45e4... enctype="application/x-www-form-urlencoded;charset=utf-8">
    <
input type="hidden" name="title" value="SuperTrackback 1" />
    <
input type="hidden" name="excerpt" value="This is a vlient trackback call." />
    <
input type="hidden" name="url" value=http://localhost/Trackback.aspx?guid=dc205699... />
    <
input type="hidden" name="blog_name" value="TestBlogger" />
    <
input type=submit name="doit" value=1>
  </
form>
</
body></html>

I have hardcoded the trackback urls just for testing. Of course it was not as easy as just posting the call since dasBlog includes spammer protection by checking the url in the trackback call. We have to disable spammer protection by checking if we can call the url at runtime in TrackBackHandler.cs (added lines are bold) .

Entry entry = dataService.GetEntry( entryId );
if ( entry != null )
{
System.Net.WebPermission urlPermission =
new WebPermission(System.Net.NetworkAccess.Connect,url);
if
(System.Security.SecurityManager.IsGranted(urlPermission))
{
try
{
string requestBody = null;
// see if this is a spammer
HttpWebRequest webRequest = WebRequest.Create(url) as HttpWebRequest;
webRequest.Method="GET";
webRequest.UserAgent = Utils.GetUserAgent();
...
...
}
catch
{
// trackback url is not even alive
logService.AddEvent(new EventDataItem(
EventCodes.TrackbackBlocked,
context.Request.UserHostAddress + " because the server did not return a valid response",
Utils.GetPermaLinkUrl(entryId),
url,
entry.Title
));
context.Response.StatusCode = 404;
context.Response.End();
return;
}
}
// if we've gotten this far, the trackback is real and valid
Tracking t = new Tracking();
t.PermaLink = url;
t.RefererBlogName = blog_name;
t.RefererExcerpt = excerpt;

This allows an anonymous caller to add a TrackBack to our blog but it also enables incoming TrackBacks under medium trust. This is only half of the solution for TrackBacks; we have opened up dasBlog för incoming calls to our TrackBackHandler but we still have to make calls to remote trackback urls. The next step would be to implement initiate a client-side trackback call to a remote server from inside dasBlog, this can be done in an AJAX (or is it Ajaxian) manner using XMLHttpRequest in JavaScript http://developer.mozilla.org/en/docs/AJAX:Getting_Started. I will cover this and tackling the spammer threat in future posts, since I haven't implemented a solution yet.

Comments [2]


ARC201 – Patterns and Anti-Patterns for Service-Oriented Architecture (SOA)


Wednesday 08 November, 2006 (.Net | TechEd 2006 | SOA)

I can only say wow! Ron Jacobs is a brilliant speaker, entertaining and very informed, an expert to say the least. A couple of his insights into SOA and what he things works and doesn’t work for SOA were real eye openers for me. Not because I didn’t understand the principles behind SOA or the problems with implementing SOA but because I do understand SOA and I realise it isn’t just about choosing the right technology and then claiming that we are service-oriented!

I will try and compress some of what he said in a short list, mainly to remind myself of this from time to time:

  • Don’t loosely couple everywhere: tightly coupled components and services have a place in our architecture too they just aren’t service-oriented in the SOA sense.
  • Rely on explicit behavior over implicit behavior: a service will do what the contract says it will. Just because it happens do something more right now (like ordering the returned data) doesn’t mean you should create a dependency on this implicit behavior.
  • Business Processes are a good starting point for identifying your services: is this performed as multiple business processes then it is probably multiple services.
  • Everything changes when we cross an external boundary: just like everything changes when we cross an international border in real life. Languages change, laws change, the weather, everything. But we should strive to make crossing the external boundaries as friction-free as possible.
  • Think about services like paper-based business processes: what does the paper form like look? That’s our message. Who do we send it to? That’s our service. What do we expect them to do with it? That’s our contract and policy.

Start with the business process:

  1. Decide on a process
  2. Decompose the process
  3. Create the contract
    a. Define the messages – messages define what we can do
    b. Define the operations – operations move the process from one state to another

If anyone who reads this has the opportunity to see Ron speak on this topic then don’t miss it. Here at Tech-Ed he will be holding the same session again on Friday.

Technorati tags:

Comments [0]


Windows SharePoint Services v3


Wednesday 08 November, 2006 (.Net | SharePoint | TechEd 2006)

WSS3 seems like a great upgrade from version 2. The whole programming model is becoming more in line with other programming models that Microsoft have. You can create custom event handlers for WSS3 relatively easily linking directly to the SP API to create new lists or manipulate existing data, customing metadata and list behavior seems really simple too. One addition that I haven’t seen demoed but that is possible now is creating WebParts and custom features for a single site without having to deploy your assembly to the GAC.

The parts of WSS3 that I have seen so far look like they are going to make life a lot easier for anyone who wants to create non-trivial SharePoint solutions. In addition to what we can all  there are a whole bunch of extra functionality already included with WSS3 like Blog and Wiki templates, which actually look like they could work. Although I think that the contrived examples that I saw Chris Bryant and Todd Bleeker demo could potentially put people off Wikis and Blogs altogether, anyone who has used these technologies in other situations will immediately see the potential in integrating this into SharePoint. Many of the customizations that I have been discussing with my colleagues for us to implement in our Team Foundation Server WSS would be a lot easier to implement with WSS3, unfortunately I have not seen an upgrade path from WSS2 to WSS3 for Team Foundation Server yet.

Technorati tags:

Comments [0]


First day at TechEd


Tuesday 07 November, 2006 (.Net | Ramblings | SharePoint | TechEd 2006)

My first day at TechEd is over, it actually feels like two days now that I think about it which is kinda weird.

I managed to sneak into the Super Early Bird priority seating for the Keynote, well I really didn't do much sneaking I just walked over and sat down but still... I am always amazed by the way Microsoft tries to sell their products to developers who are already convinced that Microsoft is the way to go. There was a lot of Vista and Sharepoint 2007 in the Keynote, nothing bad in that but the way the tools were demoed is just silly.

Speaker - "Look how easy it is to create a People-Near-Me function in a Windows Presentation Foundation application!" Click, Click, typing (inserts a 200 line snippet)

Speaker - "Now I just start my application again and all the functionality is embedded in my application, all we needed to do was enable the functionality."

Of course you only have to insert and enable functionality that you have a prewritten snippet for! I'm guessing it's a completely different story if you need to write all the code from scratch... I doubt that there is a 500 line InsertCustomBusinessLogic snippet included with Sharepoint 2007 or .Net 3.

Other than that I have enjoyed my first day, I especially enjoyed the last session with Todd Bleeker on Custom Sharepoint sites and features. Although the pace he went through the material at pretty much knocked me out but thats the way it's supposed to be at TechEd. I can read sales presentations at home, while I am here I wan't to see hardcore developer action!

Technorati tags:

Comments [0]


Running dasBlog as a partially trusted application


Tuesday 07 November, 2006 (.Net | Bugs | dasBlog | Fixes)

Since changeing web hosts I have not been able to get dasBlog running in the new environment. The host server is setup so that .Net code runs at medium trust level and won't allow me to override the trust settings. As anyone who has tried to get dasBlog to run at medium trust knows, it just isn't possible out of the box. To make life even more difficult Asp.Net returns an incomplete and ambiguous SecurityException:

Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

Exception Details: System.Security.SecurityException: Security error.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

The stack trace that is included provides no help in solving the problem and actually sent me on a wild goose chase trying to solve completely unrelated issues.

I have started to dig into this to try and see if I could find a quick fix for it with googles help. So far I haven't found a quick fix but I have found a few other things that may lead me to a solution... First of all I have seen a few forum posts and blogs referring to reflection used by serialization as part of the problem. But I have managed to get XmlSerialization to work without chainging the serializer or trust level of the application so it doesn't seem to be the XmlSerializer that is causing the exception. I changed the virtual directory settings on my local machine so that dasBlog runs under .Net 2, this provided me with a much clearer exception. dasBlog has a custom XmlTextReader called XmlNamespaceUpgradeReader which inherits fom XmlTextReader. The only problem is that XmlTextReader has a security demand for exicit inheritance permissions [PermissionSet(SecurityAction.InheritanceDemand, Unrestricted=true)]. Running under medium trust you don't have the required permissions. Changing all XmlNamespaceUpgradeReader  references to XmlTextReader allowed the deserialization of SiteConfig (and all other serialized data) to run.

The next problem was that even though the site serialization was working dasBlog stilled just returned a big fat exception. Another wild goose chase followed trying to solve new unrelated issues, but working on them gave me a flashback to a problem I solved a year or so ago while setting up NGallery on the same host. Calling strong named assemblies from partially trusted code can also be a show stopper if the signed assemblies don't allow partially trusted callers. Two assemblies in dasBlog cause this problem SharpZipLib which is used for HttpCompression and BasicFrame BasicDatePicker, neither are compiled with the AllowPartiallyTrutedCallers setting. Removing references to these solves the rest of the problems that I was experiencing. Unfortunately the fixes disable some functionality in dasBlog and may have unexpected effects on configurations other than mine.

I am planning on following up on this post with detailed instructions on implementing the fixes and maybe som attempts to restore full functionality.

References on the web that sort of showed me in the right direction:
http://choirulamri.or.id/archives/94
http://www.hanselman.com/blog/CommentView.aspx?guid=a7e58fa0-9390-4270-bab3-83ea2e969352
http://www.hanselman.com/blog/CommentView.aspx?guid=4dd4573a-1fee-4680-b28e-983271bd3ae8
http://www.jwerx.com/blog/CommentView,guid,31c5f741-3d52-46a3-beb5-b934dea73423.aspx
http://dasblog.us/viewtopic.php?p=761&sid=b87a704cc1fffacabcb0bfff2660aac9


Comments [0]


.Net 2 - DataTable internal index is corrupted


Friday 14 October, 2005 (.Net | Bugs | Fixes)

There seems to be a problem in how empty DataSets handle new rows in .Net 2, we received an exception with the message "DataTable internal index is corrupted".

Our realy simple solution is to call BeginLoadData before adding the new row and then EndLoadData afterwards. This fixed the problem for us, but the actual status of the bug can be found here:

http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=ecc665a5-d71a-4e08-ac42-f3c6c5d758e0

Comments [0]


Previous Page Page 2 of 3 in the Net category Next Page