Wednesday, November 18, 2009

IIS Web Core Notification - BeginRequest Handler Not yet determined Error Code 0x800700b7 Config Error Cannot add duplicate collection entry of type 'add' with unique key attribute 'name' set to 'ScriptHandlerFactory'

 

Situation

1. Visual studio 2008 SP1

2. IIS 7

3. Hosting WCF within site with a VDir.

This happens typically when you are hosting with hosting provider.

If you create a website in main folder (Which will be by default ) and you host a ASP.NET web site. Doesn't matter if it is AJAX or simple website. With SP1, we have 'ScriptHandlerFactory' with any web application.The site works perfectly.

 

Now if you are creating a service say a WCF service under a Vdir in this site, you will have a different Web.config for your service. Service will run fine locally. When hosted, The website will inherits the settings form parent level . This should be the reason of this issue. You can check if there is a web.fig file in the parent web content folder and an duplicate collection entry in it.

Typically a duplicate entry from services config needs to be removed.

Monday, September 07, 2009

Google App Engine – Can it replace Microsoft share Point?

It was fun reading the article at http://googleappengine.blogspot.com/2009/09/app-engine-sdk-125-released-for-python.html

Google app engine is now supported over windows as well. here are my observations -

1. Go to world with your web application within minuets. Could not find any Microsoft product / service in competition to this. 

2. Use Goggle’s Infrastructure to host, bandwidth and CPU time upto 5 million users per months for FREE!!!

3. Pay as you use after that.

4. Extensive integration with Eclipse and one click deployments.

5. Super cool UI with Google analytics and dashboard and I was feeling like I am in datacenter with my laptop.

6. Here is the Kicker – User JDO (Java data objects) and Google Authentication to use authenticate your users.

7. URL mapping off-course. Users wont even know that your www.xyz.com is hosted on Google servers.

I was thinking if any one can use the templated Servlet to create a team site like in sharepoint, then there is no licensing, now no more deployments and developmet and UI? is just like you any web development. On top of that you can convert the old apps as Google app engine app and host it on Google.

Is this a Google’s answer to sharepoint and Microsoft Cloud computing?

Tuesday, September 01, 2009

New Trend in Application development for IT organizations.

Just wanted to put a quick note on a great article that I came across here.

This is a poll conducted by Gilbane Group on Facebook for finding out the future of collaboration technology in near future.

This un-official  poll was for 1000 users and for different age group 18-24 and 25- 34

here are the results - gilbane_facebook_poll_6_19_07

Here is what I think -

1. People want to take the collaboration technology in their everyday business. More younger people would do this more Look at the SMS text Mode.

2. Social networking and Blogs are not very Popular – Will today’s Tons of Startups in social networking survive?

3. Future information worker will try to use new modes of IT not only as communication medium but in their everyday life and at work .

4. IT organizations should recognize this trend and seek to provide solutions with the flexibility to meet the technology demands of information workers.

Silverlight3 GridView Binding, LoadingRow events and Textblock traps

Those from ASP.NET background, moving forward to silverlight3 and playing around with Grid view my get frustrated at times. Grid view is one of the most widely used controls and we do want to change the contents of the Grid when we Bind the data. Sounds very simple but could be tricky at times.

I was developing prototype in Silverlight and Found few interesting things and thought I would share.

  1. So you bind the data to a grid, using AutoGenerate columns or not, Doesnt matter. To track the "GridView.RowDataBound" on row data bound event you create a backend event handler like this.
    grdEntries.LoadingRow += new EventHandler(grdEntries_LoadingRow);
  2. Getting event handler is tricky, here is how you get it working.  Note the 3 methods of getting the cell content in C# code. image

About this get parent function – this casts the cell to appropriate type – Note the way this function is called recursively.

The Above code may not work when you scroll the grid, for some wired reason it keeps binding the data again and again. For this, Alternative solution could be to use the individual column loaded even. Here is how you do it.

