Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
3.33/5 (2 votes)
See more:
HEllo Team,

While debugging ,I am getting the error as follows .

"Object synchronization method was called from an unsynchronized block of code."


I have the code as follows :
I am getting the error in Global.asax:

XML
public class Global : System.Web.HttpApplication
    {
        /// <summary>
        /// The Application_Start event fires when application starts first time.
        /// </summary>
        /// <param name="sender">The sender object page.</param>
        /// <param name="e">An event arguments</param>
        protected void Application_Start(object sender, EventArgs e)
        {
            Logger.Write("Preparing cache in Application_Start event started", LogType.Information);
            Kaizen2GController kaizen2GController = new Kaizen2GController();
            Logger.Write("Preparing cache in for combined masters started", LogType.Information);
            kaizen2GController.GetDsitinctCombinedMasterRecords(null);
            Logger.Write("Preparing cache in for combined masters ends", LogType.Information);
            Logger.Write("Preparing cache in for filtered circles start", LogType.Information);
            kaizen2GController.GetFilteredCircles(null);
            Logger.Write("Preparing cache in for filtered circles ends", LogType.Information);
            Logger.Write("Preparing cache in for Regions start", LogType.Information);
            kaizen2GController.GetRegions();
            Logger.Write("Preparing cache in for region ends", LogType.Information);
            Logger.Write("Preparing cache in for CFR Master start", LogType.Information);
            kaizen2GController.GetCfrMasters();
            Logger.Write("Preparing cache in for CFR Master ends", LogType.Information);
            Logger.Write("Preparing cache in Application_Start event Ended", LogType.Information);
        }
}


Exactly i am getting the error on line
Kaizen2GController kaizen2GController = new Kaizen2GController();


I am not getting any idea .Please guide me if you can.
Wher and how i can find the unsynchronized block of code."

Thanks
Harshal
Posted
Updated 30-Apr-14 21:19pm
v2
Comments
Sampath Lokuge 1-May-14 3:32am    
Can you put the code snippet for the 'Kaizen2GController' ?
R Harshal 1-May-14 3:45am    
This is my login page .As this error comes before the Login PAge:
namespace Kaizen.UI.WEB.Kaizen2G
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.UI;
using System.Web.UI.WebControls;
using Kaizen.Entities.UserManagement;
using Kaizen.Framework;
using Kaizen.UI.Controller;

///
/// The Login code bhind class.
///

public partial class Login : System.Web.UI.Page
{
#region Properties
///
/// Gets or sets the user entity instance
///

public static string UserEntity { get; set; }

///
/// Gets UserEntity Entity instance.
///

public string GetUserEntity
{
get
{
return UserManagementEntityCreator.GetUserEntity().ConvertToJsonString();
}
}

///
/// Get The User Identity
///

/// <param name ="userDetails">The User entity.</param>
/// <returns>The Results of User
[WebMethod]
public static string AuthenticateUser(object userDetails)
{
string errorMessage = string.Empty;
IUserEntity userEntity = UserManagementEntityCreator.GetUserEntity();
try
{
UserManagementController userManagementController = new UserManagementController();
////UserEntity = userManagementController.GetDetails(userEntity).EntityCollection.ConvertToJsonString();
userEntity = userDetails.ConvertToJsonString().JsonToObject(userEntity.GetType()) as IUserEntity;
Result result = userManagementController.Get(userEntity);
userEntity = result.Entity as IUserEntity;
HttpContext.Current.Session[KaizenConstants.CURRENTLOGGEDINUSER] = userEntity;
}
catch (Exception exception)
{
errorMessage = string.Format("Technical error ocurred. {0}. Please contact to system administrator.", exception.Message);
}

return userEntity.IsValid ? userEntity.ConvertToJsonString() : string.Empty;
}

#endregion
///
/// Page Load Method
///

/// <param name="sender">sender as object</param>
/// <param name="e">EventArgs e</param>
protected void Page_Load(object sender, EventArgs e)
{
//// test
}
}
}

