Handle "Cannot access a closed resource set" - asp.net

I have a website with several languages in a database. From the database I use ResXResourceWriter to create my .resx files. This is working really good but sometimes I get this exception:
MESSAGE: Cannot access a closed resource set.
SOURCE: mscorlib
FORM:
QUERYSTRING:
TARGETSITE: System.Object GetObject(System.String, Boolean, Boolean)
STACKTRACE: at System.Resources.RuntimeResourceSet.GetObject(String key, Boolean ignoreCase, Boolean isString)
at System.Resources.RuntimeResourceSet.GetString(String key, Boolean ignoreCase)
at System.Resources.ResourceManager.GetString(String name, CultureInfo culture)
at System.Linq.Expressions.Expression.ValidateStaticOrInstanceMethod(Expression instance, MethodInfo method)
at System.Linq.Expressions.Expression.Call(Expression instance, MethodInfo method, IEnumerable`1 arguments)
at System.Data.Linq.DataContext.GetMethodCall(Object instance, MethodInfo methodInfo, Object[] parameters)
at System.Data.Linq.DataContext.ExecuteMethodCall(Object instance, MethodInfo methodInfo, Object[] parameters)
at Business.DatabaseModelDataContext.Web_GetMostPlayedEvents(String cultureCode)
at Presentation.Default.Page_Load(Object sender, EventArgs e)
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
I don't know why this is happening or how to solve it. Does anyone know anything about this?
Thanks,
Philip

I suspect you closed your DataSource prematurely or didn't close it at all when your program routine is about to end?

Related

Page_Init() being called twice

The Page_Init() method of my page is being called twice before it is first displayed. In both cases, IsPostBack==false. I have AutoEventWireup="true" set. Here are the two stack traces for when it's being called:
First call:
G2.dll!Ctron.UI.Common.BreakoutDialog.Page_Init(object sender, System.EventArgs e) Line 46 C#
System.Web.dll!System.Web.Util.CalliEventHandlerDelegateProxy.Callback(object sender, System.EventArgs e) Unknown
System.Web.dll!System.Web.UI.Control.OnInit(System.EventArgs e) Unknown
System.Web.dll!System.Web.UI.Page.OnInit(System.EventArgs e) Unknown
CXGlobal.dll!Ctron.UI.CtronDialog.OnInit(System.EventArgs e) Line 27 C#
System.Web.dll!System.Web.UI.Control.InitRecursive(System.Web.UI.Control namingContainer) Unknown
System.Web.dll!System.Web.UI.Page.ProcessRequestMain(bool includeStagesBeforeAsyncPoint, bool includeStagesAfterAsyncPoint) Unknown
System.Web.dll!System.Web.UI.Page.ProcessRequest(bool includeStagesBeforeAsyncPoint, bool includeStagesAfterAsyncPoint) Unknown
System.Web.dll!System.Web.UI.Page.ProcessRequest() Unknown
System.Web.dll!System.Web.UI.Page.ProcessRequestWithNoAssert(System.Web.HttpContext context) Unknown
System.Web.dll!System.Web.UI.Page.ProcessRequest(System.Web.HttpContext context) Unknown
App_Web_g2ej3jrk.dll!ASP.common_breakoutdialog_aspx.ProcessRequest(System.Web.HttpContext context) C#
System.Web.dll!System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() Unknown
System.Web.dll!System.Web.HttpApplication.ExecuteStep(System.Web.HttpApplication.IExecutionStep step, ref bool completedSynchronously) Unknown
System.Web.dll!System.Web.HttpApplication.ApplicationStepManager.ResumeSteps(System.Exception error) Unknown
System.Web.dll!System.Web.HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(System.Web.HttpContext context, System.AsyncCallback cb, object extraData) Unknown
System.Web.dll!System.Web.HttpRuntime.ProcessRequestInternal(System.Web.HttpWorkerRequest wr) Unknown
System.Web.dll!System.Web.HttpRuntime.ProcessRequestNoDemand(System.Web.HttpWorkerRequest wr) Unknown
System.Web.dll!System.Web.Hosting.ISAPIRuntime.ProcessRequest(System.IntPtr ecb, int iWRType) Unknown
System.Web.dll!System.Web.Hosting.ISAPIRuntime.System.Web.Hosting.IISAPIRuntime2.ProcessRequest(System.IntPtr ecb, int iWRType) Unknown
[AppDomain Transition]
Second call:
G2.dll!Ctron.UI.Common.BreakoutDialog.Page_Init(object sender, System.EventArgs e) Line 46 C#
System.Web.dll!System.Web.Util.CalliEventHandlerDelegateProxy.Callback(object sender, System.EventArgs e) Unknown
System.Web.dll!System.Web.UI.Control.OnInit(System.EventArgs e) Unknown
System.Web.dll!System.Web.UI.Page.OnInit(System.EventArgs e) Unknown
CXGlobal.dll!Ctron.UI.CtronDialog.OnInit(System.EventArgs e) Line 27 C#
System.Web.dll!System.Web.UI.Control.InitRecursive(System.Web.UI.Control namingContainer) Unknown
System.Web.dll!System.Web.UI.Page.ProcessRequestMain(bool includeStagesBeforeAsyncPoint, bool includeStagesAfterAsyncPoint) Unknown
System.Web.dll!System.Web.UI.Page.ProcessRequest(bool includeStagesBeforeAsyncPoint, bool includeStagesAfterAsyncPoint) Unknown
System.Web.dll!System.Web.UI.Page.ProcessRequest() Unknown
System.Web.dll!System.Web.UI.Page.ProcessRequestWithNoAssert(System.Web.HttpContext context) Unknown
System.Web.dll!System.Web.UI.Page.ProcessRequest(System.Web.HttpContext context) Unknown
App_Web_g2ej3jrk.dll!ASP.common_breakoutdialog_aspx.ProcessRequest(System.Web.HttpContext context) C#
System.Web.dll!System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() Unknown
System.Web.dll!System.Web.HttpApplication.ExecuteStep(System.Web.HttpApplication.IExecutionStep step, ref bool completedSynchronously) Unknown
System.Web.dll!System.Web.HttpApplication.ApplicationStepManager.ResumeSteps(System.Exception error) Unknown
System.Web.dll!System.Web.HttpApplication.ResumeStepsFromThreadPoolThread(System.Exception error) Unknown
System.Web.dll!System.Web.HttpApplication.AsyncEventExecutionStep.OnAsyncEventCompletion(System.IAsyncResult ar) Unknown
System.Web.dll!System.Web.HttpAsyncResult.Complete(bool synchronous, object result, System.Exception error, System.Web.RequestNotificationStatus status) Unknown
System.Web.dll!System.Web.SessionState.SessionStateModule.PollLockedSessionCallback(object state) Unknown
mscorlib.dll!System.Threading.TimerQueueTimer.CallCallbackInContext(object state) Unknown
mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Unknown
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Unknown
mscorlib.dll!System.Threading.TimerQueueTimer.CallCallback() Unknown
mscorlib.dll!System.Threading.TimerQueueTimer.Fire() Unknown
mscorlib.dll!System.Threading.TimerQueue.FireNextTimers() Unknown
mscorlib.dll!System.Threading.TimerQueue.AppDomainTimerCallback() Unknown
[Native to Managed Transition]
The difference happens at the point where System.Web.HttpApplication.ResumeStepsFromThreadPoolThread() calls ResumeSteps() again and that eventually calls Page_Init() again.
Two things that have caused this to happen to me;
You have a blank src element in a HTML image tag that effectively makes another request to the same page. For example,
Two lots of events wired up. In VB this happens when you have an explicit handles clause on a method and it is also wired up via the designer. You might prefer to wire up your events explicitly and turn off auto event wireup (this goes for C# too).
It could be many things, but the img tag happens a lot.

ArgumentException: Unterminated string passed in

I recently encountered this error in one of the pages in my site.
[ArgumentException: Unterminated string passed in. (26): {"selectedIndexes":["0"],"]
at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeString()
at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeMemberName()
at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeDictionary(Int32\ depth)
at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal(Int32\ depth)
at System.Web.Script.Serialization.JavaScriptObjectDeserializer.BasicDeserialize(String\ input, Int32 depthLimit, JavaScriptSerializer serializer)
at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer\ serializer, String input, Type type, Int32 depthLimit)
at System.Web.Script.Serialization.JavaScriptSerializer.DeserializeObject(String\ input)
at Telerik.Web.UI.RadCompositeDataBoundControl.LoadPostData(String postDataKey,\ NameValueCollection postCollection)
at Telerik.Web.UI.RadCompositeDataBoundControl.System.Web.UI.IPostBackDataHandler.LoadPostData(String\ postDataKey, NameValueCollection postCollection)
at System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean\ fBeforeLoad)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,\ Boolean includeStagesAfterAsyncPoint)
[HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown.]
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,\ Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint,\ Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at ASP.pages_appeal_appealaction_aspx.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
What could be the reason for this exception ? Any ideas how to solve it ??
Yep. This error happens when the ASP.NET system receives a request, routes it to your handler and ModelBinder takes over to map values passed in to parameters in your handler. When one of those parms is a string and that string is started but not terminated, it throws the System.ArgumentException from the System.String.DeserializeString() method.
You have two options.
Fix the string data on the browser in JavaScript before you send it. (duh).
Create a custom Model Binder to handle the exception gracefully and send back a 500-series HTTP error or better yet, fix the data in a predictable way. That fixing is not always possible like in a sound file, image, movie or other base64-encoded blob.
Here's how to do #2 - Creating a custom model binder.

System.DirectoryServices.DirectoryServicesCOMException

I keep getting the following error when trying to run an application in the production environment with "anonymous" authentication and hardcoded username.
When I turn on basic authentication, which then prompts for username/password everything works like a charm. but I need to get the hardcoded version to work as well. Can't figure out whats going on.
Everything works perfectly on another server.
Exception Details: System.DirectoryServices.DirectoryServicesCOMException: An operations
error occurred.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.
Stack Trace:
[DirectoryServicesCOMException (0x80072020): An operations error occurred.]
System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) +781
System.DirectoryServices.DirectoryEntry.Bind() +44
System.DirectoryServices.DirectoryEntry.get_SchemaEntry() +49
System.DirectoryServices.AccountManagement.ADStoreCtx.IsContainer(DirectoryEntry
de) +62
System.DirectoryServices.AccountManagement.ADStoreCtx..ctor(DirectoryEntry
ctxBase, Boolean ownCtxBase, String username, String password,
ContextOptions options) +123
System.DirectoryServices.AccountManagement.PrincipalContext.CreateContextFromDirectoryEntry(DirectoryEntry
entry) +234
System.DirectoryServices.AccountManagement.PrincipalContext.DoLDAPDirectoryInit()
+497
[PrincipalOperationException: An operations error occurred.]
System.DirectoryServices.AccountManagement.PrincipalContext.DoLDAPDirectoryInit()
+534256
System.DirectoryServices.AccountManagement.PrincipalContext.DoDomainInit()
+61
System.DirectoryServices.AccountManagement.PrincipalContext.Initialize()
+141
System.DirectoryServices.AccountManagement.PrincipalContext.get_QueryCtx()
+42
System.DirectoryServices.AccountManagement.Principal.FindByIdentityWithTypeHelper(PrincipalContext
context, Type principalType, Nullable`1 identityType, String
identityValue, DateTime refDate) +27
System.DirectoryServices.AccountManagement.GroupPrincipal.FindByIdentity(PrincipalContext
context, String identityValue) +95
SERT_BO.ADHelper.UserBelongsToGrp(String adGroup, String sAMAccountName, String& emailAddr, String& fullName) in
D:\SERT\BusinessObjects\SERT_BO\ADHelper.cs:199
SERT_BO.UserSession.GetUserSession(String userName) in D:\SERT\BusinessObjects\SERT_BO\UserSession.cs:44
SERT.SetUserSession.Page_Load(Object sender, EventArgs e) in D:\SERT\SERT\SERT\SetUserSession.aspx.cs:23
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +25
System.Web.UI.Control.LoadRecursive() +71
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+3064
One thing to check is that the AppPool in which the ASP.NET app is running has the right privileges. As a quick test you can set the identity of the AppPool to Local System and see if this solves the issue. If the problem is here, then you can set the application pool identity to a (domain?) user that has enough privileges on this server.
looks like the issue was that the server was looking at the wrong AD controller. it had to be written out COMPLETELY.