Both type of columns are shown here

<!--<data:DataGridTextColumn Binding="{Binding Date}" Header="Entry Date" Width="175"/>--> regular column which works with LoadingRow event handler

<data:DataGridTemplateColumn Header="Date" SortMemberPath="Date">
<data:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Loaded="TextBlock_Loaded" x:Name="txtDate" Text="{Binding Date}">
</TextBlock>
</DataTemplate>
</data:DataGridTemplateColumn.CellTemplate>
</data:DataGridTemplateColumn>

In the code behind, track the column and change the text or whatever you want to do.

void TextBlock_Loaded(object sender, EventArgs e)

     {

          TextBlock tb = sender as TextBlock;

          tb.Text = "Amol";

      }


Now why we have so many options? There are some performance reasons in data grid and it all depends which one to use whe. Typically, if you want to change data every time you bind grid, go with Loading row handler. If it static change and grid is not going to change then use the column loaded event.

Thanks

Friday, August 28, 2009

Passing Parameters to Silverlight 3 Application from ASP.NET

Steve has excellent article here

However, For starters, I thought I would put down the steps quickly here

1. biggest change and where I struggled, How to create a parameter in ASP.NET page, the control is gone. Well, is here to help us. In the Object Tag, add line  -



2. in Code behind in ASPX, use this control to set the property on any event. 2 things to remember here, Use the ".Text" to set the key value pair like this.
Source.Text ="Param1="+ Param1.ToString();

3. In App.xaml.cs, in Application_Startup event, simply add  2 lines, and your total code should look like
this.RootVisual = new MainPage();
foreach (var data in e.InitParams)
   this.Resources.Add(data.Key, data.Value);

4. In MainPage.xaml.cs you want to access this, Simply use following construct.
App.Current.Resources["Param1"].ToString();
Note - Create a Loaded even in MainPage.xaml otherwise we will get. Final code should look like


public MainPage()

{    InitializeComponent();
    this.Loaded += new RoutedEventHandler(MainPage_Loaded);
}


void MainPage_Loaded(object sender, RoutedEventArgs e)
{     string param 1 = App.Current.Resources["Param1"].ToString();
}

Tuesday, March 10, 2009

The 'Microsoft.Jet.OLEDB.12.0' provider is not registered on the local machine !!

This is rather simple error to Fix if you are a developer and building small scale application.

Error comes becase you dont have Office 2007 installed on machine. Most of developers install it and goet going :)

Few other they go for http://www.microsoft.com/downloads/details.aspx?familyid=7554F536-8C28-4598-9B72-EF94E038C891&displaylang=en - Better way,

PROBLEM -

1. Lets say you are hosting your web site on shared host server. Hosting company may not install this Driver!!!!!

2. Another bigger problem, if your application is load balanced, how do you or hosting company know where to install this driver? On all nodes?

There is a intersesting solution to this problem, Cant share here. Hope microsoft will address this with MDAC and OS install :)

Saturday, October 18, 2008

SQL Server 2008 Alter Table - Saving Changes Not Permitted ???

Do you get this error and freak out?






























Saving changes is not permitted. The changes you have made require the following tables to be dropped and re-created. You have either made changes to a table that can't be re-created or enabled the option Prevent saving changes that require the table to be re-created.




LETS NOT GET INTO WHY IT IS LIKE THIS :)




Do this instead




Go to tools - Options and do as pointed out. - Thanks























Monday, October 13, 2008

T-SQL - If the Day is week day OR week end

Many Application needs this so trying to post this.

( I am not the author of this bu thought to help all by posting it here)

create function fn_IsWeekDay
(
@date datetime
)
returns bit
as
begin
declare @dtfirst int
declare @dtweek int
declare @iswkday bit
set @dtfirst = @@datefirst - 1
set @dtweek = datepart(weekday, @date) - 1
if (@dtfirst + @dtweek) % 7 not in (5, 6)
set @iswkday = 1 --business day
else
set @iswkday = 0 --weekend
return @iswkday
end


