Wednesday, November 26, 2008

Cannot create/shadow copy 'VariousFileName' when that file already exists

"Cannot create/shadow copy 'VariousFileName' when that file already exists" is a .NET problem with a quick cure.

Try this first: If you just made a change to a file in the App_Code directory, wait for Visual Studio to finish compiling and stabilizing. This message comes up often if you have been debugging or working with some code and then make a quick change in an App_Code directory file. If this doesn't work, go to the following.

There's a web.config solution for this problem: adding to the system.web element of your web.config file.

The 'shadowCopyBinAssemblies' property is described as follows: Sets a Boolean value indicating whether the assemblies of an application in the Bin directory are shadow copied to the application's ASP.NET Temporary Files directory.



Tuesday, November 18, 2008

Object reference not set to an instance of an object

I got the followings error message when I deployed the website to web server
Type: System.NullReferenceException
Message: Object reference not set to an instance of an object.
Source: System.Web.Extensions
TargetSite: System.Web.Script.Services.WebServiceData GetWebServiceData(System.Web.HttpContext, System.String, Boolean, Boolean)
Stack Trace:
at System.Web.Script.Services.WebServiceData.GetWebServiceData(HttpContext context, String virtualPath, Boolean failIfNoData, Boolean pageMethods)
at System.Web.Script.Services.PageClientProxyGenerator.GetClientProxyScript(HttpContext context, IPage page, Boolean debug)
at System.Web.UI.ScriptManager.RegisterServices()
at System.Web.UI.ScriptManager.OnPagePreRenderComplete(Object sender, EventArgs e)
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.Web.UI.Page.OnPreRenderComplete(EventArgs e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)


Turn on "Allow this precompiled site to be updatable" and "Use fixed naming and single page assemblies"

Friday, November 14, 2008

ASP.NET Ajax Asynchronize call back

Microsoft ASP.NET Ajax is a very powerful Ajax framework. However, when you build a real Ajax site like those out there in the Web 2.0 world, you face many problems that you will hardly find documented anywhere. In this article, I will show some advance-level ideas that I learned while building Pageflakes. We will look at the advantages and disadvantages of Batch calls, Ajax call timeouts, browser call jam problems, ASP.NET 2.0's bug in web service response caching, and so on.

Omar Al Zabir has very good explanation in his article http://www.codeproject.com/KB/ajax/aspnetajaxtips.aspx

Thursday, November 13, 2008

Common Mistake In SQL

In the follwing sql codes, the @FieldValue didn’t get set if the current @Name doesn’t exist in the table PcsValues.

fetch next from curPCSValues into @Name

while @@fetch_status = 0
begin

select @FieldValue = v.Throughput
from PcsValues WHERE pcsName = @Name

fetch next from curPCSValues into @Name
end
The sql code should change to the following in order to make it work as expecting
fetch next from curPCSValues into @Name

while @@fetch_status = 0
begin
set @FieldValue = 0

select @FieldValue = v.Throughput
from PcsValues WHERE pcsName = @Name

fetch next from curPCSValues into @Name
end

Wednesday, November 12, 2008

Today Minus one day in SQL

SELECT DATEADD(day, -1, GETDATE())

How to get the Fourth Monday of Current Month

The following sql function will return the Fourth Monday of the Current Month.

CREATE FUNCTION [dbo].[GetFourthMondayOfCurrentMonth]
(

)
RETURNS DATETIME
BEGIN
declare @Today as datetime
declare @FirstMonday as datetime
declare @FourthMonday as datetime
set @Today = getdate()

select @FirstMonday = DATEADD(wk, DATEDIFF(wk,0,dateadd(dd,6-datepart(day,@Today),@Today)),0)

set @FourthMonday = DATEADD(day,21,@FirstMonday)

return @FourthMonday
END

Saturday, November 08, 2008

Database diagram support objects cannot be installed because this database does not have a valid owner

I got the following error message when I clicked on database diagrams in Microsoft SQL Server Management Studio 2005.

Database diagram support objects cannot be installed because this database does not have a valid owner. To continue, first use the Files page of the Database Properties dialog box or the ALTER AUTHORIZATION statement to set the database owner to a valid login, then add the database diagram support objects.

I have upgrade the database to the level 90 by the following step but it is not working.

In SQL Server Management Studio do the following:

1. Right Click on your database, choose properties
2. Goto the Options Page
3. In the Dropdown at right labeled "Compatibility Level" choose "SQL Server 2005(90)"

I got it working after I execute the following command to transfer the database ownership to sa

ALTER AUTHORIZATION ON DATABASE::DatabaseName TO sa