Category: VS2008


Playing with new toys

Recently I’ve had the need to create a new website, to host various sets of media files (including pictures and videos). I’ve been wanting for a while to have a look as ASP.NET MVC, so this was a great opportunity.

I created a website (http://nhaslam.com/primus) and have uploaded it with a set of basic (basic as in, out of the box) templates.  It was an interesting experience creating a set of views to display images, and the main thing I found was  ‘Don’t over complicate things’. 

I also had to load some videos up there, and as there was going to be a fair amount of them (approx 2gb), and I didn’t really want them sitting on my hosting site (sucking bandwidth), I wanted to host them on my Amazon S3 account. Uploading them was easy with Cloudberry Explorer for S3.

Getting them to stream from Amazon was a little more complicated, but was helped by the mass of websites (Google is your friend!) that went through the issues. The main issue being the ClientAccessPolicy.xml file. Making some changes to that, then meant that I could have my video files hosted on S3, and streamed to the visitors Browser.

Thank you Internet.

Comments are welcome. Smile

DDD Southwest writeup.

This is a ‘reprint’ of an article I’ve written for our company (TAH Ltd) magazine.

clip_image002So on the 23rd May 2009 (the last Bank holiday Saturday in May), I was up at 5.30 in the morning, and on the road driving down to Taunton in Somerset. Mad, absolutely. But it was lovely weather, and sunny, before the bank holiday traffic hit the road, and air conditioning in the car always makes for a pleasant drive.

I also got to see Stonehenge appear, through the early morning mist, which was incredible. No picture of that though, as I was driving….

Anyway, why was I up and out that that unearthly time ? well, there was a Microsoft Developer community event running down in Taunton, free too, so why not attend and see what’s new ?

This year there has been a good number of free Community events run, primarily because everyone is aware that most companies are financially strapped at the moment, so realistically, the only way for people to keep up to date on the latest developments is to make it free, and out of working hours. With this in mind, there have been in-person events at Microsoft (such as the Web DD event a month or so ago (see my blog article in the Consultants Blog in SharePoint), and events held by User groups (such as DevEvening in Woking, held in a Pub ). These events have been covering new technologies released by Microsoft (SQL Server 2008, Windows 7 RC), and upcoming products such as Visual Studio 2010, Office 14, and Windows Server 2008 R2. My intention is to write articles about these products (probably not Visual Studio 2010, as you really don’t care about that.).

So, the DDDSW (Developer Developer Developer South West!) event was organised by the Developer user group in Bristol. Its the third Developer event in the past few months (with previous events held in Belfast and Glasgow). It covered a number of interesting (actually interesting) topics including the new version of Silverlight (Microsoft equivalent of Flash), the Microsoft Clould platform, Refactoring , the new version of C#and even the video gaming platform that Microsoft have produced. I’ll run through some of these, though I’ll probably stick to the ones that might be relevant. If you are interested in more on any of these, please ask. I’d be delighted to tell you more.

Firstly, lets talk about the new version of Silverlight. You might not know it, but silverlight is now on it’s third version, and is used by a wide variety of websites (its a web technology…). It was one of the main technologies used to broadcast the Olympic events from Beijing last year over the internet, and is used to varying degrees to make websites more interactive. It has a number of advantages over Flash (currently owned by Adobe), in that the installation is smaller, has more functionality available for it, can be created by a far larger group of people (developers) and the resulting Silverlight applications can (but don’t have to be) be hosted by Microsoft (on their servers). This hosting reduces the impact on your web servers, and thereby increases speed. So what does Silverlight 3 give you? It gives a wider range of graphical effects, allows you create standalone applications (right click on the website, and say Install on desktop, useful for any web application) and it also now supports Hi definition Video. You’ll already be aware of the predominance of videos throughout the internet at the moment (not just Youtube, but the majority of websites have some form of ‘moving media’ which is either Flash, Silverlight or Video). Higher resolution screens, mean that low resolution videos look terrible, hence high resolution videos.

Azure is the Microsoft Cloud platform, and will be used to support some of the features of the next versions of SQL Server, Office, SharePoint and Dynamics CRM. You may already have heard of the Cloud computing platform that Amazon have (Amazon S3 is online storage, and Cloud computing is available for online virtual servers). Cloud services are becoming more and more widely used as they allow companies to access significantly more computing power and storage than would be economically viable to have in house. The advantage for Microsoft is that you pay them a monthly few (a few cents for gigabytes of storage, or hours on a server). The advantage for the customer is that they don’t need to have all the hardware they might need in the future, it is very highly and easily scaleable (one server this week, 20 next week, with seconds notice), and also that the back up is carried out by Microsoft too (all stored data is replicated in at least three places). Speed of access to these services is then based on the speed of your internet connection.

Refactoring is pretty complicated and generally not particularly interesting, even to me, but suffice to say that it makes code and products more reusable by making them more generic. For example, a car or a plane is very specific, whereas a vehicle is more generic, as cars and planes are both vehicles, but they do both have specific features.

C# version 4 (when it is released later in the year) gives a wide range of new features, but the most interesting one by almost all the people at the event was that it would allow you greater flexibility with the development of Office applications. Effectively, it would allow you to develop for Office 2003, and the same produced application would work with Office 2007, and Office 14 (in theory) when released. This is an incredible feature, since it means that all the custom work created in Office 2003 (for everyone who hasn’t moved to Office 2007 yet, and there are a huge number) will just need to recompile the code in C#4 (straightforward) rather than re-write it (complete nightmare).

There was an interesting session on the Windows Communications Foundation (WCF) also, which talked about new ways of integrating systems together. This is all based around XML, and Web services. Most systems (ERP, CRM, back end systems) have methods for creating or recieving XML documents. WCF enables the interaction of these documents between some system and a custom system. The information therein can be transformed, manipulated and forwarded on to some other system. The Microsoft product BizTalk Server takes this one step further by ensuring that the messages (XML Documents) are completely trackable from the point they leave the source system to the point they reach their destination. This then allows corporate systems such as those used by Banks to be utterly resilient to error.

There was also an interesting session on the Microsoft XNA platform, which allows the creation of games. It allows someone to create a reasonably professional looking game within a few hours. It handles all the complicated stuff such as sound, graphics, collision detection and menuing, which then leaves you free to do the design and plot of your game. Does anybody really care about a load of games, created by techies ? well, Microsoft have also made it possible for games created using XNA to be published to the Xbox Marketplace, so you can download them onto your Xbox and play them on there. This then gives you a access to a huge number of potential players. It’s all interesting stuff, if you fancy your hand at designing games, rather than just playing them. I did
used to do this on my Atari ST 15 or 20 years ago (can’t believe it was that long ago…), so it’s interesting for me…

I’m writing this on the train down to Seaford, to see the sea, and my in-laws, and we’re nearly there, so I’m going to stop now. Hope you enjoyed it, and if you have questions, please let me know.

If you’d like to read more, the conference website is here: http://www.dddsouthwest.com/

There’s photos from the event here too: http://www.flickr.com/photos/dddsouthwest

WebDD09 Conference

I attended the Webdd09 conference at Microsoft Reading on Saturday (yes, a Saturday…).

Was a really interesting group of sessions, covering the new features coming in Visual Studio 2010, ASP.NET 4 and Silverlight 3. It also covered some of the features of IIS 7, which has been out for a while now.

IIS 7 can automatically set up URL Rewriting. Sounds dull you say, but it effectively means that it’ll setup your website for Search Engine optimisation. Whats that you say… Well it’ll convert this:

http://www.tah.co.uk/Whatweoffer/Pages/WhereScapeRED.aspx

to this:

http://www.tah.co.uk/Products/WhereScapeRED.aspx

without you having to change anything on your website. This is a good thing as Search Engines, such as Google (84 % of the Market share) index pages based on the URL.  This is a good thing to know as Google have stopped taking into account embedded keywords on websites (the meta tags). In fact, the only meta tag they are now taking account of is the Description one. Useful stuff to know.

If you’d like to see more of the event, including the more technical presentations, you’ll be able to view the videos and PowerPoint’s here soon:

http://developerdeveloperdeveloper.com/webdd09

    Recently, Windows Update included a set of addins, including Office Live connector.

    That update extended my HTTP_USER_AGENT string to beyond 260 characters, which unfortunately IE then, when asked via javascript, reports itself back as IE 6 – this causes the Modal dialog boxes in SharePoint for things like adding web parts to zones to report a message that “Not enough storage is available to complete this operation”.

    This then causes error messages when customising SharePoint.

    This can be resolved (only if you are getting error messages) by modifying the registry. (WITH CARE!!)

    1. Go to Start -> Run -> RegEdit

    2. Go to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\5.0\User Agent\Post Platform

    3. You’ll have something similar to this:

        image

      4.Delete a couple from this list (duplicate major versions, or ones you aren’t using). Mine then looked like this:

      image

      5. Then restart Internet Explorer (including all instances).

      Cheers!

      Access is denied

      Do you sometimes get an ‘Access is Denied’ message when deploying a custom web part from Visual Studio, to SharePoint ?

      image

      If so, you can resolve this by stopping and restarting the Indexing service.

      1. Go to a command prompt.

      2. Type ‘net stop cisvc’

      3. Type ‘net start cisvc’

      4. Try deploying your project again.

      Ok, this is complicated to explain.

      Say, for example, that you want to have a link on a website, that a user can click on, to gain access to their Home Directory (which is retrieved from the Active Directory field).

      Ok, kind of a specific need, I know.

      What do you need to do this:

      1. Create a linked server connection, called ADSI, with the following :

      sp_addlinkedserver ‘ADSI’, ‘Active Directory Service Interfaces’, ‘ADSDSOObject’, ‘adsdatasource’

      2. Create a website in IIS, ensure that authentication is Windows Integrated, and not Anonymous.

      3. Create an ASPX page, and give it a FormView (or data enabled tool).

      4. Give it a SQL Server Data source, with a query similar to the one below:

      SELECT ‘file:’+REPLACE(homeDirectory,’\’,’/’)
      FROM OpenQuery( ADSI,’LDAP://AD_DETAILS;
      (&(objectCategory=Person)(objectClass=user));
      homeDirectory, sAMAccountName, distinguishedName’)
      where sAMAccountName in (select SUBSTRING ( SYSTEM_USER , CHARINDEX(‘\’,SYSTEM_USER)+1, len(SYSTEM_USER)-CHARINDEX(‘\’,SYSTEM_USER)) )

      This query will return the home directory, from ADSI Linked Server, for the current user.

      5. All you then need to do is bind the returned field to a button. You can do this with the following:

      <asp:HyperLink ID=”HyperLink1″ runat=”server” NavigateUrl=’<%# Bind(“homeDirectory”) %>‘> mylink is here</asp:HyperLink>

      Creating a Zipfile in C#

      If you use SharpZipLib (http://www.icsharpcode.net/OpenSource/SharpZipLib/Default.aspx), this is really pretty straightforward.

      ZipFile z = ZipFile.Create(archiveName);

      z.BeginUpdate();
      string[] zipFiles = Directory.GetFiles((string)sPathToLoad, "*1.0.xls");

                foreach (string f in Files)         // Loop round each file
                {
                          Console.WriteLine("    Adding "+f);
                          z.Add(f);
                      }

      z.CommitUpdate();
      z.Close();

      Debugging a VSTO Excel Add-in

      Well, having spent the best part of half a day trying to find a problem with an Excel Add-in not working on a deployed machine (it worked just fine on the development machine), it wasn’t appearing in Excel. Not even an error message. Finally though, I’ve found the answer.

      Having trolled around a load of websites, and learnt a load about install kits and how to install an add in into Office applications, I found an environment variable.

      Set VSTO_SUPPRESSDISPLAYALERTS to 0

      It then gave me an error message, saying it didn’t have an assembly. Easy to fix when I got the error message.

      Hooray!

      MSDN Forums item on deployment:

      http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/cc1491b8-52a5-4a38-bd15-45dd9120018b/

      and another:

      http://social.msdn.microsoft.com/forums/en-US/vsto/thread/887d1f9d-7e7e-4042-999e-baccd31d32ab/

      and another (more detailed):

      http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/1666d2b0-a4d0-41e8-ad86-5eab3542de1e

      and with regard to ClickOnce:

      http://blogs.msdn.com/vsto/archive/2008/05/08/adding-the-office-primary-interop-assemblies-as-a-prerequisite-in-your-clickonce-installer-mary-lee.aspx

      Having been working on this for a few days, there seem to be an awful lot of ‘solutions’ on the internet which don’t actually work at all.

       I found this one, and having checked it out, it seems to work quite nicely.

      Thank you Pieter van Maasdam.

      http://sqlblogcasts.com/blogs/repieter/archive/2007/12/07/ssas2005-using-logged-in-user-within-a-role.aspx 


      A customer of ours has a security model stored in a database and they wanted to have the security in the cube to be the same, so I came up with te following solution:

      Example of the database in which the security is stored:

       

      The DimUser table contains the users and their AD login account. The FactHours contains the hours that they have booked. The security is stored in the many-to-many table FactHoursDimUser, so the data in this table shows which user can see which fact. Go to the “Dimension Usage” tab to set the right relationships between the tables:

      Next step is to add a role to the cube and add user groups on the Membership tab.

      After that, you go to the dimension data tab, select the user dimension, the loginname attribute and then enter the following MDX expression to the “Allowed member set” section: {STRTOMEMBER(“[User].[Loginname].[" + username+ "]“)}. Also, make sure that “Enable visual totals” is enabled, so the calculations for the totals will only show what the logged in user is allowed to see.

       

       After that, process the cube and go to the browser tab. Select “Switch user” to view the cube data with other credentials to see the results.

       

      Follow

      Get every new post delivered to your Inbox.

      Join 539 other followers