Coffee, smoke and techilicious burps at 3.47 AM

Some half baked ideas by Nilotpal about Tao, Zen and the art of converting coffee into code...

  • Your user profile was not loaded correctly! You have been logged on with a temporary profile.

    This is not a problem that I feel you would encounter on a regular basis. I think I had a unique problem because of which I encountered this one. When you install an operating system it allows you to create a profile. Now I installed the machine at home. Which means I was not on the corpnet of Microsoft which means I could not log on to the domain. So when I created a profile named after my alias, it was considered as a local profile and not a domain profile. And a folder was created under “C:\Users” with my alias name.

    I am not sure if this makes any sense or not, but hey, I am a software program writer not a network administrator. So please excuse my jargon. Anyway, when I actually logged on to the domain with my brand new operating system the next day, a new profile had to be created for the domain. Now since there was a folder already with my alias name in “C:\Users” the brand new operating system create a brand new profile with in the format <alias.domain> so now there was a “.” in my profile directory name.

    What happens is this “.” sometimes creates problems in installing certain software. I got the error message saying “There is an invalid character in the directory path of My Documents”. I checked the path and could find only one anomaly. And no points (“.”) for guessing what.

    So I decided I will rename the profile directory. I straight away went to the directory and though I would rename it to something else. of course it wouldn’t let you. So I thought I would log on as a local administrator and then do it. Also I made sure that I start windows in safe mode.

    After Logging on I backup my documents, and delete the profile and assume that the next time I log on, it will automatically create the new directory for me. Guess what… Not that easy…

    So after a long research I found out that there are registry entries out of which windows reads the location of the profile directory. So if it doesn’t find the directory at the specified location, it creates a temporary directory and logs you on with a temporary profile. And after the log on is complete, it gives you that message.

    So here is what you do to save your life. Please do this only if you have already deleted your profile and did not take backup. If you are doing your research before you have messed with your machine, please skip these steps and refer below.

    1. Log on with local administrator account, preferably in safe mode. To boot the machine in safe mode, Click F8 during boot.
    2. Click Start + Run and type in regedit and then Enter.
    3. Open HKEY_LOCAL_MACHINE
    4. Open Software
    5. Open Microsoft
    6. Open Windows NT
    7. Open Current Version
    8. Open ProfileList
    9. Here you will see keys that belong to each profile. To find your problematic profile navigate to each key and refer to the ProfileImagePath entry on the right hand side.
    10. Once you find your problematic profile, just delete the key. This means delete the folder on the left hand side tree view that contains your alias in the ProfileImagePath entry.
    11. Restart machine.

    There is another way you can actually backup your profile and create a new one.

    Click on “Start”, Right click “Computer” and go to “properties”

    Click on “Change Settings”

    image

    Go to the “Advanced” tab and click on User Profiles “Settings” button

    image

    image

    “Change type” will allow you to change your profile type between Roaming and Local Profiles

    “Delete” will delete that profile. Including the registry entries and everything.

    “Copy To” will back up your profile. It is always advisable to backup your profile from here rather than from anywhere else. Your profile contains more than you can see. Hidden Files, System Files, etc. This takes care of everything in a safe manner.

    Hope this helps.

  • Function Point Analysis (FPA) Glossary

    1. Internal Logical File (ILF): An internal logical file (ILF) is a user identifiable group of logically related data or control information maintained within the boundary of the application. The primary intent of an ILF is to hold data maintained through one or more elementary processes of the application being counted.
    2. External Interface File (EIF): An external interface file (EIF) is a user identifiable group of logically related data or control information referenced by the application, but maintained within the boundary of another application. The primary intent of an EIF is to hold data referenced through one or more elementary processes within the boundary of the application counted. This means an EIF counted for an application must be in an ILF in another application.
    3. Data Element Type (DET): A data element type (DET) is a unique, user-recognizable, non-repeated field.
    4. Record Element Type (RET): A record element type (RET) is a user-recognizable subgroup of data elements within an ILF or EIF.
    5. File Type Referenced (FTR): FTR's are the combined number of Internal Logical Files (ILF's) referenced or updated and External Interface Files referenced
    6. External Input (EI): An external input (EI) is an elementary process that processes data or control information that comes from outside the application’s boundary. the primary intent of an EI is to maintain one or more ILFs and/or to alter the behavior of the system.
    7. External Output (EO): An external output (EO) is an elementary process that sends data or control information outside the application’s boundary. the primary intent of an external output is to present information to a user through processing logic other than or in addition to the retrieval of data or control information. The processing logic must contain at least one mathematical formula or calculation, or create derived data. An external output may also maintain one or more ILFs and/or alter the behavior of the system.”
    8. External Inquiry (EQ): An external inquiry (EQ) is an elementary process that sends data or control information outside the application boundary. The primary intent of an external inquiry is to present information to a user through the retrieval of data or control information. The processing logic contains no mathematical formula or calculation, and creates no derived data. No ILF is maintained during the processing, nor is the behavior of the system altered.
    9. General System Characteristics (GSC): The data and transactional functions discussed in earlier chapters together represent the total business functions that are delivered through the application being counted. Truly this is the logical representation of the functionality and does not address the physical implementation of the functions in an IT environment. The FPA method of IFPUG has captured the critical implementation features of typical applications through 14 general system characteristics. These encompass almost all the major implementation complexities that can exist, and through careful evaluation of each of the GSCs, the estimator can arrive at final function point count that includes logical as well as physical implementation properties of the application being counted.
    10. Value Adjustment Factor (VAF): Calculated ((Total Degree of Influence * 0.01) + 0.65)
    11. Calibration Factor (CF): general buffer depending upon practical environment
    12. Delivery Rate (DR): No. of function points a single developer will accomplish every month
    13. Days per person month (DPM): The no. of days a person will effectively work in a month. 20 working days in a month and Microsoft generally counts 75% utilization which means around 15 working days in a month.
  • Update an entity in Repository Pattern

    Look around the web. You will find no Update method in the repository patterns for entity framework implementations published. There are different flavors of retrieves, mark for insertions an deletions but no update implementation. And curiously this is the most painful. There are 2 options that you have. But to explain both, I will start off with the repository design. We can get into a discussion about the pattern in case anyone is interested, all you have to do is instigate me by posting a comment.

     

    So now your IRepository here has some generic functions :

    ---

        /// <summary>
        /// Return all instances of type T.
        /// </summary>
        /// <returns></returns>
        IEnumerable<T> All();

        /// <summary>
        /// Return all instances of type T that match the expression exp.
        /// </summary>
        /// <param name="exp"></param>
        /// <returns></returns>
        IEnumerable<T> FindAll(Func<T, bool> exp);

        /// <summary>Returns the single entity matching the expression. Throws an exception if there is not exactly one such entity.</summary>
        /// <param name="exp"></param><returns></returns>
        T Single(Func<T, bool> exp);

        /// <summary>Returns the first element satisfying the condition.</summary>
        /// <param name="exp"></param><returns></returns>
        T First(Func<T, bool> exp);

        /// <summary>
        /// Mark an entity to be deleted when the context is saved.
        /// </summary>
        /// <param name="entity"></param>
        void MarkForDeletion(T entity);

        /// <summary>
        /// Create a new instance of type T.
        /// </summary>
        /// <returns></returns>
        T CreateInstance();

        /// <summary>Persist the data context.</summary>
        void SaveAll();

    ---

    These generic functions, if you notice, does not contain an update function. Now the 2 options that you have that I have talked about, are

    Option 1: Do not take care of your updates in the provider. Now this is simple. Do all the updates in the logical layer that calls the data provider. Something like

    ---

                        Events dbEvent = null;
                        IEnumerable<Events> dbEvents = this.DataProvider.All<Events>(eve => eve.EventID.Equals(communityEvent.EventID));
                        if (dbEvents != null && dbEvents.Count() == 1)
                        {
                            dbEvent = dbEvents.SingleOrDefault();
                        }
                        else
                        {
                            throw new ApplicationException(MADConstants.GENERIC_DATA_ERROR);
                        }
                        dbEvent.DateModified = communityEvent.DateModified;
                        dbEvent.Description = communityEvent.Description;
                        dbEvent.EventEndDate = communityEvent.EventEndDate;
                        dbEvent.EventName = communityEvent.EventName;
                        dbEvent.EventStartDate = communityEvent.EventStartDate;
                        dbEvent.IsApproved = communityEvent.IsApproved;
                        dbEvent.LastModifiedBy = communityEvent.LastModifiedBy;
                        dbEvent.NoOfRatings = communityEvent.NoOfRatings;
                        dbEvent.Organizer = communityEvent.Organizer;
                        dbEvent.ParticipatedBy = communityEvent.ParticipatedBy;
                        dbEvent.RatedBy = communityEvent.RatedBy;
                        dbEvent.Rating = communityEvent.Rating;
                        dbEvent.Sessions = communityEvent.Sessions;
                        this.DataProvider.SaveAllChanges();

    ---

    The second option which i feel is most elegant is this:

    ---

    /// <summary>
            /// Updates
            /// </summary>
            /// <typeparam name="T"></typeparam>
            /// <param name="entityName"></param>
            /// <param name="entity"></param>
            public void Update<T>(string entityName, T entity)
            {           
                this.context.AttachTo(entityName, entity);
            }

    ---

    So all you have to do now is to call the functions like this

    ---

    DataProvider.Update<Customer>(“Customer”, customer);

    DataProvider.SaveAllchanges();

    ---

    The third option is a little complex. Please refer to the diagram above, the task repositories that you will implement must contain the update function like this:

    public void Update(Customer customer)

    {
        context.Attach(customer); //Custom extensor method
        context.SaveChanges();
    }

    This means you have all your Task Repositories that know the type of your entity. So a CustomerRepository would know that it is handling Customer Types and hence will take Customer as a parameter to the Update Method. This is because Attach method requires an argument that is of type System.Data.Objects.DataClasses.IEntityWithKey. Which means it will not accept type T because this does not have the entity key or the primary key on the basis of which it will know which entity / row to update in the database.

    The purpose of the third option is that all interaction with the database that is specific to a particular entity can be handled in the Task Repositories.

  • Repository Pattern – The purpose

    We decided to implement the repository pattern for the Entity Framework Implementation in our project. So last couple of weeks people have been asking me why the repository pattern is required. I mean what is it that this pattern does besides giving a layer of abstraction, and providing the CRUD methods, which are also available in C# as a language feature (LINQ).

    The answer is given aptly by Martin Fowler as, “A system with a complex domain model often benefits from a layer, such as the one provided by Data Mapper (165), that isolates domain objects from details of the database access code. In such systems it can be worthwhile to build another layer of abstraction over the mapping layer where query construction code is concentrated. This becomes more important when there are a large number of domain classes or heavy querying. In these cases particularly, adding this layer helps minimize duplicate query logic.

    A Repository mediates between the domain and data mapping layers, acting like an in-memory domain object collection. Client objects construct query specifications declaratively and submit them to Repository for satisfaction. Objects can be added to and removed from the Repository, as they can from a simple collection of objects, and the mapping code encapsulated by the Repository will carry out the appropriate operations behind the scenes. Conceptually, a Repository encapsulates the set of objects persisted in a data store and the operations performed over them, providing a more object-oriented view of the persistence layer. Repository also supports the objective of achieving a clean separation and one-way dependency between the domain and data mapping layers.”

    This has a no. of benefits. Simplifying complexity, removing redundant querying, making code more testable, etc. Let’s say you want to test your code without going into the database and destroying it completely. unless you use DBUnit, This pattern helps you a lot. All you need to do is change your SaveChanges() function from

    ---

            /// <summary>
            /// Saves all changes in the current context.
            /// </summary>
            public virtual int SaveAllChanges()
            {
                try
                {
                    ((ObjectContext)this.Context).SaveChanges();
                    return 0;
                }
                catch
                {
                    return -1;
                }
            }

    ---

    to

    ---

            /// <summary>
            /// Saves all changes in the current context.
            /// </summary>
            public virtual int SaveAllChanges()
            {
                    return 0;
            }

    ---

    On doing this, your changes are not populated to the database and you can do all your testing in-memory. Now is it a good idea to change your code to just make it testable? Well that’s a good question that needs discussing at length. Maybe in another post…

  • Function Import and Loading of referenced data

    Why do Entity Framework Function Imports do not have eager loading? Because when you use Entity SQL or regular Object context to retrieve data, it is a live connection. So whenever you say eager loading enabled, it gets the data from the database using the live connection. But if you want to do it using Function Import, EF doesn’t know where to get the data from, since the stored procedure that the function import maps to, doesn’t get that data. Perhaps in the later versions of EF, the team might add the feature which can mix and match the object context and the stored procedure to get the required data. But as of now it is not possible.

  • Are you Eager? Or are you Lazy? Or are you both on a case to case basis...??

    Entity Framework, Eager Loading and Lazy Loading, my own 2 cents. For those new to Entity Framework, we are talking about the patterns that you can use to load related objects. The strategy by which you would load entity objects that are related to the one in question. There is a beautiful resource that mentions it all. I do not think there is any elaboration required in that matter. But this is not the meat of the matter.

    image How do you design an application that uses Entity Framework as a data access strategy? There are a no. of things to consider. The apparent answer all over the Internet is the Repository Pattern (ref: http://blogs.infosupport.com/blogs/willemm/archive/2008/08/18/Using-ADO.NET-Entity-framework-with-the-repository-pattern.aspx, http://blogs.microsoft.co.il/blogs/kim/archive/2008/11/12/data-access-with-the-entity-framework.aspx, http://www.simonsegal.net/blog/2009/01/13/entity-framework-repository-specifications-and-fetching-strategies/). The purpose of the repository pattern is "A system with a complex domain model often benefits from a layer, such as the one provided by Data Mapper (165), that isolates domain objects from details of the database access code." All said and done, we write the repository to abstract the CRUD from the Application Layer. This way, simply put, we don't need to write separate routines to do CRUD behaviour on every entity type. The functions look something like this:

    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

     

    /// <summary>
    /// Returns the required querable object to the caller
    /// </summary>
    /// <typeparam name="T">Generic Object</typeparam> 
                                          /// <returns>IQueryable<T></returns> 
                                          private IQueryable<T> GetTable<T>() 
                                         
                                                   IQueryable<T> result = null
                                                   string type = typeof(T).Name;  
                                                  
    ObjectQuery query = Context.CreateQuery<T>(type); 
                                                   result = (
    IQueryable<T>)query; 
                                                  
    return result; 
                                         
    }

    This routine is called like this.

     

    ////<summary>
    ////Return all instances of type T.
    ////</summary>
    ////<returns></returns>
    public virtual IEnumerable<T> All<T>()
    {
         System.Data.Linq.
    DataLoadOptions dlo = new System.Data.Linq.DataLoadOptions();
         return GetTable<T>();
    }

    And this in turn is called like this:

     

    public IEnumerable<Employee> GetEmployees()
    {
         IEnumerable<Employee> employees = this.dbProvider.All<Employee>();
         return employees;
    }

    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Now if you see, we have one function retrieve all types of entity objects. Now let's get to the actual topic in hand. Eager loading and lazy loading. I cannot opt for any of the mentioned patterns, because I do not have the type of the pattern that I am going to return at design time. I have already postponed that by using Generics. Just last night I learnt from Daniel Simmons that Framework 4.0 they are planning to add a property to Context object in order to opt in implicit lazy loading.

    While I am still trying to figure out a good way of working around eager loading and lazy loading, as of now (before 4.0 arrives) I am firing separate queries to get all types of related objects. And interestingly, once I fire the queries for the related objects and enumerate them, the principal object at hand gets populated with related objects. So next time you want to reference the related objects, just go ahead and use the beautiful sentence completion features such as this: "txtAddressLine1.Text = employee.EmployeeAddress.First().Address.AddressLine1;"

  • StyleCop and Good Code

    So you are serious about your code quality huh... well StyleCop is a fantastic tool to ensure that. The best part is, it integrates with Studio 2008. It is simple.

    1. Go to This Location, click on downloads and download the latest version of StyleCop. As of now it is the version 4.3
    2. Install StyleCop. It asks you information about integration. Let it integrate with Studio for the moment.
    3. Fire up Visual Studio
    4. Click on Tools and say Run StyleCop and look at the 1001 warnings that StyleCop gives.

    Now when you use StyleCop, most of the warnings are not what you really want to work upon. Like Documentation, for instance, imagewho cares whether there is a blank space line above a comment or not...? So you can go to Solutions Explorer and click on Style Cop Settings. This will bring up the "Microsoft StyleimageCop Project Settings" Dialogue box which will allow you to customize your rules set. Allow you to enable / disable rules as per your own special requirements / whims / fancies / moods... :)

    It is a fun little tool and I could have written more about it but then I decided that I won't spoil the fun. You guys go ahead and explore.

  • Entity Framework FAQ

    Lately everyone in my team and around my bay have been talking about Entity Framework. Well since I have been an early adopter, writing my small apps using Entity Framework and fighting for it on my project, people have been coming to me to ask questions. I have been taking pride in answering them (happy to help), most of the times... until lately... since I have been working on too many things...

    I just came across an FAQ which pretty much covers it all (thanks Daniel...!). I thought I will add it to my browser favourites. But then I thought that would just help me and not everyone.

    Happy to help... :)

  • It's all there in the cloud...!!

    So what's this new buzz word... everyone has been talking about it...

    Essentially what we are doing is taking our applications and putting them in a cloud. Cloud meaning highly available servers which are provided by huge service providers such as Microsoft, Amazon, etc. Now since I strongly believe that it is business that drives technology, it is the business side that we need to understand first. why do we need it. I have my servers in house, I deploy my apps on my servers, I control and maintain them then why would I want it to be on servers that others control? It is like the analogy that my valuables are in my house, how can it be a better idea to go and put them somewhere else. Well the answer to that question is another question. Do you put all your money under your mattress in your house? Or is it a better idea to go and put them in the bank?

    There are many benefits in building the applications from the cloud. Let's take cost for example. The cost of hosting an application on the cloud is just a fraction of what you will have to incur in deploying the application on one of your in-house servers. Along with it comes the maintenance cost. Employing people to maintain the Servers, business continuity planning, and so on and so forth. The list goes on. The Cloud providers on the other hand can provide you all the same services at a fraction of the cost. They work on much much larger scales. So it makes sense for them too.

    Another interesting perspective is that, let's say you are an application vendor. You go and talk to a customer to sell your app. Let's say you convince the customer in buying the app. That means you have convinced one person. The person who takes the decisions. Let's say he consults a team before he takes the decision. Even in that case you have convinced that team. And most usually, the people who make the decisions are not the people who end up using your app. And there is no way for them, yet, to find out whether or not the app is good enough for them in their context. So then you go ahead and deploy the app and then start using it. Then the users, find out how much the application was worth in their context and they may or may not like it. Although this is the model we have been working on all these years, it doesn't look like a very effective model does it?

    Let's change the scenario. Same application vendor, but this time, he has his application as a software as a service, deployed on the cloud. He just has to go and say, "Well you don't have to guess, I don't have to convince you. Why don't you use the application yourself for a few days and find out?" The users use the app, they like it fine; if they don't, well they don't have to buy it. And of course there is the "pay as you go" model in Software as a service. Just stop paying when you stop using the software.

    And the best part is you don't have to go fight it out with your IT for deployment. It's all there in the cloud...!!

  • Hot fix for the Entity Framework Bug

    I had recently posted about a bug on SQL CE Entity Framework. Please note that the links mentioned in there for the bug and the hot fix are internal to Microsoft. The hot fix shall be released as a KB article in a couple of weeks.

  • SQL Server Compact Edition / Entity Framework bug

    I am working on this really smart, smart client application installer. Which smartly installs other pieces of another smart client application as and when required.

    It makes sure that only those bits are downloaded that are not already installed. So it takes care of upgrades on its own. So basically we are writing our own "ClickOnce" functionality.

    Why are we not using ClickOnce out of the box? Well that would require another post, but let's say we require much more granularity than what "ClickOnce" provides us, on this "Installation Manager", and put it at that.

    Anyways, I am doing some book keeping using SQL Server CE on the client machine to maintain account of upgrades and installations. For this I am querying the SQL Server CE database and in the process and I encounter an error that says:

    "The ntext and image data types cannot be used in WHERE, HAVING, GROUP BY, ON, or IN clauses, except when these data types are used with the LIKE or IS NULL predicates."

    I am not even working on ntext data type. The select query goes something like this:

    IQueryable <FileInfo> files = entities.FileInfo.Where(fileInfo => fileInfo.FileName.Equals(fileName));

    And "FileName" is not an ntext datatype in the entity "fileInfo". It is an nvarchar.

    Interestingly, if you fire the same query on the Management Studio (SQL Version of the query of course), it works fine. It only breaks when you use LINQ to SQL or EF.

    After a little research I find out that there is a bug in SQL Server 3.5 RTM which was incidentally not resolved even in the "SQL Server Compact 3.5 SP1 English". And later there was an out of the bag release that was made to resolve this issue. So the Hotfix, cannot be installed directly. You need to uninstall "Microsoft SQL Server Compact 3.5 SP1 English" from Add Remove Programs before you install this hotfix.

    Once the Hotfix is installed, your query will just work...!

    In case if you are wondering whether you need to re-install "Microsoft SQL Server Compact 3.5 SP1 English"? Well, installing it back will remove the hotfix. So DO NOT DO THAT.

  • Best RSS Feed Reader

    My wife is a writer, and a pretty good one for that matter. Recently she went for a job interview, where she was asked a lot of questions about current affairs, and she doesn't exactly read the news regularly. So I told her she should. But she doesn't like reading the news paper, and I told her about online news. About RSS Feeds and Feed Readers.

    So which feed reader do you use. Of course every developer uses one. So what else does a developer use? Internet Explorer and Microsoft Outlook. Post Internet Explorer 7, you can subscribe to RSS Feeds using IE. you can read the posts online on IE. But the beautiful thing is every time you subscribe to a feed on IE, it nicely goes and adds itself on the RSS Feeds folder in Microsoft Outlook. This gives you the offline reading facility of course it also depends on what you are subscribing to. Some of the stuff is just not available offline. Like MSDN Magazine, which just has a one liner and a link to the actual article.

    Speaking of which, MSDN Magazine is available online since January 2008. The MSDN Magazine is a fantastic read and is on top of my reading list every month. Some of the articles are just too good. Like for instance, this month my favorites are: The editor's note (which is always a pleasure to read), Thread Management in the CLR, Design for testability, Static Analysis tools for .Net.

    Other favorites on my feed reader are:

    1. Ann-Dee's Tic-Tacs (My wife's weblog)
    2. Stack Overflow
    3. Threads watched by Channel 9 Team
    4. Business Week Online - Tech Beat
  • Downloading and installing AdventureWorks Database

    I am assuming that you want to write a prototype of some sort for which you want a sample database to work with. And I am assuming that you don't have AdventureWorks on your machine. Putting down quick set of steps:

    1. Go to http://www.codeplex.com/MSFTDBProdSamples/Release/ProjectReleases.aspx?ReleaseId=4004
    2. Click on AdventureWorksDB.mdi, in case you are looking for the AdventureWorks Database for SQL Server 2005. there are also other sample databases available. This post is specifically for the AdventureWorks database for SQL Server 2005
    3. Accept the Agreement
    4. Download and run the installable.
    5. Open Visual Studio Command Prompt.
    6. Type in SQLCMD and press enter
    7. Type in the command
      "exec sp_attach_db @dbname=N'AdventureWorks', @filename1=N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AdventureWorks_Data.mdf', @filename2=N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AdventureWorks_log.ldf'"
    8. Please note that the Drive could be either C:\ or D:\ depending upon where you have installed the AdventureWorks Database MSI.

     

    This will attach the AdventureWorks database. Fire up SQL Server Management Studio and confirm whether Adventure Works exists or not.

  • Marriage and the movie maker

    I am getting married. That's right. Well I don't know about the other parts of the world, but 32 is a little late to get married for people resident in India. All my friends are married and have children of age ranging from 4 months to 8 years. Most of them started thinking that I am not ever going to get married. But well it is happening. But this blog post is not about that.

    A couple of months back, my girl friend (the girl with whom I am getting married silly...!!) received a marriage invite from her friend which was quite innovative. They had made a nice write up with the Shrek Movie poster in the back ground. Sweet nothings about their relationship, about their attitude and chemistry. Being a girl, she was moved and said she wanted something equally innovative for our marriage.  I told her if a picture is worth a thousand words, we make a movie. And we did.

    Now to stick the clips together, and to do the editing, I really didn't know what to do. So a friend of mine suggested that I download the ULead Video Studio, which I did, and installed it and used it to create the movie. Dainty little tool it is. The only thing that was left in the movie was the sub titles. Yes I made a movie and the subtitles would describe how the movie relates to our lives. That's when the trial period for Video Studio got over. Now I was in a fix. I didn't want to upload the movie with no subtitles. Talking about it around the cafeteria, Dhananjay, reminded me of the Microsoft Windows Movie Maker.

    That's what this blog is all about. I did upload the movie without the subtitles, but as we speak, or rather as I write this, the Movie Maker is publishing the movie with the subtitles. I am going to upload the movie once I reach my workplace. The whole point is Movie Maker is a nice tool, that comes free with Windows since Windows ME. When it was released initially, it faced some poor reviews. But it has come out pretty well it seems.

    As Wikipedia quotes it, "Windows Movie Maker in Windows Vista includes new effects and transitions, and support for the DVR-MS file format which Windows Media Center records television in. The HD version in Premium and Ultimate editions of Windows Vista adds support for capturing from HDV camcorders. The capture wizard will create DVR-MS type files from HDV tapes."

    Just giving Windows Movie Maker the credit it deserves...

  • Hosting a WCF Service on IIS

    Look for this topic on the Internet. The first thing that you will see is the implementation of the service. I really wouldn't fathom why that is usually done. If I am looking for the subject Hosting a service on IIS, I would assume that the service has already been written and ready, and it is the hosting that I really need the help with. But still I will also follow the standard and go and and tell you the details of how to create a WCF Service.

    1. File -> New -> Website
    2. WCF Service

    This will create Service1.svc and IService1.cs. The IService1.cs is the Service Contract, that you need to implement on your Service. Prepare the contract, prepare the Service and then build. Once it builds, you are done with the service.

    Now when you are writing an application which requires a WCF Service, you don't really start off with a WCF Service. Just like you don't start writing a Windows Service, with a Windows Service, you don't start a WCF Service application with a WCF Service application. Confused...? What I am trying to say is, in case of a windows service, what I usually do is write the entire application in a Windows Application. Once I am done writing the application, I move the code to a Windows Service, simply because it is much easier to debug a windows application than a windows service. Similarly, I would write a normal multi-layered application, and then once I am done (at least up to a logical completion), I would Create a WCF Service and move the Service Layer (which was not a service layer until now) into the new Service. Of course with it goes all the other layers, which were supposed to be on the database side. Like the Data Access Layer or perhaps the Entities Layer, if you happen to use one.

    So coming back to the point how do you really host your service? This article is not really about hosting the service. I would like to write more about the glitches and the obstacles that you have to face when you are hosting the service. In theory, the process of hosting the service is quite simple:

    1. Publish the Service
    2. Open Internet Information Services (IIS) Manager
    3. Create a new application and provide the physical path to the directory into which you published the service

    That's it.

    Now the glitches:

    Server Error in Application “Default Web Site/CallService”

    HTTP Error 404.3 - Not Found:

    Incase of this error the possible reasons are:

    1. The current version of WCF has not been registered
    2. IIS Scriptmaps are not updated at the IIS Metabase Roots
    3. Existing Scriptmaps are of a lower version

    To resolve this issue, you need to take the following steps:

    1. Run a command prompt window as administrator. Start, cmd as normal then press CTRL+SHIFT+ENTER
    2. Navigate to c:\windows\Microsoft.Net\Framework\v3.0\Windows Communication Foundation\
    3. Run the command ‘ServiceModelReg -i’ - You should receive the results below.
    4. Exit

    Another error that you most commonly see is this:

    "There is no compatible TransportManager found for URI 'http://<your URI>.svc This may be because that you have used an absolute address which points outside of the virtual application. Please use a relative address instead."

    The error message might misguide you. There is a possibility that you might have specified an absolute address in the configuration file. But if you go there and check and find that the address is not absolute, then perhaps the error isn't there. For this what you should do is, check if all your IIS Components are installed or not. In my case I discovered that I didn't have 2 things installed. "IIS Metabase and IIS 6 Configuration Compatibility" under Web Management Tools -> IIS 6 Management Compatibility and "Windows Authentication" under World Wide Web Services -> Security.

    Last but not the least. If you see any other issues, which you are not able to figure out just by reading the error message on the IE, where you are trying to browse to the service, publish the website once again, using an http:// URI from your Visual Studio project. If the publish fails, even though you might not see any errors on the error window, go to the output window and check. You will see the source of the problem, which is much more clear and easy to understand. This idea was given to my by my good friend Koti who sits next to me.

     

More Posts Next page »

© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Microsoft
Page view tracker