And Secondily this is my Kaizen2GController page
namespace Kaizen.UI.Controller
{
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Kaizen.Entities.Kaizen2G;
using Kaizen.Entities.UserManagement;
using Kaizen.Framework;
using Kaizen.ServiceManager;
using Kaizen.UI.ControllerInterfaces;
using System.IO;
using System.Text;
using System;

///
/// This class Kaizen2GController
///

public class Kaizen2GController : IKaizen2GController
{
#region Properties
///
/// Gets or sets the Kaizen2GService instance.
///

private Kaizen2GService kaizen2GService { get; set; }

///
/// Gets or sets the current logged in user;
///

private IUserEntity User
{
get
{
return HttpContext.Current.Session[KaizenConstants.CURRENTLOGGEDINUSER] as IUserEntity;
}
}
#endregion

#region Constructors
///
/// Initializes a new instance of the DashboardController class.
///

public Kaizen2GController()
{
// this.dashboardService = ServiceFactory.GetDashboardServ
Sampath Lokuge 1-May-14 3:50am    
You have not put whole code of the 'Kaizen2GController'.Please put that ?
R Harshal 1-May-14 3:57am    
this.kaizen2GService = new Kaizen2GService();
}
#endregion

#region Public Methods
///
/// Delete list of records from cache.
///

/// <param name="deleteCollection">The list of records to delete.</param>
/// <returns>The result of batch operation.
public Result Delete(IEntityCollectionBase deleteCollection)
{
return null;
}

///
/// Get the details of entity.
///

/// <param name="entityBase">The entity to Get the details.</param>
/// <returns>The result with the details.
public Result Get(IEntityBase entityBase)
{
return null;
}

///
/// Get the details of entity.
///

/// <param name="Key">The key to get details.</param>
/// <returns>The result with the details.
public Result Get(int Key)
{
return null;
}

///
/// Get list of records.
///

/// <returns>The result with list of records.
public Result GetList()
{
return null;
}

///
/// Save record details.
///

/// <param name="entityBase">The entity to save details.</param>
/// <returns>The result of operation.
public Result Save(IEntityBase entityBase)
{
return null;
}

///
/// Search records based on serach criteria.
///

/// <param name="entityBase">The entity containe search criteria.</param>
/// <returns>The result of serach operation.
public Result Search(IEntityBase entityBase)
{
return null;
}

///
/// Get the list of regions.
///

/// <returns>the list of regions.
public Result GetRegions()
{
Result result = null;
if (this.kaizen2GService != null)
{
result = this.kaizen2GService.GetRegions();
}

return result;
}

///
/// Get the filtered circles from regions.
///

/// <param name="graphFilter">The filter enity.</param>
/// <returns>list of circles.
public Result GetFilteredCircles(IEntityBase graphFilter)
{
Result result = null;
if (this.kaizen2GService != null)
{
result = this.kaizen2GService.GetFilteredCircles(graphFilter);
}

return result;
}

///
/// Get the CFR master records.
///

/// <returns>list of circles.
public Result GetCfrMasters()
{
Result result = null;
if (this.kaizen2GService != null)
{
result = this.kaizen2GService.GetCfrMasters();
}

return result;
}

///
/// Get the distinct region, circle, districts , town, bsc and sam.
///

/// <param name="graphFilter">The filter enity.</param>
/// <returns>list of distinct region, circle, districts , town, bsc and sam..
public Result GetDsitinctCombinedMasterRecords(IEntityBase graphFilter)
{
Result result = null;
if (this.kaizen2GService != null)
{
result = this.kaizen2GService.GetDsitinctCombinedMasterRecords(graphFilter);
}

return result;
}

///
/// Get data from data base and prepare graph series according to users selection.
///
Sampath Lokuge 1-May-14 4:04am    
Are you using any asynchronous requests some where on your code ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900