Madhawa Learns To Blog : C#, Java

.net, c#, java,sql, OOAD and more mad memory dumps...

  Home  |   Contact  |   Syndication    |   Login
  39 Posts | 0 Stories | 28 Comments | 15 Trackbacks

News

Archives

Post Categories

Blog Roll

Hang Outs

My old blog

Monday, June 29, 2009 #

You know what happens when we change the name of a SharePoint server right? It simply won’t work again unless you run the SharePoint Server configuration wizard.

So what would happen if you do the same for the SSRS (SQL server reporting services) server? Some say you might not be able to connect to the reporting services again. I changed my reporting server’s name and still was able to create reports and do some other things. But clearly there were some problems. I tried to get support from my colleagues who were already familiar with SSRS but with no luck.

After some googling I found below link looks promising. But alas… it didn’t resolve my prob.

http://msdn.microsoft.com/en-us/library/ms345235(SQL.90).aspx

If I point my problem clearly, when I try to do “Configure report server - > Initialization” it shows me old machine name (name before I rename it) which will causes lots of problem in future. (That was according to my colleagues and I don’t know what those problems would be as this is the first time I’m gonna use SSRS)

Then I tried to create a new reporting server database through “Configure report server - > Data Setup”.


Guess what? It worked and saved my day!


Thursday, January 22, 2009 #

Today I had to work on a project which uses VS2008 and SQL Server 2008. I haven't used SQL2008 but had used VS2008 a little bit. When I tried to install SQL2008 (Developer edition) got this strange error which says "Microsoft .NET Framework 3.5 installation has failed. SQL 2008 Setup requires .NET 3.5 to be installed."

Strange thing is I had installed .NET 3.5 in the VPC upfront. Actually you are installing .NET 3.5 when you install VS2008 right?

Anyway I tried to resolve this using,

1. Uninstall .NET 3.5 and try install SQL 2008 (SQL 2008 setup comming with .NET 3.5 installation)

2. Reinstall .NET 3.5 and install SQL 2008

3. Reinstall .NET 3.5, service pack and install SQL 2008

Yes... I failed. I can't remember what other things I tried. :)

So then I went for other possible option, that is to connect to an existing SQL2008 server through VS2008. Then I got this damn error message.

 "This server version is not supported. Only servers up to Microsoft SQL Server 2005 are supported.".

But fortunately this time I got the resolution. You had to install <a href="http://download.microsoft.com/download/6/7/0/670ce765-4c9b-4620-902f-b9fc9a7c3c2d/vs90-kb945855.exe">vs90-kb945855.exe</a>. Then you can connect to SQL2008 from VS2008.

But still I didn't get an answer for my first prob. If anyone knows the answer pls drop the solution here. Thanks in advance.

 


Tuesday, November 18, 2008 #

        /// <summary>
        /// Add a user to a Sharepoint group
        /// </summary>
        /// <param name="userLoginName">Login name of the user to add</param>
        /// <param name="userGroupName">Group name to add</param>
        private void AddUserToAGroup(string userLoginName, string userGroupName)
        {
            //Executes this method with Full Control rights even if the user does not otherwise have Full Control
            SPSecurity.RunWithElevatedPrivileges(delegate
            {
                //Don't use context to create the spSite object since it won't create the object with elevated privileges but with the privileges of the user who execute the this code, which may casues an exception
                using (SPSite spSite = new SPSite(Page.Request.Url.ToString()))
                {
                    using (SPWeb spWeb = spSite.OpenWeb())
                    {
                        try
                        {
                            //Allow updating of some sharepoint lists, (here spUsers, spGroups etc...)
                            spWeb.AllowUnsafeUpdates = true;

                            SPUser spUser = spWeb.EnsureUser(userLoginName);

                            if (spUser != null)
                            {
                                SPGroup spGroup = spWeb.Groups[userGroupName];

                                if (spGroup != null)
                                    spGroup.AddUser(spUser);
                            }
                        }
                        catch (Exception ex)
                        {
                            //Error handling logic should go here
                        }
                        finally
                        {
                            spWeb.AllowUnsafeUpdates = false;
                        }
                    }
                }

            });
        }

 

Here in this method you have to set "spWeb.AllowUnsafeUpdates = true" to allow updating some sharepoint lists.


Tuesday, November 11, 2008 #

Check these really good articles by James Tsai.

Understand SharePoint Permissions - Part 1. SPBasePermissions in Hex, Decimal and Binary - The Basics

