Can't add related entities in CRM 3.0 - sql-server

The story so far:
A couple weeks ago, a field completely disappeared from the AccountExtensionBase table but remained in the Account and FilteredAccount views. This caused the Main Info form in CRM itself (which draws from that table) to stop working completely.
To fix the above, I manually removed said field from the definitions of said views, and I edited the Main Info form to no longer reference the missing field.
That left in more-or-less working condition. The only thing that's still broken is adding related entities from an already-open Main Info form. When I try, it throws exception 0x80044150. After learning this, I manually removed the field from the METABASE database and manually removed all references to it in the OrganizationUIBase table. Nothing. CRM won't let me just recreate the field, and I also can't seem to convince it to actually write to the trace log so I can get any more information about what's going on. I know this sometimes comes up when you exceed the 2155 option limit for picklist fields within an entity, but I don't think that's it, because the first thing I tried when the original issue manifested itself was to remove two entire picklist fields that were no longer needed, and that clearly hasn't helped.
So any ideas about what could be causing this, or what I can do to fix it, or even what a possible next step might be? I'm kind of stumped here.
Edit: got the trace logging to work...
at ErrorInformation.LogError()
at ErrorInformation..ctor(Exception exception, Uri requestUrl)
at MainApplication.Application_Error(Object sender, EventArgs e)
at EventHandler.Invoke(Object sender, EventArgs e)
at HttpApplication.RaiseOnError()
at HttpApplication.RecordError(Exception error)
at HttpApplication.ResumeSteps(Exception error)
at HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
at HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr)
at HttpRuntime.ProcessRequest(HttpWorkerRequest wr)
at ISAPIRuntime.ProcessRequest(IntPtr ecb, Int32 iWRType)
>MSCRM Platform Error Report:
Error: Exception of type System.Web.HttpUnhandledException was thrown.
Error Number: 0x80044150
Error Message: Exception from HRESULT: 0x80044150.
Error Details: Exception from HRESULT: 0x80044150.
Source File: Not available
Line Number: Not available
Request URL: http://crmserv/userdefined/edit.aspx?_CreateFromType=1&_CreateFromId={94892C13-A23E-DB11-BBF1-0014221C4264}&etc=10059
Stack Trace Info: Exception of type System.Web.HttpUnhandledException was thrown.
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain()
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at System.Web.CallHandlerExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
at Microsoft.Crm.Platform.ComProxy.CRMCustomizationClass.Transform(CUserAuth& Caller, CObjectName& SourceObject, Int32 TargetObjectType, Int32 TargetFieldType)
at Microsoft.Crm.Application.Platform.Entity.CreateFrom(Int32 sourceEntityType, String sourceEntityId, TransformType transformType)
at Microsoft.Crm.Application.Forms.EndUserForm.PopulateDefaultDataIfAvailable()
at Microsoft.Crm.Application.Forms.EndUserForm.RetrieveParams()
at Microsoft.Crm.Application.Forms.EndUserForm.Initialize(Entity entity)
at Microsoft.Crm.Application.Forms.CustomizableForm.Execute(Entity entity, String formId, String formType)
at Microsoft.Crm.Application.Forms.CustomizableForm.Execute(Entity entity)
at Microsoft.Crm.Application.Pages.UserDefined.DetailPage.ConfigureForm()
at Microsoft.Crm.Application.Controls.AppPage.OnPreRender(EventArgs e)
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Page.ProcessRequestMain()
Type: Platform
This might be the more useful error report, actually. The above showed up twice, but this one is getting thrown scores of times every minute:
at User.GetPrivilege(String priv, PRIVILEGE_DEPTH depth)
at User.GetPrivilege(Int32 objectType, PrivilegeId privilegeId)
at AppMenuBar.BuildNewObjectMenu(Menu menuObject, Boolean buildAsSubMenu)
at AppFormMenuBar.BuildFileMenu(String formName)
at AppFormMenuBar.Execute(PrivilegeCheck privilegeCheck, String formName)
at AppFormMenuBar.Execute(PrivilegeCheck privilegeCheck)
at AccountDetailPage.ConfigureMenus()
at AppPage.OnPreRender(EventArgs e)
at Control.PreRenderRecursiveInternal()
at Page.ProcessRequestMain()
at Page.ProcessRequest()
at Page.ProcessRequest(HttpContext context)
at CallHandlerExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute()
at HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
at HttpApplication.ResumeSteps(Exception error)
at HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
at HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr)
at HttpRuntime.ProcessRequest(HttpWorkerRequest wr)
at ISAPIRuntime.ProcessRequest(IntPtr ecb, Int32 iWRType)
Privilege Check Failed For user: , User Does Not Have Privilege: {9f2b415e-8a0c-430c-bdd1-ad2052b86b02}
Lots of different users show up in the last line. Anything?

