Type converter initialization failed.

14 posts, 0 answers
  1. emad
    emad avatar
    4 posts
    Member since:
    Dec 2010

    Posted 14 Dec 2010 Link to this post

    Hi,
    I had revesion my openaccess to latest version 2010.3.1125.1,  after reversion I got following error :
    Type converter initialization failed. The converter with name 'VariableLengthStringConverter' does not convert from CLR type 'System.Int64' to SQL type 'nvarchar'.
    Parameter name: converterName
    Actual value was OpenAccessRuntime.Data.VariableLengthStringConverter, Telerik.OpenAccess.Runtime, Version=2010.3.1125.1, Culture=neutral, PublicKeyToken=7ce17eeaf1d59342

    please help me,

  2. Thomas
    Admin
    Thomas avatar
    590 posts

    Posted 15 Dec 2010 Link to this post

    Hello emad,

    it looks like your are having a nvarchar column that is mapped to a Int64 field, and this setup fails. Unfortunately, we dont yet give out the name of the column or field so that you will need to look manually to find such a field mapping. Alternativly, can you send us the failing project?

    Kind regards,
    Thomas
    the Telerik team
    Accelerate your learning with industry's first Telerik OpenAccess ORM SDK. Download today.
  3. DevCraft banner
  4. Ady
    Admin
    Ady avatar
    589 posts

    Posted 17 Dec 2010 Link to this post

    Hello emad,

    As mentioned in my reply to you in a similar thread - 375898, you can now attach a sample application to this post.

    Looking forward to resolving your issue soon.

    Greetings,
    Ady
    the Telerik team
    Accelerate your learning with industry's first Telerik OpenAccess ORM SDK. Download today.
  5. Jiri
    Jiri avatar
    7 posts
    Member since:
    Oct 2012

    Posted 18 Dec 2010 Link to this post

    Greetings to all,

    i'm experiencing the same issue but with another column type : Guid and Guid?

    The metadata for field 'guid' of class '...' cannot be initialized: Type converter initialization failed. The converter with name 'String2GuidConverter' does not convert from CLR type 'System.Guid' to SQL type 'RAW'.
    Parameter name: converterName
    Real value was OpenAccessRuntime.Data.String2GuidConverter, Telerik.OpenAccess.Runtime, Version=2010.3.1125.1, Culture=neutral, PublicKeyToken=7ce17eeaf1d59342.

    The metadata for field 'cancelDocGuid' of class '...' cannot be initialized: Type converter initialization failed. The converter with name 'String2GuidConverter' does not convert from CLR type 'System.Nullable`1[[System.Guid, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]' to SQL type 'RAW'.
    Parameter name: converterName
    Real value was OpenAccessRuntime.Data.String2GuidConverter, Telerik.OpenAccess.Runtime, Version=2010.3.1125.1, Culture=neutral, PublicKeyToken=7ce17eeaf1d59342.

    [Telerik.OpenAccess.Persistent(IdentityField="guid")]
    private Guid guid; // pk 
    [Telerik.OpenAccess.FieldAlias("guid")] 
    public Guid Guid 
      
        get { return guid; } 
        set { this.guid = value; } 
    }
      
    private Guid? cancelDocGuid; 
    [Telerik.OpenAccess.FieldAlias("cancelDocGuid")] 
    public Guid? CancelDocGuid 
        get { return cancelDocGuid; } 
        set { this.cancelDocGuid = value; } 
    }


    <view name="'...'" type="1" locked="False">
        <column name="CANCELDOCGUID" isPk="False" isAutoInc="False" adoType="-11" sqlType="RAW" length="16" isNull="True" />
        <column name="GUID" isPk="False" isAutoInc="False" adoType="-11" sqlType="RAW" length="16" isNull="False" />
        <class name="..." check="-1" generated="True">
            <field name="guid" type="1" isPK="True" column="GUID" valueType="System.Guid" />
            <field name="cancelDocGuid" type="1" isPK="False" column="CANCELDOCGUID" valueType="System.Nullable`1[[System.Guid, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]" />
        </class>
    </view>

    -- Edited --
    I downgrade back to the version 2010.2.1013.8 and everything works as expected ... version 2010.3.1110.3 gave me also exception

    Best regards

    Jiri
  6. emad
    emad avatar
    4 posts
    Member since:
    Dec 2010

    Posted 21 Dec 2010 Link to this post

    Hi,
    thanks Thomas,
    after some days I solved the problem by commenting some codes in App.config file :
    <field name="code" null-value="exception">
     <extension key="db-column" value="mssql">
      <!--<extension key="db-sql-type" value="nvarchar" />-->
      <extension key="db-length" value="50" />
      <extension key="db-type" value="BIGINT" />
      <extension key="db-column-name" value="Code" />
     </extension>
    </field>
    that worked for me.
  7. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 22 Dec 2010 Link to this post

    Hello,

    @emad: We are happy to see that you have solved the problem.

    @JL: With Q3 we introduced a whole new type-conversion framework and that is why you do not see this problem with older versions. The new framework may still have some limitations but gives the ability to implement custom type converters for handling more rare cases of mapping SQL to CLR types that cannot be handled automatically.
    The problem you experienced is one of those cases and the it can be avoided by implementing a type converter. The solution is already discussed in this forum thread. Hope that helps.

    Kind regards,
    Alexander
    the Telerik team
    Accelerate your learning with industry's first Telerik OpenAccess ORM SDK. Download today.
  8. Jiri Lev
    Jiri Lev avatar
    1 posts
    Member since:
    Jan 2010

    Posted 23 Dec 2010 Link to this post

    Hello Alexander,

    thanks for the answer, I forgot to look around and find the answer by myself :) - experince for nex time. Anyway thanks for pushing me the right way.

    All the best

    Jiri
  9. Christian
    Christian avatar
    81 posts
    Member since:
    Aug 2008

    Posted 18 Jan 2011 Link to this post

    Hi,
    I have a database on an MS-SQL Server. All tables have a key with the data type "uniqueidentifier". The foreign keys have the data type.
    I have created with the Visual Designer from the tables into classes.

    Here the class code:
    #pragma warning disable 1591
    //------------------------------------------------------------------------------
    // <auto-generated>
    //     This code was generated by a tool.
    //
    //     Changes to this file may cause incorrect behavior and will be lost if
    //     the code is regenerated.
    // </auto-generated>
    //------------------------------------------------------------------------------
    using System;
    using System.Data;
    using System.Linq;
    using System.Linq.Expressions;
    using System.Data.Common;
    using System.Collections.Generic;
    using Telerik.OpenAccess;
      
      
    namespace Berlin.Polizei.LKA.KooStBetrug.DatenModell    
    {
        [Table("Katalog_Fahrzeugart")]
        public partial class clsKatalogFahrzeugart
        {
            private string fahrzeugart;
            [Column("Fahrzeugart", OpenAccessType = OpenAccessType.Varchar, Length = 50, SqlType = "nvarchar")]
            [Storage("fahrzeugart")]
            public virtual string Fahrzeugart 
            
                get
                {
                    return this.fahrzeugart;
                }
                set
                {
                    this.fahrzeugart = value;
                }
            }
              
            private Guid iD;
            [Column("ID", OpenAccessType = OpenAccessType.Guid, IsPrimaryKey = true, SqlType = "uniqueidentifier")]
            [Storage("iD")]
            public virtual Guid ID 
            
                get
                {
                    return this.iD;
                }
                set
                {
                    this.iD = value;
                }
            }
              
            private DateTime? lastUpdate;
            [Column("LastUpdate", OpenAccessType = OpenAccessType.DateTime, IsNullable = true, SqlType = "datetime")]
            [Storage("lastUpdate")]
            public virtual DateTime? LastUpdate 
            
                get
                {
                    return this.lastUpdate;
                }
                set
                {
                    this.lastUpdate = value;
                }
            }
              
            private DateTime? createDate;
            [Column("CreateDate", OpenAccessType = OpenAccessType.DateTime, IsNullable = true, SqlType = "datetime")]
            [Storage("createDate")]
            public virtual DateTime? CreateDate 
            
                get
                {
                    return this.createDate;
                }
                set
                {
                    this.createDate = value;
                }
            }
              
            private string autor;
            [Column("Autor", OpenAccessType = OpenAccessType.Varchar, IsNullable = true, Length = 20, SqlType = "nvarchar")]
            [Storage("autor")]
            public virtual string Autor 
            
                get
                {
                    return this.autor;
                }
                set
                {
                    this.autor = value;
                }
            }
              
            private IList<clsDatenFahrzeug> clsDatenFahrzeugs1 = new List<clsDatenFahrzeug>();
            [Collection(InverseProperty = "ClsKatalogFahrzeugart", IsManaged = true)]
            [Storage("clsDatenFahrzeugs1")]
            public virtual IList<clsDatenFahrzeug> clsDatenFahrzeugs 
            
                get
                {
                    return this.clsDatenFahrzeugs1;
                }
            }
              
        }
    }

    Here the function to create and save an object:
    clsKatalogFahrzeugart neueFahrzeugart = new clsKatalogFahrzeugart();
    neueFahrzeugart.ID = Guid.NewGuid();            
    neueFahrzeugart.Fahrzeugart = "Neu";
    Program.dbContext.Add(neueFahrzeugart);


    When saving an instance I get the following error message:
    The metadata for field 'fahrzeugart' of class 'Berlin.Polizei.LKA.KooStBetrug.DatenModell.clsDatenFahrzeug' cannot be initialized: Type converter initialization failed. The converter with name 'VariableLengthStringConverter' does not convert from CLR type 'System.Nullable`1[[System.Guid, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]' to SQL type 'nvarchar'.
    Parametername: converterName
    Der tatsächliche Wert war OpenAccessRuntime.Data.VariableLengthStringConverter, Telerik.OpenAccess.Runtime, Version=2010.3.1125.1, Culture=neutral, PublicKeyToken=7ce17eeaf1d59342.

    A deeper analysis shows the following:
    #pragma warning disable 1591
    //------------------------------------------------------------------------------
    // <auto-generated>
    //     This code was generated by a tool.
    //
    //     Changes to this file may cause incorrect behavior and will be lost if
    //     the code is regenerated.
    // </auto-generated>
    //------------------------------------------------------------------------------
    using System;
    using System.Data;
    using System.Linq;
    using System.Linq.Expressions;
    using System.Data.Common;
    using System.Collections.Generic;
    using Telerik.OpenAccess;
      
      
    namespace Berlin.Polizei.LKA.KooStBetrug.DatenModell    
    {
        [Table("Katalog_Fahrzeugart")]
        public partial class clsDatenFahrzeug
        {
            private Guid iD;
            [Column("ID", OpenAccessType = OpenAccessType.Guid, IsPrimaryKey = true, SqlType = "uniqueidentifier")]
            [Storage("iD")]
            public virtual Guid ID 
            
                get
                {
                    return this.iD;
                }
                set
                {
                    this.iD = value;
                }
            }
              
            private System.Nullable<System.Guid> fahrzeugart;
            [Column("Fahrzeugart", OpenAccessType = OpenAccessType.Varchar, Length = 50, SqlType = "nvarchar")]
            [Storage("fahrzeugart")]
            public virtual System.Nullable<System.Guid> Fahrzeugart 
            
                get
                {
                    return this.fahrzeugart;
                }
                set
                {
                    this.fahrzeugart = value;
                }
            }
              
            private DateTime? lastUpdate;
            [Column("LastUpdate", OpenAccessType = OpenAccessType.DateTime, IsNullable = true, SqlType = "datetime")]
            [Storage("lastUpdate")]
            public virtual DateTime? LastUpdate 
            
                get
                {
                    return this.lastUpdate;
                }
                set
                {
                    this.lastUpdate = value;
                }
            }
              
            private DateTime? createDate;
            [Column("CreateDate", OpenAccessType = OpenAccessType.DateTime, IsNullable = true, SqlType = "datetime")]
            [Storage("createDate")]
            public virtual DateTime? CreateDate 
            
                get
                {
                    return this.createDate;
                }
                set
                {
                    this.createDate = value;
                }
            }
              
            private string autor;
            [Column("Autor", OpenAccessType = OpenAccessType.Varchar, IsNullable = true, Length = 20, SqlType = "nvarchar")]
            [Storage("autor")]
            public virtual string Autor 
            
                get
                {
                    return this.autor;
                }
                set
                {
                    this.autor = value;
                }
            }
              
            private string kennzeichen;
            [Column()]
            [Storage("kennzeichen")]
            public virtual string Kennzeichen 
            
                get
                {
                    return this.kennzeichen;
                }
                set
                {
                    this.kennzeichen = value;
                }
            }
              
            private string herstellerTyp;
            [Column()]
            [Storage("herstellerTyp")]
            public virtual string Hersteller_Typ 
            
                get
                {
                    return this.herstellerTyp;
                }
                set
                {
                    this.herstellerTyp = value;
                }
            }
              
            private string farbe;
            [Column()]
            [Storage("farbe")]
            public virtual string Farbe 
            
                get
                {
                    return this.farbe;
                }
                set
                {
                    this.farbe = value;
                }
            }
              
            private clsKatalogFahrzeugart clsKatalogFahrzeugart;
            [ForeignKeyAssociation(SharedFields = "Fahrzeugart", TargetFields = "iD")]
            [Storage("clsKatalogFahrzeugart")]
            public virtual clsKatalogFahrzeugart ClsKatalogFahrzeugart 
            
                get
                {
                    return this.clsKatalogFahrzeugart;
                }
                set
                {
                    this.clsKatalogFahrzeugart = value;
                }
            }
              
        }
    }


    The attribute of the field "fahrzeugart" in the class clsDatenFahrzeug is set wrong. I have no chance to change this attribute manually because it is entered by the Visual Designer.


    My Problem is: Why is saving not possible?

    For help I would be grateful.
    Christian
  10. Zoran
    Admin
    Zoran avatar
    534 posts

    Posted 24 Jan 2011 Link to this post

    Hi Christian,

    So it seems that the 'Fahrzeugart' member was not mapped correctly. However I am not sure which of the following two cases is the real cause of the exception:

       - We have marked it as a 'varchar' column but it is indeed a 'uniqueidentifier'.
       - We have mapped the column to Nullable<Guid> but it should instead be mapped to a string.

    We will appreciate if you would send us a script of your database schema so that we could try to reproduce it locally and fix the problem as soon as possible. The problem is related to the fact that we changed our type handling framework in the product and there are obviously few glitches left which we should address.
     
    Kind regards,
    Zoran
    the Telerik team
    Accelerate your learning with industry's first Telerik OpenAccess ORM SDK. Download today.
  11. Christian
    Christian avatar
    81 posts
    Member since:
    Aug 2008

    Posted 03 Feb 2011 Link to this post

    Hi,
    at the moment the project works fine. So I can't reproduce the error. Thanks. Christian
  12. Jeff
    Jeff avatar
    6 posts
    Member since:
    Jul 2010

    Posted 01 Mar 2011 Link to this post

    I am having the same problem but with a column of type SqlGeometry instead of Guid.  Is there a solution for the SqlGeometry type?  Thanks
  13. Thomas
    Admin
    Thomas avatar
    590 posts

    Posted 02 Mar 2011 Link to this post

    Hello Jeff,

     yes, the upcoming Q1 release will contain the support for the SqlGeometry, SqlGeography and SqlHierarchyId types.

    Greetings,
    Thomas
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  14. Waheed
    Waheed avatar
    1 posts
    Member since:
    Aug 2013

    Posted 24 Nov 2014 Link to this post

    Hi,
    I am getting this error with my project. I am using an MsSql2012 database

    Type converter initialization failed. The converter with
    name 'VariableLengthAnsiStringConverter' does not convert from CLR type
    'System.Int32' to SQL type 'varchar'.
    Parameter name: converterName
    Actual
    value was OpenAccessRuntime.Data.VariableLengthAnsiStringConverter,
    Telerik.OpenAccess.Runtime, Version=2013.3.1320.1, Culture=neutral,
    PublicKeyToken=7ce17eeaf1d59342.

    How do I fix it
  15. Boris Georgiev
    Admin
    Boris Georgiev avatar
    190 posts

    Posted 25 Nov 2014 Link to this post

    Hello Waheed,

    This error is thrown if there is a varchar column in the database mapped to an int property in the domain model.

    Unfortunately still we are not providing information about the property for which the error is thrown, so you should check your model manually for mismatch between the properties and the columns.

    I hope that helps.

    Regards,
    Boris Georgiev
    Telerik
     
    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
     
Back to Top
DevCraft banner