Custom Module exception

Posted by Community Admin on 04-Aug-2018 19:13

Custom Module exception

All Replies

Posted by Community Admin on 23-Nov-2011 00:00
I created a custom module Using the Josh Morales "Developing Intra-Site Modules in Sitefinity 4" and "Sitefinity 4 Modules Made Simple" videos and accompanying blogs.  The code compiles and the module and widget install without error.  I was able to load the module admin page and add a couple of entries.  Suddenly out of the blue, now when I attempt to view the module admin page I'm getting this less than helpful execption:

Server Error in '/' Application.
Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
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.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
 
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:
 
[ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.]
   System.Reflection.RuntimeModule.GetTypes(RuntimeModule module) +0
   System.Reflection.RuntimeModule.GetTypes() +4
   System.Reflection.Assembly.GetTypes() +78
   System.Data.Metadata.Edm.ObjectItemConventionAssemblyLoader.LoadTypesFromAssembly() +32
   System.Data.Metadata.Edm.ObjectItemAssemblyLoader.Load() +25
   System.Data.Metadata.Edm.AssemblyCache.LoadAssembly(Assembly assembly, Boolean loadReferencedAssemblies, ObjectItemLoadingSessionData loadingData) +160
   System.Data.Metadata.Edm.AssemblyCache.LoadAssembly(Assembly assembly, Boolean loadReferencedAssemblies, KnownAssembliesSet knownAssemblies, EdmItemCollection edmItemCollection, Action`1 logLoadMessage, Object& loaderCookie, Dictionary`2& typesInLoading, List`1& errors) +166
   System.Data.Metadata.Edm.ObjectItemCollection.LoadAssemblyFromCache(ObjectItemCollection objectItemCollection, Assembly assembly, Boolean loadReferencedAssemblies, EdmItemCollection edmItemCollection, Action`1 logLoadMessage) +316
   System.Data.Metadata.Edm.ObjectItemCollection.ExplicitLoadFromAssembly(Assembly assembly, EdmItemCollection edmItemCollection, Action`1 logLoadMessage) +53
   System.Data.Metadata.Edm.MetadataWorkspace.ExplicitLoadFromAssembly(Assembly assembly, ObjectItemCollection collection, Action`1 logLoadMessage) +93
   System.Data.Metadata.Edm.MetadataWorkspace.LoadFromAssembly(Assembly assembly, Action`1 logLoadMessage) +130
   System.Web.UI.WebControls.EntityDataSourceView.ConstructContext() +595
   System.Web.UI.WebControls.EntityDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +76
   System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +21
   System.Web.UI.WebControls.DataBoundControl.PerformSelect() +143
   Telerik.Web.UI.GridTableView.PerformSelect() +38
   System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +74
   Telerik.Web.UI.GridTableView.DataBind() +364
   Telerik.Web.UI.RadGrid.DataBind() +173
   System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +66
   System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +75
   System.Web.UI.Control.EnsureChildControls() +102
   System.Web.UI.Control.PreRenderRecursiveInternal() +42
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2496
 
 
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.237

Anyone have any thoughts regarding what might be happening or how best to troubleshoot?

Thanks -- Steve
Posted by Community Admin on 23-Nov-2011 00:00
I forgot to mention that the module is using the Entity Data Model to read/write to a new SQL Server table in the Sitefinity database.  Nothing fancy really, an int for the primary key, a couple of varchar columns, several datetime columns, and a boolean.  Mapping details are shown in the attached image.

--Steve
Posted by Community Admin on 23-Nov-2011 00:00
Hi steve! I too encountered that issue when using the Entity Framework for the data layer. I seem to recall that opening the Data model file (edmx) and saving it, then building the project again fixed that issue, though I needed to do it each time I modified the data model.

another customer reported that deleting the website dll and pdb file (usually SitefinityWebApp.dll) and building the project again (not REbuild, just build it again) to create also appears to work.

I hope this is helpful! I would like to also add that since updating the project to use OpenAccess I never got this issue again :) so it might be worth looking into!
Posted by Community Admin on 23-Nov-2011 00:00
Thanks for the suggestions.  I tried both and alas, no joy.  I'll look into OpenAccess--don't know much about it so I've got some reading to do. 

I'd be curious to know if anyone is using the Entity Framework successfully, and if not, why the videos and example code are using it.

Thanks again -- Steve
Posted by Community Admin on 25-Nov-2011 00:00
I ended up updating the code to use OpenAccess which did in fact solve the problem.  I will say that using OpenAccess was very convoluted compared to using the Entity Framework.  The OpenAccess docs could have been a bit clearer and it would have been very helpful to have a video on the subject. 

Also, I tried using my original data table but OA does some funky column renaming under the hood which caused exception after exception. There wasn't much valuable data in the table so I deleted it and started from scratch.

Steve

This thread is closed