none
Build error while using class library using MEL data access RRS feed

  • Question

  • Hi,

    I had made a class library making use of MEL data access block. To use this class library in a console application i had added the reference into the console application project. When i try to use this class library in using block or create an instance of the class present in it, it gives an error saying are you missing an assembly. The thing is it is not able to find the class library even though i had added the reference.

    The class library is as follows:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Microsoft.Practices.EnterpriseLibrary.Data;
    using System.Data;

    namespace DataAccessApplication
    {
        public class DataAccessBase
        {
            private Database db;

            public Database CurrentDB
            {
                get
                {
                    return db;
                }
            }

            public DataAccessBase(Database defaultDatabase)
            {
                db = defaultDatabase;
            }
        }
    }

    //Injection class

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Microsoft.Practices.Unity;
    using Microsoft.Practices.EnterpriseLibrary.Common.Configuration.Unity;
    using System.Data.Common;

    namespace DataAccessApplication
    {
        public class InjectionClass
        {
            public InjectionClass()
            {
                var container = new UnityContainer().AddNewExtension<EnterpriseLibraryCoreExtension>();
                DataAccessBase myDbAccess = container.Resolve<DataAccessBase>();
                string sql = "SELECT * FROM Talent";
                DbCommand cmd = myDbAccess.CurrentDB.GetSqlStringCommand(sql);

                try
                {
                    cmd.ExecuteReader();
                }
                catch (Exception ex)
                {

                }

            }
        }
    }

    The console application's program class:

                

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using DataAccessApplication; //Getting error here

    namespace ConnectionLogConsole
    {
        public class Program
        {
            static void Main(string[] args)
            {
                Console.WriteLine("Initiating connections...");

            }
        }
    }

    Can any one help in this or is familiar with this kind of issue please help me out.

    I can share the whole solution if required..

    Thanks & Regards,

    John


    John

    Saturday, September 7, 2013 8:54 AM

Answers

  • Hi,

    I got rid of the issue. The reason console application was giving error while referring the class library using MEL DAAB because, the class library was having targeting to .NET 4.0 and the console application was on .NET 4.0 client profile. So, it was unable to reference the dependency of Database class used in the first class mentioned.

    Thanks & Regards


    John

    • Marked as answer by john0609 Sunday, September 8, 2013 12:23 PM
    Sunday, September 8, 2013 12:22 PM