What appears to be a .net bug is happening after every recycle of a worker process. Only occurring when I'm using entity-framework
I've written a vb.net project (.net 4) that seems to work perfectly on my windows 7 machine, and seems to work fine when published to a windows server 2003 server.
The issue comes after a few hours on my server, I get the infamous "Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information". I haven't seen this problem at all when using visual studio.
Which seems to suggest to me that a reference to a dll / something is lost due to a cache process. Uploading anything to that folder temporally fixes the issue (including a test.txt file). Then after a few hours the issue returns.
I开发者_Go百科've turned off search indexing on the server and insured that the server is up to date.. but the error keeps on returning. (on investigation it returns every time the worker process recycles)
The issue only seems to appear on certain ascx files, these files reference an EntityDataSource that references an orders table.
Also I have attempted to get the LoaderExceptions and any other data with the following code:
Try
OrdersTable.DataBind()
Catch ex As ReflectionTypeLoadException
Response.Write(ex.Message)
If (Not ex.InnerException Is Nothing) Then
Response.Write(ex.InnerException.Message)
Response.Write(ex.LoaderExceptions)
For Each Parameter As DictionaryEntry In ex.Data
Dim key As Object = Parameter.Key
Dim value As Object = Parameter.Value
Response.Write(key & ":" & value & "<br>\n")
Next
End If
Response.End()
End Try
All that is written is the same error as before "Unable to load one or more of..."
New to the .net framework so any suggestions will be very much appreciated :).
Edit: Stack trace attached.
[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, Action1 logLoadMessage, Object& loaderCookie, Dictionary2& typesInLoading, List1& errors) +166
System.Data.Metadata.Edm.ObjectItemCollection.LoadAssemblyFromCache(ObjectItemCollection objectItemCollection, Assembly assembly, Boolean loadReferencedAssemblies, EdmItemCollection edmItemCollection, Action1 logLoadMessage) +316
System.Data.Metadata.Edm.ObjectItemCollection.ExplicitLoadFromAssembly(Assembly assembly, EdmItemCollection edmItemCollection, Action1 logLoadMessage) +53
System.Data.Metadata.Edm.MetadataWorkspace.ExplicitLoadFromAssembly(Assembly assembly, ObjectItemCollection collection, Action1 logLoadMessage) +93
System.Data.Metadata.Edm.MetadataWorkspace.LoadFromAssembly(Assembly assembly, Action1 logLoadMessage) +130
System.Web.UI.WebControls.EntityDataSourceView.ConstructContext() +585
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
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +74
System.Web.UI.WebControls.GridView.DataBind() +4
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
Have to tried to use the Fusion Log Viewer tool? It should give you some hints, although it's sometimes too verbose... Available here http://msdn.microsoft.com/en-us/library/e74a18c4
In the end the solution that was easiest for me was to not do what was causing the bug to surface.
I now no longer bind any data at design time.
<asp:GridView ID="InvoiceTable" runat="server" AllowPaging="True"
AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="Invoice_No"
DataSourceID="Invoices" CellPadding="4" ForeColor="#333333"
GridLines="None">
....[skiped for brevity]
</asp:GridView>
</div>
<asp:EntityDataSource ID="Invoices" runat="server"
ConnectionString="name=VetlabEntities1" DefaultContainerName="VetlabEntities1"
EnableFlattening="False" EntitySetName="SALES_MASTER">
</asp:EntityDataSource>
Becomes
<asp:GridView ID="InvoiceTable" runat="server" AllowPaging="True"
AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="Invoice_No"
DataSourceID="Invoices" CellPadding="4" ForeColor="#333333"
GridLines="None">
....[skiped for brevity]
</asp:GridView>
Protected Sub BindInvoice()
Dim db As New VetlabEntities1
InvoiceTable.DataSource = db.SALES_MASTER
InvoiceTable.DataBind()
End Sub
It also means that I now have to handle deleting / selecting etc. myself, which is a little irritating, however manageable.
精彩评论