Understand SharePoint Permissions - Part 2. Check SharePoint user/group permissions with Permissions web service and JavaScript

Thanks Suranja for sending me these links.

 


Tuesday, September 02, 2008 #

I have a small question for sharepoint experts. :)

Can we deploy a Content Type as a feature with some extended settings like "Workflow settings" and "Information management policy settings"?

If so please enlighten me on how to do that.


Monday, September 01, 2008 #

Type below in the command line replacing <MC name or IP> with the machine name or IP you want to connect. This works with WinXP and Vista.

mstsc -v:<MC name or IP> /f -console

Updated:

:D There is a easy way. Just type mstsc /console in the command prompt.


Tuesday, August 26, 2008 #

STSDEV is a simple tool for SharePoint developers. It helps you to create SharePoint projects (with solutions precisely) and deploy templates and components into the SharePoint 2007 platform.

http://www.codeplex.com/stsdev

This tool creates project and solution in same name and in the same folder. We all know we never put the solution and project files in the same folder and never use same name for the solution and the project. Unfortunately we didn’t find a way of changing those and use the tool after since it gives errors. I found a very easy way of tweaking that from changing small line in the source code or changing a line in the generated .target file.

And furthermore I have changed the tool to support for supplying a different project name when creating a solution and now we are using it in our SharePoint project.

BTW I'll explain how to tweak the tool to use separate source folder for project by a small change in the source code in next post. Until then play with the tool and have some fun.

If you want that version of the tool with source code please email me.

 


Monday, August 25, 2008 #

One of the main things you should consider if you believe in good coding is error or exception handling. When it come to programming languages, now all popular object oriented languages have try, catch method to handle an exception.

We can put our code (which might gives errors or exceptions) inside the try block and error handling code in the catch block. This has become the de-facto of error or exception handling now.
But when it comes to T-SQL we hadn’t got that luxury. Error handling in T-SQL was always tedious and tricky job. Most of the time we used not to handle the error at the T-SQL level but handling it in the upper most level. (data access layer or business layer, handling database errors in business layer is a totally wrong practice)

But now in SQL 2005, 2008 you have proper error handling mechanism just like in modern OO languages. You can use try catch in the stored procedures and functions. Actually I knew that I can use try catch in stored procedures but only today I got to know about a more interesting method we can use.

After catching an error what we can to do was a question for me. If it’s in C# or Java we can log the error and may be throw a customized exception to the next layer. (There are so many options in handling errors)
Can you remember throw exception in C#? Of cause you know it. :) Well… we can do the same in T-SQL using RAISERROR function.

Using the RAISERROR is as follows,

BEGIN TRY
    -- RAISERROR with severity 11-19 will cause execution to
    -- jump to the CATCH block.
    RAISERROR ('Error raised in TRY block.', -- Message text.
               16, -- Severity.
               1 -- State.
               );
END TRY
BEGIN CATCH
    DECLARE @ErrorMessage NVARCHAR(4000);
    DECLARE @ErrorSeverity INT;
    DECLARE @ErrorState INT;

    SELECT
        @ErrorMessage = ERROR_MESSAGE(),
        @ErrorSeverity = ERROR_SEVERITY(),
        @ErrorState = ERROR_STATE();

    -- Use RAISERROR inside the CATCH block to return error
    -- information about the original error that caused
    -- execution to jump to the CATCH block.
    RAISERROR (@ErrorMessage, -- Message text.
               @ErrorSeverity, -- Severity.
               @ErrorState -- State.
               );
END CATCH;

Pretty good ha…
You can follow up this more in
MSDN.

 

 


Tuesday, January 29, 2008 #

Well... After 6 months I’m gonna do it again. I don’t know people who used to visit my blog still are doing that. Anyway will tell ya what happened in last 6 months later. :D


Well today I was working on deploying a SharePoint site in 64 bit server. This is the first time I’m putting my hands on x64 bit machines.  If you are used to do or want to do SharePoint deployments and never done that in 64 bit servers just keep in mind below.

There are 2 programming files folders in 64 bit machines. Normal "programming files" folder for x64 bit programs and "programming files (x86)" for 32 bit programs. So when you are using script files or solutions  (wsp files) for deployment make aware of this. More info will follow…. :)

 


Thursday, July 26, 2007 #

Google announced that they have opensourced the Google Singleton Detector, or GSD. Simply GSD is a tool which analyzes Java byte code and detects the use of Singletons.

As they say:

It's not quite as simple as that, however. First, GSD doesn't only detect singletons; it detects four different types of global state, including singletons, hingletons, mingletons and fingletons.Second, it outputs a graph with all these different types of static state highlighted, and shows all the classes that are directly dependent on them. The point of this tool is to allow you to see all of the uses of global state inside a project, as well as how they are all interrelated. Hopefully you'll be able to locate global state that is heavily depended on and remove it.

Well... Now you might think what’s wrong with the good old singleton pattern which we always use freely in every project?  Singleton pattern is the first pattern I learned and used.  

Actually there are some problems with singletons.

Major problem is that it’s hard to write unit tests if you are using singleton classes. How that could be? Well... If your unit tests are really good those should be loosely coupled. That’s mean you should be able to execute your tests without any proper order and yet those tests should be passed. But if your class had used singleton class one method can alter a state of sth in the singleton class and that would effects in the other tests. That’s make your tests are tightly coupled with each other. So you should have to have an order in executing your tests or you should reset your singleton objects in each test.

Ok folks, let’s dig into further on this problem and of cause will try to find some workarounds, in my next blog post.

 


Tuesday, July 17, 2007 #

Visual WebGui










Visual WebGui is the .net answer for GWT (Google Web Toolkit). But it’s seems more powerful than GWT even though it’s not coming from Microsoft and yet it’s open source. Still I hadn’t got time to put my hands on deeply but you can feel it by just browsing their web site and checking the features and comparing those with GWT.
Not like GWT, in Visual WebGui you can use existing windows controls to create your UI.  Major advantage of Visual WebGui over GWT is we can deploy Visual WebGui applications as web applications or desktop applications. That’s a huge step taken by Visual WebGui.  And most importantly Visual WebGui is open source.

And with world best IDE (Visual Studio 2005) you have the ultimate power of designing your graphical user interfaces. Just check these features out by visiting Visual WebGui.

User-Friendly – Visual WebGui was designed to be the next VB6 for the web. Simple to program, simple to deploy. With a full WinForms API and design time support you can start developing complex AJAX applications in seconds with no web know-how.

 

Secured – Visual WebGui was designed to provide for military grade secured AJAX applications by eliminating client side service consumption and business logic processing using an empty client concept. The browser is used as a looking glass to the server that runs the application.

 

Productive – With full WinForms API and design time support, Visual WebGui is almost as productive as R.A.D. platforms without limiting your options. Debug your application the same way you would debug any .NET application free of script debugging nightmares.

 

Powerful – Visual WebGui was designed to support enterprise class applications with unlimited complexity supported by full object oriented programming. Using our unique AJAX transport, Visual WebGui applications consume 1% of bandwidth compared to any alternative AJAX framework.

 

Feature-Rich – Visual WebGui contains most of WinForm's components including non trivial implementations of controls such as the PropertyGrid that provides a simple way to edit live objects. 

 

Supported - Visual WebGui is supported by its Core Team of developers and a dedicated international community. Through online forums and our support@visualwebgui.com mail box support is always close at hand (commercial support will be available soon).

 

Easily Installed – Visual WebGui comes with a simple installation that will get you started on developing your AJAX application in no time. Visual WebGui's toolbox and templates are integrated into Visual Studio so they are always available.

 

Localized – Visual WebGui includes full .NET and WinForms multi-language localization support which allows you to localize your application in the designer the same way you localize a WinForms application.

 

Open Source – Visual WebGui SDK is provided free, as open-source software, and licensed under a standard LGPL agreement. It allows individuals to do whatever they wish with the application framework, both commercially and non-commercially.

 

Cutting-Edge – Visual WebGui provides the developer with full object oriented .NET support allowing utilization of all the .NET capabilities including reflection, generics and more. This is enabled by a unique architecture that provides an alternative HTTP processing pipeline that does not include serializing JavaScript.

 

Extensible – Visual WebGui is provided with many customization and extensibility features including custom control creation, theme creation and gateways.

 

Interopable – As an extension to ASP.NET, Visual WebGui can also interact with standard ASP.NET pages hosting them within your Visual WebGui application or calling Visual WebGui dialogs and forms from your ASP.NET code.

 

Visual WebGui's roadmap includes…

 

Mono deployment - Allowing your Visual WebGui application to run on non Microsoft servers (Visual WebGui for .NET 1.1 is already compatible with mono).

 

Legacy to web – Migrating WinForms or VB6 applications to web with out rewriting your application.

 

Dual mode deployment – Deploy your Visual WebGui application as a desktop application or a web application enjoying the best of both worlds.