It sounds like you are making unsupported direct SQL modifications to the database. If that is the cause of the errors, you are likely in trouble. You say tracing will not turn on, did you add the following keys to the registry and perform IIS reset? - http://support.microsoft.com/kb/907490
EDIT:
Can you run the following query replacing the database name with that from your instance and let me know if a privilege comes up. You are likely missing that privilege for the users security role for whom it is throwing that error.
SELECT [PrivilegeId]
,[Name]
,[CanBeLocal]
,[CanBeDeep]
,[VersionNumber]
,[CanBeGlobal]
,[CanBeBasic]
,[AccessRight]
,[IsDisabledWhenIntegrated]
FROM [MyCrmDatabase_MSCRM].[dbo].[PrivilegeBase]
WHERE privilegeid='9f2b415e-8a0c-430c-bdd1-ad2052b86b02'

Related

DotNetNuke Exception in DotNetNuke.Entities.Users.UserInfo.get_Social()

just recently started getting a "System.ArgumentException: An item with the same key has already been added." with the following stack trace.
System.ArgumentException: An item with the same key has already been added
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at DotNetNuke.Entities.Users.UserInfo.get_Social()
at DotNetNuke.Entities.Users.UserInfo.get_Roles()
at DotNetNuke.Entities.Users.UserInfo.IsInRole(String role)
at DotNetNuke.HttpModules.Membership.MembershipModule.AuthenticateRequest(HttpContextBase context, Boolean allowUnknownExtensinons)
at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
All I did was install and update Extensions and recycle the application pool. It appears on different pages where I have a custom module that has a search form on it and some DevExpress components.
DNN Version is 7.3.2
Kind regards
UPDATE:
Seems to be a bug in DNN https://dnntracker.atlassian.net/browse/DNN-6990
I think you are seeing a race condition where two threads are trying to access the Social property of the UserInfo:
public UserSocial Social
{
get
{
if (this._social == null)
{
this._social = new Dictionary<int, UserSocial>();
}
if (!this._social.ContainsKey(this.PortalID))
{
this._social.Add(this.PortalID, new UserSocial(this));
}
return this._social[this.PortalID];
}
}
The only way for the error to happen would be for two threads to check the presence of the portal id key and both trying to add the key to the dictionary at the same time.
The Social property is called in many places (14 according to ILSpy in a v7.2.2), so it is hard to pinpoint where the problem could be coming from; if you note that the problem occurs only with your custom module you may want to investigate the methods that may call this code

OutOfMemoryException while bulk data processing with WCF RIA & WF4

