Thursday, March 8, 2007

HRESULT -2147012867, Native Error 28037 on Merge Replication

When using a handheld device emulator to perform merge replication, you may receive this error when trying to synchronize. The reason might be very simple: the emulator may not have its network card turned on. It is not enabled by default for the PocketPC 2003 emulator.

For identification, the full managed error description is:
System.Data.SqlServerCe.SqlCeException was unhandled HResult=-2147012867 Message="A request to send data to the computer running IIS has failed. For more information, see HRESULT." NativeError=28037 Source="Microsoft SQL Server Compact Edition" StackTrace: at System.Data.SqlServerCe.NativeMethods.CheckHRESULT() at System.Data.SqlServerCe.SqlCeReplication.Synchronize() at SQLMobile.Form1.Synch() at SQLMobile.Form1.Form1_Load() at System.Windows.Forms.Form.OnLoad() at System.Windows.Forms.Form._SetVisibleNotify() at System.Windows.Forms.Control.set_Visible() at System.Windows.Forms.Application.Run() at SQLMobile.Form1.Main()

Wednesday, January 24, 2007

If GridView doesn't update data on Update command

Suppose you have set all parameters and the UPDATE statement properly, databound all controls, but the data is still not updated. In that case, you should check the DataKeyNames property of the GridView component to ensure that the property is not blank. This can occur if you are customizing the GridView datasource without using the wizard.

Input validation can't be reused in GridView templates

In the GridView, it's possible to define a blank template and another template will be used in place, e.g. if InsertItemTemplate is empty, the EditItemTemplate is used instead. Therefore, if they are supposed to be the same, just make sure EditItemTemplate is blank.

However, one thing to note is that the input validation control will not be duplicated. Therefore, if input validation is required (which it usually is), then, the control must be duplicated.

Tuesday, January 23, 2007

Solving error Code 2714 for Windows Installer

If you receive this error while running a built installation package:

"The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2714."

..it means that the path specified for the installation package is incorrect. There is nothing the user can do about this since it's a problem with the package itself. Basically, ensure that the DefaultLocation property is correctly set to the full path of the directory to create and that the path is valid. The '(Name)' property is actually not used to name the folder on the target computer, it is rather an internal name used in the installer.

Monday, January 22, 2007

Solving Unable to cast object of type 'ProfileCommon' to type 'ProfileCommon' error

I uncovered yet another strange behavior of ASP.NET which was mentioned by Alex Thissen at http://www.alexthissen.nl/blogs/main/archive/2005/05/31/asp-net-2-0-need-to-know-thingies-for-beta2.aspx.

Although Alex mentioned this to be a problem with Beta2, it can also occur on the relase version, e.g. Microsoft .NET Framework Version:2.0.50727.91; ASP.NET Version:2.0.50727.210.

I got this error:
Unable to cast object of type 'ProfileCommon' to type 'ProfileCommon'.
[InvalidCastException: Unable to cast object of type 'ProfileCommon' to type 'ProfileCommon'.] MasterPageCls.get_Profile() +67
MasterPageCls.SetDefaultZoningSystem() in c:\inetpub\...\MasterPage.vb:33
MasterPageCls.InitZSID() in c...\MasterPage.vb:152
MasterPageCls.Page_Load1(Object sender, EventArgs e) in ...\MasterPage.vb:186
System.Web.UI.Control.OnLoad(EventArgs e) +99 System.Web.UI.Control.LoadRecursive() +47 System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061

The resolution? Simply making a simple change in web.config for the application and saving it again, which worked. Referring to an earlier post on my blog, this time, clearing the temporary folder did not resolve the problem.

I find this error strange and a bit confusing. If the type has the same name, why can't I cast it? And what does an invalidated web.config have to do a class in the membership provider anyway?

Clearing up ASP.NET temporary file

Sometimes you may be getting unexpected error caused by configuration changes on the web server on pages that have been working correctly before. These errors may be due to the fact that the precompiled ASP.NET pages are out of date and that the temporary files have not been updated as they should automatically, which can, and does happen sometimes.

It can therefore help to clear the temporary folder:
C:\windows\microsoft.net\framework\v2.0.50727\temporary asp.net files
(Note: must be on the web server, not the local computer if your dev box is not on the iis box).

If you are unsure, move all subfolders and file out of the folder and test your site before deleting. These are not primary files created by the user so deleting them does not affect the source files of the site. However, deleting them will slow down access since compilation has to happen again for the site.

An example of this happened when I was installing FrontPage 2002 server extensions on W2K3 server, IIS 6.0. Then I suddenly got the error (asp.net error) access to the path ... \web.config is denied. No relevant source lines, source: web.config in wwwroot, line 0. Very odd indeed! And the error was pretty far from a security error, in fact, just clearing the temporary folder mentioned above solved the problem. Likewise, the uninstallation of FP2002 S.E. caused the error to occur again. Again, clearing the asp.net temp folder was the solution.

I'd say this is something you may try if "nothing else makes sense" and the "errors don't make sense" with asp.net..

Powerful input checking

Perhaps one of the most flexible and powerful ways to validate user input in any ASP.NET page is regular expressions.

If you have not heard about it yet, visit
http://msdn2.microsoft.com/en-us/library/ms998267.aspx