Sunday, July 15, 2007 #

Well guys... If you have read my previous blog post about Guice and you are using only .net technologies you might got little bit worried of that why you can’t use such a nice framework. Don’t worry, there is a project going on at Google called Titan that inspired by Guice. It’s still in the beta stage though. It’s a pre-release version and they don’t recommend it using in mission critical applications.

Titan is a new take on inversion of control for .NET 2.0 applications, inspired largely by Bob Lee and Kevin Bourrillion's Guice. Ultra-lightweight, easy to use, fast, flexible, and powerful, Titan aims to make inversion of control accessible to all types of .NET projects, regardless of complexity.

Goals of Titan:

1. Ultra-lightweight. We aim to keep all baseline functionality in a single assembly with no non-standard dependencies, and keep that assembly's footprint around 100KB when compiled for release. (The current version weighs in at 96KB.)

2. Easy to use. Too many of the existing IoC projects sacrifice usability for features that aren't often used. Each time a feature is added to Titan, its benefit is weighed against the complexity it adds. Our goal is to keep the 'barrier to entry' -- the baseline level of knowledge required to use Titan -- as low as possible. Titan has many advanced features, but understanding them is not required to use the toolkit.

3. Fast. Instead of relying on reflection for invocation, Titan takes advantage of the lightweight code generation features in version 2.0 of the CLR. This results in a dramatic (8-50x) improvement in speed.

4. Flexible and extensible. Titan is designed with customization and evolution in mind. Many facets of the system can be augmented or modified to fit the requirements of each project.

5. Powerful. Titan includes many advanced features. For example, most existing IoC frameworks use key-based binding to select concrete components for injection. Titan introduces the concept of contextual binding, in which a different concrete implementation of a service may be injected depending on the context in which it is requested.

http://code.google.com/p/titan-ioc/


Saturday, July 14, 2007 #

Doing some R&D works on GWT a few weeks back, I really fascinated on the Google frameworks. Next Google framework I’m gonna puts my hands on is Guice: Google way of implementing Dependency Injection.  That isn’t a company assignment but I think its worth to learn and try. Guice (pronounced "juice") is an ultra-lightweight, next-generation dependency injection container for Java 5 and later.

If you have ever tried out to achieve loose coupling to the ultimate extent you really should know about dependency injection. It’s not a buzz word anymore. People are using several of methods and frameworks to implement DI. Couple of years back when I was at my good old place (Logical Systems now known as Kandysoft) I did my first application design on my own. It was an e-commerce web site and I got instructions to develop the application framework as generic as possible. So we can re-use some of it functionalities in other applications. Our focus was on product catalog and shopping cart. Some applications product catalog and shopping cart is not separated but I thought it has to be developed as separated. So I did it and it was a very successful one. At that time I actually had heard about DI and use of it to achieve loose coupling. But only article I had read was
Martin fowlers one and I couldn’t understand it much of it at that time. And for the worse case I had limited time frame to complete and deliver the project as we always do. Anyway I gained what I wanted by  using interfaces and now I know I have implemented dependency injection by hand even though I didn’t know  I was doing that.

BTW now there are so many application frameworks that leverage use of DI and some related functionalities. I think spring is in the top. They are hitting both java and .net so it’s a great framework to developers like me who focused on both java and .net.

But if you are new to DI and doing java I think Guice is the best to put your hands on first. Like all Google frameworks it simple and easy to learn. I’ll shed some posts later on DI and Guice.


Wednesday, July 11, 2007 #

Check this out. Worth to see.

http://www.glumbert.com/media/battlespecies

Thx Senthil for the url.


Sunday, June 24, 2007 #

There is a good audio talk show in .net Rocks with Mark Pollack who founded Spring.Net. Particularly this show would be more useful if you are not aware of the potential of Spring.Net.

BTW Spring.Net has announced the release of  Spring.NET 1.1 M1 (Milestone 1). 
New features and improvements in the release are below.

    * NUnit Integration:  Aids in writing integration tests. Configuration of test cases via dependency injection and automatic transaction rollback
    * NHibernate 1.0/1.2 Integration:  Simplify use of NHibernate and participation in Spring's declarative management
    * ASP.NET AJAX Integration:  Export 'plain .NET objects' as web service, configure and apply aspects to them, and then expose inside client side Javascript.
    * Transaction and AOP XML namespaces to simplify configuration.
    * AOP support for methods with out/ref parameters.
    * Sample NHibernate application.
    * Numerous bug fixes and improvements.