I have an existing Silverlight 5 application. I'm adding a page to it to allow users to process mass updates to data in a 3rd party database system. The application currently uses WCF RIA services to communicate to the 3rd party system via SOAP. The functionality of the update is contained in a Workflow 4 application I created and is referenced as an assembly on the server-side of the SL application. Lastly, the application is hosted right now in my local instance of IIS 7.5 running on Windows 7; I'm also debugging with IIS, not the VS dev server.
At the basic level, the application functions as follows:
Select text file
Click "Start" button
Event handler creates an instance of a user-defined Type that keeps track of the batch
Event handler creates a new BackgroundWorker instance and wires up handlers for the DoWork, ProgressChanged, and RunWorkerCompleted events
Event handler calls RunWorkerAsync()
Here's the shortened code for the DoWork event handler, since that's where the majority of the work is done.
private void BwOnDoWork(object sender, DoWorkEventArgs doWorkEventArgs, BatchContainerControl batchProcess)
{
var worker = sender as BackgroundWorker;
// Iterate through each record of data file and call the 'UpdateAddress' function
// of the AddressDomainService which, in turn, executes the Workflow
foreach (var item in batchProcess.FileData)
{
// Check if operation has been cancelled
if (worker.CancellationPending)
{
doWorkEventArgs.Cancel = true;
break;
}
. . .
// Invoke THINKComm.CustomerAddressUpdate Workflow via AddressContext
var invokeOp = _addressDomainContext.UpdateAddress(activityData);
// 'activityData' is an instance of Dictionary<string, string>
invokeOp.Completed += (o, args) => InvokeOpOnCompleted(o, args, batchProcess);
}
}
The handlers for the ProgressChanged and RunWorkerCompleted events, as well as the Completed event of the InvokeOperation instance all, for the most part, update a part of the UI. If you think posting any of that code would be helpful, I'd be happy to update the post.
Speaking of UI, the parts that are updated by the event handlers are two ProgressBar controls - one that tracks the records as they're read from the file and a second one that tracks the records as the update has taken place on the 3rd party database.
Getting to the actual problem...
I've processed files of 10, 100, and 1,000 records with no problem. I then attempted to process a complete file containing ~15,000 records (or 1,907KB of data). The process starts and I can see in the debugger output that the Workflow is being executed. About a quarter of the way through or so, I get an OutOfMemoryException. Here's the stack trace:
at System.ServiceModel.DomainServices.Client.WebDomainClient`1.BeginInvokeCore(InvokeArgs invokeArgs, AsyncCallback callback, Object userState)
at System.ServiceModel.DomainServices.Client.DomainClient.BeginInvoke(InvokeArgs invokeArgs, AsyncCallback callback, Object userState)
at System.ServiceModel.DomainServices.Client.DomainContext.InvokeOperation(String operationName, Type returnType, IDictionary`2 parameters, Boolean hasSideEffects, Action`1 callback, Object userState)
at THINKImportSystem.Web.Address.AddressDomainContext.UpdateAddress(Dictionary`2 activityData)
at THINKImportSystem.BatchProcessPage.BwOnDoWork(Object sender, DoWorkEventArgs doWorkEventArgs, BatchContainerControl batchProcess)
at THINKImportSystem.BatchProcessPage.<>c__DisplayClass10.<StartButtonClick>b__6(Object s, DoWorkEventArgs args)
at System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e)
at System.ComponentModel.BackgroundWorker.OnRun(Object argument)
Then, the JIT debugger pops up with an error of Unhandled Error in Silverlight Application Code:4004 with a message of System.ServiceModel.DomainServices.Client.DomainOperationException: Invoke operation 'UpdateAddress' failed. Error HRESULT E_FAIL has been returned from a call to a COM component.
I should mention that, sometimes, I get the JIT debugger first. I see in the Debug output that threads are still exiting, and then about 10 or 20 seconds later, the VS debugger pops up with the out of memory exception.
My best guess is that, objects somewhere (maybe related to the DomainService?) aren't being released and therefore, memory usage is building. From what I understand, IIS places restrictions on the amount of memory an application can use, but I can't tell if that's the case here or not.
I was thinking that, each time a record in the file is processed, the objects related to it's processing would be released and therefore overall memory usage would be pretty low. But obviously I'm not understanding how everything is being executed!
I was also wondering if using the TPL as opposed to BackgroundWorker would make a difference?

How to recover from a Silverlight UnhandledException

