Hi There,
Wondering if anybody has any ideas on this one. Here's where I'm confused.
1) I have a ultrawebgrid on an aspx page and a csladatasource that binds my business object collection to the grid on post back after a submit button is pressed. Works great.
2) I then went and added a "CheckBox" column to the grid and click submit and as long as I don't change the value by clicking on the checkbox everything works great. As soon as I check and uncheck checkboxes in the grid. The databinding failes saying that it can't find one of my libraries. The library it can't find would cause #1 to fail as well.
The actual Error is
[FileNotFoundException: Could not load file or assembly 'MyCompany.MyLibrary' or one of its dependencies. The system cannot find the file specified.]
It took me for ever to figure out what was causing this error and have no idea how to solve it. I can click on the submit button as much as I was as long as I don't change the value of the checkbox from what it was set at when loaded.
Here is the full error from the event viewer. It's very strange.
The column with checkboxes binds correctly to the boolean value in the collection using the csladatasource and if I don't change any of the values the page submits correctly.
BUT
If I unselect or select another checkbox and then submit the form. I get the following error.
Event code: 3005
Event message: An unhandled exception has occurred.
Event time: 5/29/2008 9:40:38 AM
Event time (UTC): 5/29/2008 1:40:38 PM
Event ID: 994033e7d6824bc88d6b75e0d590b0cf
Event sequence: 15
Event occurrence: 1
Event detail code: 0
Application information:
Application domain: /LM/W3SVC/1/Root/MyWebSite-1-128565419777970339
Trust level: Full
Application Virtual Path: /MySite
Application Path: C:\Dev\MyCompany\MySite\
Machine name: DEV
Process information:
Process ID: 4308
Process name: aspnet_wp.exe
Account name: DEV\ASPNET
Exception information:
Exception type: FileNotFoundException
Exception message: Could not load file or assembly 'MyCompany.MyLibrary' or one of its dependencies. The system cannot find the file specified.
Request information:
Request URL: http://localhost/MySite/admin/search.aspx
Request path: /MySite/admin/search.aspx
User host address: 127.0.0.1
User: DevUser
Is authenticated: True
Authentication Type: Csla
Thread account name: DEV\ASPNET
Thread information:
Thread ID: 1
Thread account name: DEV\ASPNET
Is impersonating: False
Stack trace: at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.Load(String assemblyString)
at Csla.Web.CslaDataSource.GetType(String assemblyName, String typeName)
at Csla.Web.CslaDataSourceView.get_CanUpdate()
at Infragistics.WebUI.UltraWebGrid.UltraWebGrid.UpdateDBRow(UltraGridRow row, UltraGridRow oldRow)
at Infragistics.WebUI.UltraWebGrid.UltraWebGrid.ProcessChanges(StateChanges stateChanges, Boolean fireEvents)
at Infragistics.WebUI.UltraWebGrid.UltraWebGrid.RaisePostDataChangedEvent()
at System.Web.UI.Page.RaiseChangedEvents()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Hmm.
I usually see this exception during deserialization of an object. But ultimately the core issue is in the way .NET tries to find pre-loaded assemblies when you attempt to get at a Type object by name.
Obviously deserialization needs to get a Type object by name to create an empty instance of your object type so it can deserialize data into that object.
What is happening here is that CslaDataProvider needs to find out if the target business object is "updatable", which it does by examining the Type object for the business object.
To do that, it needs to get the Type object, and it does that using the type name you provided at design time via the properties window or attribute on the CslaDataProvider tag in your aspx page.
Ultimately it calls the standard Type.GetType() method, which does all the real work. But this is exactly the point at which deserialization can fail too - so I suspect the core issue is the same, though there's one other possibility.
The likely core issue is that .NET has different ways of loading an assembly. Assemblies loaded each way are stored in a different list - for example there's a list for dynamically loaded assemblies. Oddly, Type.GetType() doesn't check all the lists - it only checks some of them - to find the requested assembly, and this causes the failure.
The other possible issue is that the UltraGrid might be creating its own AppDomain that doesn't use the same assembly probing path(s) as the normal ASP.NET AppDomain. You can run into issues along this line when using nunit for example, because nunit creates an AppDomain inside which your tests run.
OK.
So if it is the first issue, the solution would be to use the "Serialization bug workaround" code from EnterpriseServicesPortal. This code should be run ONCE per AppDomain, so probably in your web application startup event handler in global.asax. It hooks an event on the current AppDomain and does a more thorough search to find the assembly in the case that an assembly isn't found automatically.
That's easy enough to try - so give that a go and see if it fixes the issue.
If it doesn't fix this issue then I'm not entirely sure what to try...
In any case, the UltraGrid seems to be doing something very strange here to get the CslaDataProvider running in some context where it can't load assembly information...
Hi Rocky,
Thanks for the great tip!.. Read up on the "Serialization bug workaround" and sure sounds like that's what is wrong. After reading up I didn't want the end user to have to configure anything but the web app. So I opted just to remove the csla data source and override the grid databinding and paging... Works great now! No more errors :)
Thanks again for the quick reply!
Hi RangerGuy,
I'm running into something similar. You wouldn't happen to be using classes that are in the App_Code folder and specify a namespace would you?
Thanks,
Mike
Thanks Rock I will try that :)
Here is the error reported by ASP. This is the error that displays instead of the page. I just noticed it's more detailed than the event viewer message
Could not load file or assembly 'MyCompany.MyLibrary' or one of its dependencies. The system cannot find the file specified.
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.IO.FileNotFoundException: Could not load file or assembly 'MyCompany.MyLibrary' or one of its dependencies. The system cannot find the file specified.
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.
Assembly Load Trace: The following information can be helpful to determine why the assembly 'MyCompany.MyLibrary' could not be loaded.
Assembly manager loaded from: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
Running under executable C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_wp.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = DEV\ASPNET
LOG: DisplayName = MyCompany.MyLibrary
(Partial)
LOG: Appbase = file:///C:/Dev/MyCompany/MySite/
LOG: Initial PrivatePath = C:\Dev\MyCompany\MySite\bin
Calling assembly : Csla, Version=2.1.3.0, Culture=neutral, PublicKeyToken=93be5fdc093e4c30.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Dev\MyCompany\MySite\web.config
LOG: Using host configuration file: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet.config
LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/mysite/293577e4/bc069f76/MyCompany.MyLibrary.DLL.
LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/mysite/293577e4/bc069f76/MyCompany.MyLibrary/MyCompany.MyLibrary.DLL.
LOG: Attempting download of new URL file:///C:/Dev/MyCompany/MySite/bin/MyCompany.MyLibrary.DLL.
LOG: Attempting download of new URL file:///C:/Dev/MyCompany/MySite/bin/MyCompany.MyLibrary/MyCompany.MyLibrary.DLL.
LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/mysite/293577e4/bc069f76/MyCompany.MyLibrary.EXE.
LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/mysite/293577e4/bc069f76/MyCompany.MyLibrary/MyCompany.MyLibrary.EXE.
LOG: Attempting download of new URL file:///C:/Dev/MyCompany/MySite/bin/MyCompany.MyLibrary.EXE.
LOG: Attempting download of new URL file:///C:/Dev/MyCompany/MySite/bin/MyCompany.MyLibrary/MyCompany.MyLibrary.EXE.
Copyright (c) Marimer LLC