Instance validation error calling web service

I'm getting an instance validation error in my proxy class i use to call a web service. This proxy class was auto-generated by XSD2Code. To me the error doesn't match the code it's pointing to.
Exception Details:
System.InvalidOperationException:
Instance validation error:
'LessThanOrEqualTo' is not a valid
value for ComparisonOperatorType.
Source Error:
Line 12866: cswgetCapabilitiesResponse csw.cswgetCapabilities(cswgetCapabilitiesRequest request)
Line 12867: {
Line 12868: return base.Channel.cswgetCapabilities(request);
Line 12869: }
Line 12870:
Source File:
d:\webapp\App_Code\ogc.csw.proxy.cs
Line: 12868
Stack Trace:
[InvalidOperationException: Instance validation error: 'LessThanOrEqualTo' is not a valid value for ComparisonOperatorType.]
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReadercsw.Read156_ComparisonOperatorType(String s) +582
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReadercsw.Read157_ComparisonOperatorsType(Boolean isNullable, Boolean checkType) +742
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReadercsw.Read162_Scalar_CapabilitiesType(Boolean isNullable, Boolean checkType) +746
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReadercsw.Read165_Filter_Capabilities(Boolean isNullable, Boolean checkType) +746
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReadercsw.Read166_CapabilitiesType(Boolean isNullable, Boolean checkType) +1430
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReadercsw.Read280_Item() +281
Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer11.Deserialize(XmlSerializationReader reader) +43
System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events) +579
[InvalidOperationException: There is an error in XML document (284, 13).]
System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events) +1375
System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle) +163
System.ServiceModel.Dispatcher.XmlSerializerOperationFormatter.DeserializeBody(XmlDictionaryReader reader, MessageVersion version, XmlSerializer serializer, MessagePartDescription returnPart, MessagePartDescriptionCollection bodyParts, Object[] parameters, Boolean isRequest) +606
[CommunicationException: Error in deserializing body of reply message for operation 'cswgetCapabilities'.]
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +4767763
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +1725
csw.cswgetCapabilities(cswgetCapabilitiesRequest request) +0
cswClient.csw.cswgetCapabilities(cswgetCapabilitiesRequest request) in d:\webapp\App_Code\ogc.csw.proxy.cs:12868
cswClient.cswgetCapabilities(GetCapabilitiesType1 GetCapabilities) in d:\webapp\App_Code\ogc.csw.proxy.cs:12875
tests_csw.Unnamed1_Click(Object sender, EventArgs e) in d:\webapp\tests\csw.aspx.cs:22
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +154
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3691
Is "LessThanOrEqualTo" meant to be a valid value? I think this message is saying that it tried to deserialize "LessThanOrEqualTo" as a value for the ComparisonOperatorType element (or attribute), but that the string "LessThanOrEqualTo" is not valid for the type of the element.