Short and sweet.

Now you can simply do this: (USAGE)


if dbo.fn_IsWeekDay(@date) = 1
begin
--do some magic here ;-)
end
--or
select a.SomeFieldsForCalculation from table a where dbo.fn_IsWeekDay(a.SomeDateField) = 1



and all is good.

Thursday, September 25, 2008

Simple Memory Management Stuff.


I belive that Once the code is written it lives for ever. Write it best for the first time. No One lakies to refactor it.
consider yourself fortunate if you are getting opportunity to wrte the code from scratch ang follow these simple things.
More to come

Monday, September 22, 2008

UNICEF - Be a member. It really helps

Hello,

Here I am to request who ever read this post. We all know that there are some among us that cant even think of looking at computer. I really feel bad about those who are disabled and its not their fault.

I have joined UNICEF. Its my urge to you all to join.

It doesn't take that much from your life an pocket.

http://www.unicef.org/

thanks

Thursday, September 18, 2008

How can I maintain the format of text in a multiline textbox when saving to sql server ie new lines paragraphs etc in ASP.NET

Very common scenario - Here are my Thoughts

1. If you are using multiline text box (built in asp.net) - You can only save the New lines.

here is a quick c# code.

string FinalString = MultilineTextBox.Text.Replace("\r\n","");

and then save it in regular fashion in SQL server. Make sure to turn off the page validation request. i.e. ValidateRequest="false" at page level.

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

2. Very Elgant, Less time consuming, and FREE way to do it.

a. Go to Free Text Box and download.
b. Put the DLL in Bin of your website.
c. Add a tag in your page.

<FTB:FreeTextBox id="txtDesc"
ToolbarLayout="ParagraphMenu, FontFacesMenu, FontSizesMenu, FontForeColorsMenu,
FontForeColorPicker, FontBackColorsMenu, FontBackColorPicker, Bold, Italic, runat="Server" Width="800px"/
>


d. This is server side control and directly give you HTML when you acesses the Text property in code behind. Save it in the SQL server as nvarchar and you are good to go.

thanks.

(Leave a comment if this helped you)

Validating Image File for Content Type with ASP.NET FileUpload web control.

We use file upload web control in our sites, where we want only valid image types to be uploaded.
Without talking much -> here are 3 ways to do it.

1. Accept attribute of fileUpload control - Doesnt work with most of the browsers (Bad with IE itself)

2. Regular Expression validator for FileUpload



This is Not very handy when using AJAX controls on page- Both javascripts dont like each other :)

3. Write a code behind function in a very simple way - Most robust way to use it. - Very Generic can be used for any file types.

C# code
private bool IsFileValid()
{
string [] allowedImageTyps = {"image/gif", "image/pjpeg", "image/bmp","image/x- png"};
StringCollection imageTypes = new StringCollection();
imageTypes.AddRange(allowedImageTyps);
if (imageTypes.Contains(FileUpload1.PostedFile.ContentType))
return true;
else
{
return false;
}
}

NOTE - use FileUpload1.PostedFile.ContentType and not the file name to check the Extension

Leave a comment if this helped you

Tuesday, March 22, 2005

Installing VSTS 2005 - Installation Problem Error Code 2350

Microsoft has a KB that talks about troubleshooting Visual Studio.NET installation, but that really not helpful in this context.

To Reolve this Issue, Please do the following

1. Go to Start Menu -> Run -> Installer
This will open the installer directory For You. Locate the .NET farmework beta 2 installer,
2. Right Click and Say Uninstall.
This will uninstall the ol frame work.

Now start the VSTS Installation,

Note:- If you install SQL Server 2005, Please uninstall it, as the framework with SQL server 2005 is different than ships with the Whidbey,

Please read the guide provided by Microsoft on installing the Tem foundation server - very Useful