Unable to load type System.Data.Entity.DynamicProxies.ClassName_A1398804A2AD2636A55B88C252D769E3468A12F2C5A773B1895C58D312108335 required for deserialization.
Or:
Unable to find assembly 'EntityFrameworkDynamicProxies-XXXX, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
What is happening here is that you are likely using POCO objects for the Entity Framework. These objects have proxy classes automatically generated for them behind the scenes. Upon a first visit to the application they are compiled, however if they are used in a post (for instance when posting data to an MVC Action) and that type is used in serialization then they have not yet been created.
Your code may look like:
[HttpPost]
public ActionResult Edit(Job job, [Deserialize] List
When you post to this, the framework will NOT create the proxies automatically. You must access the page via a normal manner (ie via HttpGet) and the proxies will all be created. If you must have this feature, then you may possibly be able to do something in Application_Start to reference an Entity class and thus all of them should be auto generated.
In short - this fix is simply refresh the page. If posting to the page requires deserializing POCO objects from the page, then you will need to implement some mechanism to use the POCO Entities before the method is attempted, possibly in Application_Start.
Note - I did have a 'little' success calling something like this in Application_Start
ReplyDeletecontext.YourObject.CreateObject();
It got me past the above error, however I'm now getting
Object of type 'System.Runtime.Serialization.TypeLoadExceptionHolder' cannot be converted to type 'XXX'
where XXX is a custom object of mine.
I did not change namespaces (something that can cause this issue) so still working on a resolution, but it's something you can try.
I do know that refreshing the page from another browser window will eliminate this issue if you try again from the original browser window, so if you need a quick workaround, that will do it - obviously not ideal but if it means saving data or failing, I'd take the save.
Faced the same issue today and used Value Injecter to solve it. It's as simple as:
ReplyDeletevar dynamicProxyMember = _repository.FindOne(m=>m.Id = 1);
var member = new Member().InjectFrom(dynamicProxyMember) as Member;
You can download it here: http://valueinjecter.codeplex.com/
DeleteHaving a hard time getting this to work with generic objects, where you don't really have the object until AFTER its been deserialized. So, if you have a statement like this: var objectValue = (T)formatter.Deserialize(stream)
DeleteAny advise?
Any further tips on this issue? I put the code in app_start as suggested, and am now regularly getting TypeLoadExceptionHolder errors. Stopping IIS/aspnet_state service fixes it for a while, but not fool proof...
ReplyDeleteThanks for sharing useful information. I am giving best MVC online training in Hyderabad
ReplyDeleteMVC online training
online MVC training
asp.net with MVC training
MVC training
Thanks for your information about this great post.IEEE Projects Center in Chennai | IEEE Projects Center in Velachery
ReplyDeletethanks for sharing excellent information....
ReplyDeletePLC Training in Chennai | PLC Training Institute in Chennai | PLC Training Center in Chennai | PLC SCADA Training in Chennai | PLC SCADA DCS Training in Chennai | Best PLC Training in Chennai | Best PLC Training Institute in Chennai | PLC Training Centre in Chennai | Automation Training in Chennai | Automation Training Institute in Chennai
Great blog...
ReplyDeleteVLSI Training in Chennai | Best VLSI Training in Chennai | VLSI Training Centres in Chennai | VLSI Courses in Chennai | VLSI Training Courses in Chennai | VLSI Training Institute in Chennai | VLSI Training Institutes in Chennai | Best VLSI Training Institute in Chennai