Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > LLBLGen Pro Runtime Framework> The type initializer
 

Pages: 1
LLBLGen Pro Runtime Framework
The type initializer
Page:1/1 

  Print all messages in this thread  
Poster Message
mohamed
User



Location:
Salmia, kuwait
Joined on:
10-Mar-2008 19:55:21
Posted:
136 posts
# Posted on: 15-Oct-2009 18:27:02.  
Greetings,

after execute this query



it throw    The type initializer for 'BNIS.AMS.DAL.FactoryClasses.EntityFactoryFactory' threw an exception.

using (var adapter = DataAccess.DataAdapterFactory.Create())
         {
             LinqMetaData metaData = new LinqMetaData(adapter);
             var q = from c in metaData.SysDBRelation
                     select c;

             var li = q.ToList();
         }

stack trace
Code:

at BNIS.AMS.DAL.FactoryClasses.EntityFactoryFactory.GetFactory(Type typeOfEntity)
at BNIS.AMS.DAL.FactoryClasses.ElementCreator.GetFactoryImpl(Type typeOfEntity) in C:\Projects\AMS\Solution\BNIS.AMS.DAL\DatabaseGeneric\FactoryClasses\EntityFactories.cs:line 43197
at BNIS.AMS.DAL.FactoryClasses.ElementCreator.GetFactory(Type typeOfEntity) in C:\Projects\AMS\Solution\BNIS.AMS.DAL\DatabaseGeneric\FactoryClasses\EntityFactories.cs:line 43122
at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProvider2.ExecuteEntityProjection(QueryExpression toExecute)
at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.ExecuteExpression(Expression handledExpression)
at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.Execute(Expression expression)
at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.System.Linq.IQueryProvider.Execute(Expression expression)
at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProQuery`1.Execute()
at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at BNIS.AMS.BL.EntityDB.GetDBObjectName(String relationName) in C:\Projects\AMS\Solution\BNIS.AMS.BL\Globals\EntityDBMapping.cs:line 46
at BNIS.AMS.Win.Form1.kryptonButton1_Click(Object sender, EventArgs e) in C:\Projects\AMS\Solution\BNIS.AMS.Win\Form1.cs:line 39
at System.Windows.Forms.Control.OnClick(EventArgs e)
at ComponentFactory.Krypton.Toolkit.KryptonButton.OnClick(EventArgs e)
at ComponentFactory.Krypton.Toolkit.KryptonButton.b(Object A_0, MouseEventArgs A_1)
at ComponentFactory.Krypton.Toolkit.ButtonController.OnClick(MouseEventArgs e)
at ComponentFactory.Krypton.Toolkit.ButtonController.MouseUp(Control c, Point pt, MouseButtons button)
at ComponentFactory.Krypton.Toolkit.ViewBase.MouseUp(Point pt, MouseButtons button)
at ComponentFactory.Krypton.Toolkit.ViewBase.MouseUp(Point pt, MouseButtons button)
at ComponentFactory.Krypton.Toolkit.ViewBase.MouseUp(Point pt, MouseButtons button)
at ComponentFactory.Krypton.Toolkit.ViewBase.MouseUp(Point pt, MouseButtons button)
at ComponentFactory.Krypton.Toolkit.ViewManager.MouseUp(MouseEventArgs e, Point rawPt)
at ComponentFactory.Krypton.Toolkit.VisualControlBase.OnMouseUp(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at ComponentFactory.Krypton.Toolkit.VisualControlBase.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)




using
VS 2008,
SQL 2008,
Adapter mode,
Shared templates.NET2.0
SD.LLBLGen.Pro.LinqSupportClasses.NET35.dll version 2.6.9.1008,
presets Adapter.General2008

  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
14569 posts
# Posted on: 16-Oct-2009 10:06:12.  
I can't find anything in the generated code that can throw such exception.
So maybe there were some corrupt compiles IL.

Would you please make sure you rebuild the entire solution and see if the exception goes away.

I als recommend using VS SP1.


  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37797 posts
# Posted on: 16-Oct-2009 10:21:07.  
The static constructor of the entity factory failed it seems. Could you please place a breakpoint in that constructor (in the EntityFactories.cs file) and check why it fails?
Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
mohamed
User



Location:
Salmia, kuwait
Joined on:
10-Mar-2008 19:55:21
Posted:
136 posts
# Posted on: 16-Oct-2009 16:49:21.  
France.. Yes. I got this exception.
it occurs when EntityType is Unknow as my friend Omar posted http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=16697

Code:

static EntityFactoryFactory()
        {
            Array entityTypeValues = Enum.GetValues(typeof(BNIS.AMS.DAL.EntityType));
            foreach(int entityTypeValue in entityTypeValues)
            {
                IEntity2 dummy = GeneralEntityFactory.Create((BNIS.AMS.DAL.EntityType)entityTypeValue);
                _factoryPerType.Add(dummy.GetType(), dummy.GetEntityFactory());
            }
        }


Is it right to write logic to bypass Unknow entityType, or you use it in other places?


  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
14569 posts
# Posted on: 19-Oct-2009 11:39:29.  
Quote:
it occurs when EntityType is Unknow as my friend Omar posted http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=16697


AFAIK, EntityType can't be unknown, have you implemented this yourself?
Did you or Omar add a Type of Unknown = 0 to the entityType enum?
  Top
omar
User



Location:
Salmiya, Kuwait
Joined on:
15-Oct-2004 15:44:57
Posted:
569 posts
# Posted on: 19-Oct-2009 13:25:44.  
Yes Walaa. As Mohammad explained, he traced the exception to the fact that the EntityType enum has the value Unknown=0 which is ofcourse NOT mapped to any actual entity type.

What Mohmmad needs to have is for LLBL Linq provider to handle the case when an EntityType value is NOT mapped to an entity type.


We don't know who we are until we see what we can do  Top
mohamed
User



Location:
Salmia, kuwait
Joined on:
10-Mar-2008 19:55:21
Posted:
136 posts
# Posted on: 19-Oct-2009 13:38:09.  
Or instead of the LLBL Linq provider, do I need to modify the EntityFactory() code to handle the case of the Unknown value ??
  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37797 posts
# Posted on: 19-Oct-2009 15:36:06.  
will look into it.

Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37797 posts
# Posted on: 19-Oct-2009 16:47:27.  
Could you explain please how you end up with an EntityType enum value which isn't a valid value for an entity? Did you change the templates that valid entities start with 1 ?

(as for every entity in the model, there's a valid EntityType value and a valid factory entry in GeneralEntityFactory. )
Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
mohamed
User



Location:
Salmia, kuwait
Joined on:
10-Mar-2008 19:55:21
Posted:
136 posts
# Posted on: 19-Oct-2009 17:10:07.  
Just add Unknown =0, in SD_ConstantsEnumsTemplate


Code:

<[If HasEntity]>
    /// <summary>
    /// Enum definition for all the entity types defined in this namespace. Used by the entityfields factory.
    /// </summary>
    public enum EntityType:int
    {
        Unknown = 0,
<[Foreach Entity CommaCrLf]>        ///<summary><[CurrentEntityName]></summary>
        <[CurrentEntityName]>Entity<[NextForeach]>
    }
<[EndIf]>




  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37797 posts
# Posted on: 20-Oct-2009 09:53:43.  
ah, in that case: add an if statement (C#, not template) in entityfactoriesadapter.template, line 186, where you check on '0' and continue if the value is 0.

You have to understand that the generated code isn't checking on the validity of the EntityType value as that enum is generated as well, so it always is correct.
Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.