In my App() initialization code, I include a generic handler
UnhandledException += Application_UnhandledException;
private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
{
Debugger.Break();
}
I have 2 screens that work fine, but when navigating quickly back and forth between the two screens a number of times (varies between 7 and 12) I hit this breakpoint with the exception
{System.Windows.ApplicationUnhandledExceptionEventArgs} base {System.EventArgs}: {System.Windows.ApplicationUnhandledExceptionEventArgs}
ExceptionObject: {System.ArgumentException: Value does not fall within the expected range.}
Handled: false
and if I remove the UnhandledException and set the Debugger to break on unhandled, I get the following:
Unhandled Error in Silverlight Application
Code: 4004
Category: ManagedRuntimeError
Message: System.Windows.Markup.XamlParseException: 2028 An error has occurred. [Line: 0 Position: 0] ---> System.ArgumentException: [Arg_ArgumentException]
Arguments: Debugging resource strings are unavailable.
Often the key and arguments provide sufficient information to diagnose the problem.
See http://go.microsoft.com/fwlink/?linkid=106663&Version=4.0.60531.0&File=mscorlib.dll&Key=Arg_ArgumentException
at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
at MS.Internal.XcpImports.Collection_AddValue[T](PresentationFrameworkCollection`1 collection
even if I set e.handled = true, my application crashes.
Important Note:
The application, under a MVVM framework works over 99.9% of the time, navigating between dozens of screens. Only one user has reported being able to crash the application by quickly navigating between two screens, and then only after about 10 back and forth tries
My questions are:
Any way to determine what is causing it?
Any way to prevent it?
What is the best way to recover from this error?
Followup:
The problem was solved by naming the view control, even though that should not be needed
from
<telnav:RadTabItem.Content>
<views:Detail_InfoView />
</telnav:RadTabItem.Content>
to
<telnav:RadTabItem.Content>
<views:Detail_InfoView x:Name="DetailsInnerView"/>
</telnav:RadTabItem.Content>

Silverlight 4 & WCF Deseralizing Issue- There was an error deserializing the object of type 'T'. Unexpected end of file

I have come across a large issue that i am having that has suddenly come to light when i upgraded my Silverlight & Web Projects to versions 4 respectively.
Since doing this, all my WCF Services are Failing with the following Error message:
There was an error deserializing the object of type Anyboat.Admin.UserService.User. Unexpected end of file. Following elements are not closed: LastName, AuthenticateUserResult, AuthenticateUserResponse, Body, Envelope.
The StackTrace is:
at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeParameterPart(XmlDictionaryReader reader, PartInfo part, Boolean isRequest)
at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeBody(XmlDictionaryReader reader, MessageVersion version, String action, MessageDescription messageDescription, Object[] parameters, Boolean isRequest)
at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeBodyContents(Message message, Object[] parameters, Boolean isRequest)
at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeReply(Message message, Object[] parameters)
at System.ServiceModel.Dispatcher.ProxyOperationRuntime.AfterReply(ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
at System.ServiceModel.ClientBase`1.ChannelBase`1.EndInvoke(String methodName, Object[] args, IAsyncResult result)
at Anyboat.Admin.UserService.UserServiceClient.UserServiceClientChannel.EndAuthenticateUser(IAsyncResult result)
at Anyboat.Admin.UserService.UserServiceClient.Anyboat.Admin.UserService.UserService.EndAuthenticateUser(IAsyncResult result)
at Anyboat.Admin.UserService.UserServiceClient.OnEndAuthenticateUser(IAsyncResult result)
at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result)
I put a breakpoint in my SilverlightFaultBehaviour on the Response Message and this is the Envelope reponse i got back. Notice the Carriage return which is between *"\r\n"*
"<s:Envelope xmlns:a=\"http://www.w3.org/2005/08/addressing\" xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\">\r\n <s:Header>\r\n <a:Action s:mustUnderstand=\"1\">urn:UserService/AuthenticateUserResponse</a:Action>\r\n <a:RelatesTo>urn:uuid:07cc1361-c74c-4449-b423-e982d2ac8e05</a:RelatesTo>\r\n </s:Header>\r\n <s:Body>\r\n <AuthenticateUserResponse>\r\n <AuthenticateUserResult xmlns:d4p1=\"http://schemas.datacontract.org/2004/07/AnyBoat.Web.Classes.DataObjects\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">\r\n <d4p1:Active>true</d4p1:Active>\r\n <d4p1:EmailAddress>robbie#robbietapping.com.au</d4p1:EmailAddress>\r\n <d4p1:FirstName>Robbie</d4p1:FirstName>\r\n <d4p1:IsAdministrator i:nil=\"true\" />\r\n <d4p1:LastName>Tapping</d4p1:LastName>\r\n <d4p1:Password>xxxxxxxxx</d4p1:Password>\r\n <d4p1:UserID>2</d4p1:UserID>\r\n <d4p1:UserName>robbietapping</d4p1:UserName>\r\n </AuthenticateUserResult>\r\n </AuthenticateUserR
esponse>\r\n </s:Body>\r\n</s:Envelope>"
Can anyone tell me if there is away around this at all, i upgraded my VS2010 to SP1 where this has started to show itself.
Any Information or answers would be greatfully appreciated.
Thanks
EDIT
The Code that the Error Occurs on is:
public Anyboat.Admin.UserService.User EndAuthenticateUser(System.IAsyncResult result) {
object[] _args = new object[0];
Anyboat.Admin.UserService.User _result = ((Anyboat.Admin.UserService.User)(base.EndInvoke("AuthenticateUser", _args, result)));
return _result;
}
Which serialization type do you use at services side? I'm pretty sure that you use some custom serialization. "\r\n" problem is pretty common and it occurs when you're trying to deserialize not well formed xml received from service.
So I see two ways:
The most preferable way. Check the serializer at service side. It's obvious that service returns xml in wrong format.
Add IClientMessageInspector to client and remove special symbols from response before deserialization.

IsolatedStorage Errors

I'm building a Windows Phone 7 application that uses isolated storage. The code works most of the time but I keep getting IsolatedStorageExceptions randomly:
{"An error occurred while accessing IsolatedStorage."}
There are no further details about the reason for the exception. Here is the stack trace:
at System.IO.IsolatedStorage.IsolatedStorageFile.DeleteFile(String file)
at MyApp.Core.Data.WindowsPhoneFileRepository.DeleteFile(String name)
at MyApp.Core.Domain.ThingService.SaveThing(Thing Thing)
at MyApp.Core.Domain.TrackedThingService.PersistThingLocally(TrackedThing Thing)
at MyApp.Ui.ViewModels.TrackViewModel.<.ctor>b__3(Thing Thing)
at GalaSoft.MvvmLight.Command.RelayCommand`1.Execute(Object parameter)
at GalaSoft.MvvmLight.Command.EventToCommand.Invoke(Object parameter)
at System.Windows.Interactivity.TriggerAction.CallInvoke(Object parameter)
at System.Windows.Interactivity.TriggerBase.InvokeActions(Object parameter)
at System.Windows.Interactivity.EventTriggerBase.OnEvent(EventArgs eventArgs)
at System.Windows.Interactivity.EventTriggerBase.OnEventImpl(Object sender, EventArgs eventArgs)
at System.Windows.Controls.Primitives.ButtonBase.OnClick()
at System.Windows.Controls.Button.OnClick()
at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
at System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl, EventArgs e)
at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)
The file exists. I place all my IsolatedStorage uses inside using blocks so I shouldn't have the file open anywhere.
What could be causing this?
How I can I get more details about the cause of the exception?
Using blocks are currently not guaranteed to flush/close streams in WP7.
Close all files/streams explicitly until the SDK reaches the point you can actually trust it! :)
I would specifically check to make sure that you've closed all readers and writers to anything within the File that you are trying to delete. I'm not saying that will definately fix it, but rather not being able to delete files that do exist tend to be caused by open files.
It should not be overlooked that the WP7 is still in Beta (you've updated from the CTP to the Beta version right?).
Consider creating a very simple application that manipulates the Isolated storage in the way your main application is to see if you can create a small Repo of the problem. Having done that send it to Microsoft so they can take a look at it.
I faced the same problem.
I checked carefully and found a place where I didn't close the FileStream. Closing it solved the problem for me.

Resources