Error Asp.net Membership Provider when adding user

The error message below i get when I"m trying to create a new user in a project management system we use for a client. I type in all the corresponding information then when I click create it throws this error.
The following message may help in diagnosing the problem: Exception has been thrown by the target of an invocation. at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Web.Administration.WebAdminMembershipProvider.CallWebAdminMembershipProviderHelperMethodOutParams(String methodName, Object[] parameters, Type[] paramTypes) at System.Web.Administration.WebAdminMembershipProvider.CreateUser(String username, String password, String email, String passwordQuestion, String passwordAnswer, Boolean isApproved, Object providerUserKey, MembershipCreateStatus& status) at System.Web.UI.WebControls.CreateUserWizard.AttemptCreateUser() at System.Web.UI.WebControls.CreateUserWizard.OnNextButtonClick(WizardNavigationEventArgs e) at System.Web.UI.WebControls.Wizard.OnBubbleEvent(Object source, EventArgs e) at System.Web.UI.WebControls.CreateUserWizard.OnBubbleEvent(Object source, EventArgs e) at System.Web.UI.WebControls.Wizard.WizardChildTable.OnBubbleEvent(Object source, EventArgs args) at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) at System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
What causes this error is the hard drive where all databases are being stored is full. Even if there is 1kb left it will post the error. To fix, install a much larger hard drive, or clear any unnecessary files from the hard drive and make free space. the server error or asp.net error you may see from this is the 9002 error. When the hard drive is full the databases log file cannot be written too, which when anything is done to the database, inserting, updating, etc. it is written to the log file. When there is no space left the log file cannot expand therefore throwing an error. I appreciate your help chriskent. By the way if anyone is wondering we had no room left literally not even 1kb to spare, our free space was 0kb. Hope this helps.
Do you have a machine key element in your web.config? Ensure this is specifically set (Not autogenerate). Check this thread for more information:
http://forums.asp.net/t/1213872.aspx

Resources