I am using DNN module 5.6.1, and i created a custom module using Devxpress controls,
It is installing in dnn site, but when i try to add the module in a page, i getting the following Error,
A critical error has occurred.
Object reference not set to an instance of an object.
And Log is.........
AssemblyVersion: 5.6.1
PortalID: 0
PortalName: My Website
UserID: 1
UserName: host
ActiveTabID: 63
ActiveTabName: TestDNN
RawURL: /dotnetnuke_new/TestDNN.aspx
AbsoluteURL: /DotNetNuke_New/Default.aspx
AbsoluteURLReferrer: http://senthilkumar.com/dotnetnuke_new/TestDNN.aspx
UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14 (.NET CLR 3.5.30729)
DefaultDataProvider: DotNetNuke.Data.SqlDataProvider, DotNetNuke.SqlDataProvider
ExceptionGUID: cd7a06c5-7a69-4ebf-b51e-07f70714bfe6
InnerException: Object reference not set to an instance of an object.
FileName:
FileLineNumber: 0
FileColumnNumber: 0
Method: dnn_webrater.ctrlRater.Page_Load
StackTrace:
Message: DotNetNuke.Services.Exceptions.PageLoadException: Object reference not set to an instance of an object. ---> System.NullReferenceException: Object reference not set to an instance of an object. at dnn_webrater.ctrlRater.Page_Load(Object sender, EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) --- End of inner exception stack trace ---
Source:
and after logout and login, it shows the following error on the page
Error: Test Module 1 is currently unavailable.
DotNetNuke.Services.Exceptions.ModuleLoadException: Object reference not set to an instance of an object. ---> System.NullReferenceException: Object reference not set to an instance of an object. at DotNetNuke.UI.Modules.ModuleHost.LoadModuleControl() --- End of inner exception stack trace ---
Can any one please help me to fix this error
This is a very generic error. You may want to look through your Event Log to see if there are other errors that occur at the same time more related to your specific module. Debugging the module to see what exception is coming from your module can also be helpful, rather than trying to unwind these stack traces that, more than likely, are going to be wild goose chases.
What often happens with DNN is that a module fails while loading, and then other parts of the skin and container fail because the module was never fully setup correctly. These are the NullReferenceException errors that you're seeing.
bdukes said the main things I would guess anyway keep the following problem in mind, too.
another reason for this problem could be a specific servertag used in a dnnwrapper.
for example if you are using telerik wrapper from dotnetnuke but placing telerik controls in this wrappers without having a refference on the telerik assambly.
example:
<dnncontrols:datepicker>
<calendar>
<SpecialDays>
<telerik:calendarDays />
</SpecialDays>
</calendar>
</dnncontrols:datepicker>
If you are doing this you will get a nullreference as you got. This Problem drove me crazy to find it so I decided to post it here.
I hope this will help you.
But at first I would suggest the way bdukes described (this is the normal way to go).
best regards
Related
We have been investing heavily in 2sxc for a client with a large site. We've built a number of custom apps and added quite a few content types to the default Content App.
About a month ago we started seeing slowness when saving front end data and saving ContentTypes in the Content App (but only there). The site would take 20 - 30 seconds to save. Now it's gotten worse and started throwing exceptions intermittently. Save is no faster than 30 seconds. At other times it's 60 seconds. Intermittently the content fails to save and we get the error message and exceptions listed below.
However we have no problems saving content within other apps like the Blog app and our custom apps. Performance there is fine. Also 2sxc modules in general seem to render fine for front end users.
We are running 2sxc 8.4.5 on DNN 7.4.2.
Here is the initial Error Message:
Had an error talking to the server (status 400)
Message: Bad Request
Detail: Error getting List of Stream.
Stream Name: Default
DataSource Name: QuickCache
Failed to load resource: the server responded with a status of 400 (Bad Request)
POST [removed]/en-us/desktopmodules/2sxc/api/eav/entities/savemany?appId=2 400 (Bad Request)
(anonymous) # VM2141:2
(anonymous) # set.min.js?sxcver=8.9.1.13916:103
n # set.min.js?sxcver=8.9.1.13916:99
(anonymous) # set.min.js?sxcver=8.9.1.13916:96
(anonymous) # set.min.js?sxcver=8.9.1.13916:131
$eval # set.min.js?sxcver=8.9.1.13916:145
$digest # set.min.js?sxcver=8.9.1.13916:142
$apply # set.min.js?sxcver=8.9.1.13916:146
(anonymous) # set.min.js?sxcver=8.9.1.13916:276
Sf # set.min.js?sxcver=8.9.1.13916:37
d # set.min.js?sxcver=8.9.1.13916:37
There are two exceptions that appear in the DNN Event Log. Both of them appear twice for each failure to save.
General Exception
AbsoluteURL:/en-us/desktopmodules/2sxc/api/eav/entities/savemany
DefaultDataProvider:DotNetNuke.Data.SqlDataProvider, DotNetNuke
ExceptionGUID:7888b675-2f38-4664-96ab-786b27b3406c
AssemblyVersion:
PortalId:-1
UserId:-1
TabId:-1
RawUrl:
Referrer:
UserAgent:
ExceptionHash:QVy9pjR7G9IFD3vpE650/A==
Message:Error getting List of Stream. Stream Name: Default DataSource Name: QuickCache
StackTrace:
at ToSic.Eav.DataSources.DataStream.get_LightList() in C:\Projects\eav-server\ToSic.Eav.DataSources\DataStream.cs:line 143
at ToSic.Eav.DataSources.BaseDataSource.get_LightList() in C:\Projects\eav-server\ToSic.Eav.DataSources\BaseDataSource.cs:line 132
at ToSic.Eav.Import.Import.RunImport(IEnumerable`1 newAttributeSets, IEnumerable`1 newEntities) in C:\Projects\eav-server\ToSic.Eav\ImportExport\Import.cs:line 71
at ToSic.Eav.WebApi.EntitiesController.SaveMany(Int32 appId, List`1 items) in C:\Projects\eav-server\ToSic.Eav.WebApi\EntitiesController.cs:line 204
at ToSic.SexyContent.EAVExtensions.EavApiProxies.EntitiesController.SaveMany(Int32 appId, List`1 items) in C:\Projects\2SexyContent\Web\DesktopModules\ToSIC_SexyContent\WebApi\EavApiProxies\EntitiesController.cs:line 109
at lambda_method(Closure , Object , Object[] )
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass13.b__c(Object instance, Object[] methodParameters)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.<>c__DisplayClass5.b__4()
at System.Threading.Tasks.TaskHelpers.RunSynchronously[TResult](Func`1 func, CancellationToken cancellationToken)
InnerMessage:An error occurred while executing the command definition. See the inner exception for details.
InnerStackTrace:
at System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
at System.Data.Objects.Internal.ObjectQueryExecutionPlan.Execute[TResultType](ObjectContext context, ObjectParameterCollection parameterValues)
at System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
at System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable.GetEnumerator()
at ToSic.Eav.BLL.DbLoadIntoEavDataStructure.GetAppDataPackage(Int32[] entityIds, Int32 appId, IDeferredEntitiesList source, Boolean entitiesOnly) in C:\Projects\eav-server\ToSic.Eav\BLL\DbLoadIntoEavDataStructure.cs:line 179
at ToSic.Eav.DataSources.SqlSources.EavSqlStore.GetDataForCache(IDeferredEntitiesList targetCacheForDeferredLookups) in C:\Projects\eav-server\ToSic.Eav\DataSources\SqlSources\EavSqlStore.cs:line 68
at ToSic.Eav.DataSources.Caches.BaseCache.EnsureCache() in C:\Projects\eav-server\ToSic.Eav.DataSources\Caches\BaseCache.cs:line 126
at ToSic.Eav.DataSources.Caches.BaseCache.GetList() in C:\Projects\eav-server\ToSic.Eav.DataSources\Caches\BaseCache.cs:line 46
at ToSic.Eav.DataSources.DataStream.get_LightList() in C:\Projects\eav-server\ToSic.Eav.DataSources\DataStream.cs:line 135
Source:ToSic.Eav.DataSources
FileName:
FileLineNumber:0
FileColumnNumber:0
Method:
Page Load Exception
AbsoluteURL:/Default.aspx
DefaultDataProvider:DotNetNuke.Data.SqlDataProvider, DotNetNuke
ExceptionGUID:c5449323-0a0a-486f-98cd-9849243fff19
AssemblyVersion:7.4.2
PortalId:0
UserId:-1
TabId:56
RawUrl:/en-us/
Referrer:http://www.cui.edu/en-us/
UserAgent:Mozilla/5.0 (iPhone; CPU iPhone OS 9_3_2 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13F69 Safari/601.1
ExceptionHash:301KQ/ilLzYrwILN4yfdXA==
Message:Error getting List of Stream. Stream Name: Default DataSource Name: PublishingFilter
StackTrace:
InnerMessage:Error getting List of Stream. Stream Name: Default DataSource Name: PublishingFilter
InnerStackTrace:
at ToSic.Eav.DataSources.DataStream.get_List() in C:\Projects\eav-server\ToSic.Eav.DataSources\DataStream.cs:line 98
at ToSic.Eav.DataSources.BaseDataSource.get_List() in C:\Projects\eav-server\ToSic.Eav.DataSources\BaseDataSource.cs:line 127
at ToSic.SexyContent.ContentGroup.get_Template() in C:\Projects\2SexyContent\Web\DesktopModules\ToSIC_SexyContent\SexyContent\ContentGroup.cs:line 71
at ToSic.SexyContent.ContentBlock.ModuleContentBlock..ctor(ModuleInfo moduleInfo, IEnumerable`1 overrideParams) in C:\Projects\2SexyContent\Web\DesktopModules\ToSIC_SexyContent\SexyContent\ContentBlock\ModuleContentBlock.cs:line 77
at ToSic.SexyContent.View.get_SxcI() in C:\Projects\2SexyContent\Web\DesktopModules\ToSIC_SexyContent\View.ascx.cs:line 18
at ToSic.SexyContent.View.get_UserMayEditThisModule() in C:\Projects\2SexyContent\Web\DesktopModules\ToSIC_SexyContent\View.ascx.cs:line 90
at ToSic.SexyContent.View.Page_Load(Object sender, EventArgs e) in C:\Projects\2SexyContent\Web\DesktopModules\ToSIC_SexyContent\View.ascx.cs:line 28
at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Source:
FileName:
FileLineNumber:0
FileColumnNumber:0
Method:
Thanks to Raphael Müller this issue has been solved. He suggested rebuilding indexes on the database. Once that was done the content saves went from 45 seconds plus with timeouts down to 1.5 seconds. Boy is my face red. Oh well live and learn. The lesson is simple: Make sure your database has a maintenance plan that includes the rebuilding of indexes.
Here are some helpful links for those who might encounter this issue.
Here is a script to rebuild all indexes in a database. In theory the script should not lock your database or website but anything is possible so it's best to execute off hours. It took 5 minutes to run on my DNN database which is around 2.5 Gb. https://gallery.technet.microsoft.com/scriptcenter/Script-for-rebuilding-all-8d079754
Michelle Ufford's Index Defrag Script is an advanced solution. I've run it on my stage server successfully and it seems to be well received by the community. http://sqlfool.com/2011/06/index-defrag-script-v4-1/
Here is a helpful discussion on how often to schedule your index rebuilds. How Often should the indexes be re-build in sql-server DB?
I've just upgraded from 4.0 to 4.2 update 1. Now i got an error as soon as I try to open a page:
System.FormatException: Unrecognized Guid format. at System.Guid.GuidResult.SetFailure(ParseFailureKind failure, String failureMessageID, Object failureMessageFormatArgument, String failureArgumentName, Exception innerException)
at System.Guid.TryParseGuid(String g, GuidStyles flags, GuidResult& result)
at System.Guid..ctor(String g)
at CompositePageContentEditor.PageContentEditor.get_SelectedTemplateId() in c:\Development\ValaLocal\website\Composite\controls\FormsControls\FormUiControlTemplates\Customized\PageContentEditor.ascx.cs:line 14
at CompositePageContentEditor.PageContentEditor.SetUpTextAreas(Boolean flush) in c:\Development\ValaLocal\website\Composite\controls\FormsControls\FormUiControlTemplates\Customized\PageContentEditor.ascx.cs:line 71
at CompositePageContentEditor.PageContentEditor.InitializeViewState() in c:\Development\ValaLocal\website\Composite\controls\FormsControls\FormUiControlTemplates\Customized\PageContentEditor.ascx.cs:line 60
at Composite.Plugins.Forms.WebChannel.CustomUiControls.TemplatedPageContentEditorUiControl.InitializeViewState()
at Composite.Plugins.Forms.WebChannel.UiControlFactories.TemplatedContainerUiControl.InitializeViewState()
at Composite.Plugins.Forms.WebChannel.UiControlFactories.TemplatedContainerUiControl.InitializeViewState()
at Composite.Plugins.Forms.WebChannel.UiControlFactories.TemplatedContainerUiControl.InitializeViewState()
at System.Web.UI.Control.InitRecursive(Control namingContainer)
at System.Web.UI.Control.AddedControl(Control control, Int32 index)
at Composite_Management_FlowUi.Page_Load(Object sender, EventArgs e) in c:\Development\ValaLocal\website\Composite\content\flow\FlowUi.aspx.cs:line 61
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
any help appreciated!
/Johan
The exception happens if the system cannot find any page templates (I made some changes so in the next version there will be a more appropriate exception message).
You should check the server log for additional details. Could be something wrong with the configuration ("/App_Data/Composite/Composite.config" file) or with the templates itself.
I've got a problem with a Silverlight application. It has been working and I haven't changed the code, but I have changed a few other things such as upgrading to VS2012. I thought all was well with the project post upgrade but have now run in to trouble.
When the application starts it throws an exception during the InitializeComponent call. It looks like the problem is with the ResourceDictionary, specifically I notice this in the inner exception:
InnerException: System.Collections.Generic.KeyNotFoundException
Which makes me think it's trying to set a property and can't find the key it's looking for in the ResourceDictionary. I've been tearing my hair out trying to discover how to determine what key it's looking for, can anyone suggest a debugging technique to do this?
The full details of the exception are:
System.Windows.Markup.XamlParseException occurred Message=Set
property 'System.Windows.FrameworkElement.Style' threw an exception.
[Line: 228 Position: 64] LineNumber=228 LinePosition=64
StackTrace:
at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
at MyApp.Silverlight.MainPage.InitializeComponent()
at MyApp.Silverlight.MainPage..ctor() InnerException: System.Windows.Markup.XamlParseException
Message=Failed to assign to property 'System.Windows.ResourceDictionary.Source'. [Line: 5 Position: 36]
LineNumber=5
LinePosition=36
StackTrace:
at MS.Internal.XcpImports.CreateFromXaml(UnmanagedMemoryStream stream,
String sourceAssemblyName, Boolean createNamescope, Boolean
requireDefaultNamespace, Boolean allowEventHandlers, String
xamlResourceUriString, Boolean isBinaryContent)
at System.Windows.Controls.Control.GetBuiltInStyle(IntPtr nativeTarget, IntPtr& nativeStyle)
InnerException: System.Collections.Generic.KeyNotFoundException
Message=The given key was not present in the dictionary.
StackTrace:
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at System.Windows.ResourceManagerWrapper.GetResourceForUri(Uri xamlUri,
Type componentType)
InnerException:
Thanks very much for reading and if you have any suggestions I'll be very grateful.
I am getting the following error in Silverlight for one of the users. The target runtime is 4.1.10329.0 and the application is built using Silverlight 4. I don't happen to understand what may be the issue. Looks like it is trying to load something on LoadComponent and failing:
Message: Unhandled Error in Silverlight Application
Parser_CreateFromValue_CannotConvertInitializationText]
Arguments: PropertyChanged,System.Windows.Data.UpdateSourceTrigger
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.1.10329.0&File=System.Windows.dll&Key=
Parser_CreateFromValue_Cannot ConvertInitializationText
[Line: 582 Position: 273] at
System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
at Samplexxx.MainPage.InitializeComponent()
at Samplexxx.MainPage..ctor()
at Samplexxx.App.Application_Startup(Object sender, StartupEventArgs e)
at MS.Internal.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate
handlerDelegate, Object sender, Object args)
at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs,
Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)
Any ideas on what could be the issue?
Open IIS on the server, go to HTTP headers, click on Mime Types, click “Add New” and add the following:
Extension – Mime Type
.xaml – application/xaml+xml
.xap – application/x-silverlight-app
.xbap – application/x-ms-xbap
In which situation following error occurs?
Unable to cast object of type 'MyType' to type 'Castle.Proxies.MyType'.
UPDATE:
I got this error message while binding MyType.FindAllByProperty("col1", "foo"); to a GridView (exactly a Telerik's one: RadGrid). This error is not occuring every time, just sometimes. Here is markup of my grid:
<telerik:RadGrid ID="grdList" runat="server" AutoGenerateColumns="false" OnNeedDataSource="grdList_NeedDataSource"
OnUpdateCommand="grdList_UpdateCommand" AllowAutomaticUpdates="True" OnItemUpdated="grdList_ItemUpdated"
AllowMultiRowEdit="true">
<MasterTableView EditMode="InPlace" DataKeyNames="PageInRole_id" AllowAutomaticUpdates="true">
<Columns>
<telerik:GridBoundColumn DataField="ContainerPage.PageTitle" HeaderText="Title" UniqueName="ContainerPage.PageTitle"
ReadOnly="true" />
</Columns>
</MasterTableView>
</telerik:RadGrid>
UPDATE2
Here is all exception message and stack trace:
Unable to cast object of type 'PineCMS.Core.PageInRole' to type 'Castle.Proxies.PageInRoleProxy'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidCastException: Unable to cast object of type 'PineCMS.Core.PageInRole' to type 'Castle.Proxies.PageInRoleProxy'.
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:
[InvalidCastException: Unable to cast object of type 'PineCMS.Core.PageInRole' to type 'Castle.Proxies.PageInRoleProxy'.]
Telerik.Web.UI.GetEnumerator>d__0.MoveNext() +175
Telerik.Web.UI.GridDataTableFromEnumerable.FillDataTableFromEnumerable(IQueryable enumerable) +1285
Telerik.Web.UI.GridDataTableFromEnumerable.FillData35() +3390
Telerik.Web.UI.GridDataTableFromEnumerable.FillData() +824
Telerik.Web.UI.GridResolveEnumerable.EnsureInitialized() +28
Telerik.Web.UI.GridEnumerableFromDataView..ctor(GridTableView owner, IEnumerable enumerable, Boolean CaseSensitive, Boolean autoGenerateColumns, GridColumnCollection presentColumns, String[] additionalField, Boolean retrieveAllFields) +242
Telerik.Web.UI.GridDataSourceHelper.CreateGridEnumerable(GridTableView owner, IEnumerable enumerable, Boolean caseSensitive, Boolean autoGenerateColumns, GridColumnCollection presentColumns, String[] additionalField, Boolean retrieveAllFields) +223
Telerik.Web.UI.GridDataSourceHelper.GetResolvedDataSource(GridTableView owner, Object dataSource, String dataMember, Boolean caseSensitive, Boolean autoGenerateColumns, GridColumnCollection presentColumns, String[] additionalField, Boolean retrieveAllFields) +595
Telerik.Web.UI.GridTableView.get_ResolvedDataSource() +243
Telerik.Web.UI.GridTableView.CreateChildControls(IEnumerable dataSource, Boolean useDataSource) +42
System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +72
System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +147
System.Web.UI.WebControls.DataBoundControl.PerformSelect() +261
Telerik.Web.UI.GridTableView.PerformSelect() +23
Telerik.Web.UI.GridTableView.DataBind() +363
Telerik.Web.UI.GridTableView.Rebind() +101
Telerik.Web.UI.GridCommandEventArgs.ExecuteCommand(Object source) +1174
Telerik.Web.UI.RadGrid.OnBubbleEvent(Object source, EventArgs e) +185
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +70
Telerik.Web.UI.GridItem.OnBubbleEvent(Object source, EventArgs e) +142
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +70
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +29
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2981
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.4927; ASP.NET Version:2.0.50727.4927
This exception probably comes from the code trying to re-attach a proxied/lazy-loading entity to a session. The most likely API call to throw this exception with a newer NHibernate (I don't have problem with 2.1 but I do have problems with latest) is Session.Lock(obj, LockMode.None).
If the programmer of this component first evicts the entity from the ISession and then re-loads it (perhaps cached?) into another one by id, or performs ISession.Update this problem should go away until the NHibernate team has figured out the underlying problem.
I had a similar problem with EntityFramework 6.0.
I had migrated from an old version of EntityFramework that did not use proxies and had some code that created and attached new instances of the entity via new MyEntity();.
My solution was to use dbContext.MyEntity.Create(); instead so I only work with proxies. Something similar should be available for NHibernate if I recall correctly.
My error was:
Unable to cast object of type 'MyProject.MyEntity' to type
'System.Data.Entity.DynamicProxies.MyEntity_849E94C98E5E543D6DF5245252144E3EAC00131F811886276B6ABD991719D232'
We ran into the same issue with RadGrid having AutomaticInserts. After inserting an item it throw InvalidCastException: Unable to cast object of type 'MyDbModel.Role' to type 'System.Data.Entity.DynamicProxies.Role_...' in DataBind() at Rebind().
The issue was gone after I adapted the DataBinding to have an OrderBy().