in

CodeSmith Community

Your Code. Your Way. Faster!

Problems with getting Winforms App to work 'could not load file or assembly Data.SqlClient or one of its dependendies. error'

Last post 03-20-2007 1:12 PM by Satvinder. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 03-20-2007 11:52 AM

    • Satvinder
    • Not Ranked
    • Joined on 03-20-2007
    • Posts 4
    • Points 95

    Problems with getting Winforms App to work 'could not load file or assembly Data.SqlClient or one of its dependendies. error'

    Hi, using Codesmith 4.0 and NietTiers latest build version as of today.

     I am trying to create a winforms application, I build the entire generated solution and it has no problems

    I add a winforms project with 1 form and when I run any command in the service layer after creating an instance of it

     e.g. userService us = new UserService();

    User user = us.GetByUserName("SSB");

    I always get an exception could not load file or assembly Data.SqlClient or one of its dependendies. The System cannot find the file specified ...WindowsApplication2.vshost.exe.config in the DomainUtil.cs

    I have created an app.config file in my windows application with all 3 sections I needed to add as per the report.html that is generated.

    And added the Data, Enties and Service Dlls as references to my winforms project and in the using clause.

    I have been trying all day without sucesss, any help or pointers would be welcome.

    Regards

    Satvinder

     

     

    Filed under: , ,
    • Post Points: 80
  • 03-20-2007 11:54 AM In reply to

    • Satvinder
    • Not Ranked
    • Joined on 03-20-2007
    • Posts 4
    • Points 95

    Re: Problems with getting Winforms App to work 'could not load file or assembly Data.SqlClient or one of its dependendies. error'

    If anyone has a example csp file for the Northwind project with a winforms example app including app.config that would really help

     Cheers

     Satvinder

    • Post Points: 5
  • 03-20-2007 12:04 PM In reply to

    • bgjohnso
    • Top 10 Contributor
    • Joined on 09-15-2005
    • Spokane, WS
    • Posts 763
    • Points 22,465

    RE: Problems with getting Winforms App to work 'could not load file or assembly Data.SqlClient or one of its dependendies. error'

     

    This may be a silly question, but did you add a reference to the Data.SqlClient dll?  Here’s my app.config from a sample Northwind winforms application:

     

    <?xml version="1.0" encoding="utf-8" ?>

    <configuration>

       <configSections>

          <section name="netTiersService"

           type="Northwind.Data.Bases.NetTiersServiceSection, Northwind.Data"

           allowDefinition="MachineToApplication"

           restartOnExternalChanges="true" />

       </configSections>

     

       <connectionStrings>

          <add name="netTiersConnectionString" connectionString="Data Source=(local);Initial Catalog=Northwind;Integrated Security=true;Connection Timeout=1;" />

       </connectionStrings>

     

       <netTiersService defaultProvider="SqlNetTiersProvider">

          <providers>

             <!--

        *** SqlClient Provider ***

          connectionStringName: sqlclient connection string to the db

          useStoredProcedure: if trueindicates that we use the stored procedures, otherwise, we use parametrized queries that are embedded.

        -->

             <add

               name="SqlNetTiersProvider"

               type="Northwind.Data.SqlClient.SqlNetTiersProvider, Northwind.Data.SqlClient"

               connectionStringName="netTiersConnectionString"

               useStoredProcedure="false"

               providerInvariantName="System.Data.SqlClient"

               entityFactoryType="Northwind.Entities.EntityFactory"

             useEntityFactory="true"

             enableEntityTracking="false"

               enableMethodAuthorization="false"

               defaultCommandTimeout="30"

            />

             <!>

          </providers>

       </netTiersService>

     

    </configuration>

     

    Ben Johnson
    ------------------------------
     Member of the .NetTiers team
     Visit http://www.nettiers.com
    ------------------------------
    • Post Points: 35
  • 03-20-2007 12:37 PM In reply to

    • Satvinder
    • Not Ranked
    • Joined on 03-20-2007
    • Posts 4
    • Points 95

    Re: RE: Problems with getting Winforms App to work 'could not load file or assembly Data.SqlClient or one of its dependendies. error'

    yes included that reference , still no luck

     

    I ran my Codesmith against northwind using the following csp, app.config and windows form

     Northwind.csp

    <?xml version="1.0"?>
    <codeSmith xmlns="http://www.codesmithtools.com/schema/csp.xsd">
      <propertySets>
        <propertySet output="NetTiers.txt" template="C:\Program Files\NetTiers\netTiers2.0.1\NetTiers.cst">
          <property name="ExecuteSql">False</property>
          <property name="SQLFolderName">SQL</property>
          <property name="ViewReport">True</property>
          <property name="LaunchVisualStudio">False</property>
          <property name="IncludeUnitTest">None</property>
          <property name="IncludeComponentLayer">ServiceLayer</property>
          <property name="IncludeDatabaseFeatures">None</property>
          <property name="IncludeWCFDataAttributes">False</property>
          <property name="SerializeEntityState">False</property>
          <property name="IncludeXmlAttributes">False</property>
          <property name="CustomCodeFolderName">App_Code</property>
          <property name="BusinessLogicLayerNameSpace">Entities</property>
          <property name="DataAccessLayerNameSpace">Data</property>
          <property name="UnitTestsNameSpace">UnitTests</property>
          <property name="SignAssembly">False</property>
          <property name="GenerateWebLibrary">True</property>
          <property name="IncludeDesignTimeSupport">True</property>
          <property name="GenerateWebservice">False</property>
          <property name="AttemptCreateLocalVirtualDirectory">False</property>
          <property name="GenerateWebsite">False</property>
          <property name="UseWebAppProject">False</property>
          <property name="OverwriteWebConfig">False</property>
          <property name="IncludeAtlasLibrary">False</property>
          <property name="IncludeAtlasToolkit">False</property>
          <property name="GenerateWebsiteAdmin">False</property>
          <property name="WebAdminSiteName">Application Name</property>
          <property name="RetryEnabled">False</property>
          <property name="RetryMaxAttempts">5</property>
          <property name="RetrySleepTime">1000</property>
          <property name="IncludeCustoms">True</property>
          <property name="CustomNonMatchingReturnType">DataSet</property>
          <property name="IncludeDrop">True</property>
          <property name="IncludeInsert">True</property>
          <property name="IncludeUpdate">True</property>
          <property name="IncludeSave">True</property>
          <property name="IncludeDelete">True</property>
          <property name="IncludeGet">True</property>
          <property name="IncludeGetList">True</property>
          <property name="IncludeGetListByFK">True</property>
          <property name="IncludeGetListByIX">True</property>
          <property name="IncludeFind">True</property>
          <property name="IncludeManyToMany">True</property>
          <property name="IncludeRelations">True</property>
          <property name="IsolationLevel">None</property>
          <property name="InsertSuffix">_Insert</property>
          <property name="UpdateSuffix">_Update</property>
          <property name="DeleteSuffix">_Delete</property>
          <property name="SelectSuffix">_Get</property>
          <property name="SelectAllSuffix">_List</property>
          <property name="FindSuffix">_Find</property>
          <property name="GenerateWinLibrary">False</property>
          <property name="RootNameSpace">Northwind</property>
          <property name="OutputDirectory">c:\NetTiers\Northwind</property>
          <property name="MappingFile">c:\NetTiers\Northwind\NorthwindMapping.config</property>
          <property name="ComponentLayerNameSpace">Services</property>
          <property name="SourceTables">
            <connectionString>Data Source=Laptop\SUNNY;Initial Catalog=NorthWind;Persist Security Info=True;User ID=sa; password=walking;</connectionString>
            <providerType>SchemaExplorer.SqlSchemaProvider,SchemaExplorer.SqlSchemaProvider</providerType>
            <tableList>
          <table>
            <owner>dbo</owner>
            <name>Suppliers</name>
          </table>
          <table>
            <owner>dbo</owner>
            <name>Categories</name>
          </table>
          <table>
            <owner>dbo</owner>
            <name>Products</name>
          </table>
        </tableList>
          </property>
          <property name="WebServiceOutputPath">c:\NetTiers\Northwind\WebServices</property>
          <property name="WebServiceUrl">http://localhost/NorthwindServices</property>
          <property name="ChooseSourceDatabase">
            <connectionString>Data Source=Laptop\SUNNY;Initial Catalog=NorthWind;Persist Security Info=True;User ID=sa; password=walking;</connectionString>
            <providerType>SchemaExplorer.SqlSchemaProvider,SchemaExplorer.SqlSchemaProvider</providerType>
          </property>
          <property name="RetrySleepStyle">Constant</property>
          <property name="MethodNames">
            <MethodNamesProperty xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="">
          <Get>Get</Get>
          <GetAll>GetAll</GetAll>
          <GetPaged>GetPaged</GetPaged>
          <Find>Find</Find>
          <Insert>Insert</Insert>
          <Update>Update</Update>
          <Save>Save</Save>
          <Delete>Delete</Delete>
          <DeepLoad>DeepLoad</DeepLoad>
          <DeepSave>DeepSave</DeepSave>
          <GetTotalItems>GetTotalItems</GetTotalItems>
          <BulkInsert>BulkInsert</BulkInsert>
        </MethodNamesProperty>
          </property>
          <property name="StrippedTablePrefixes">tbl;tbl_</property>
          <property name="EntityFormat">{0}</property>
          <property name="CollectionFormat">{0}Collection</property>
          <property name="GenericViewFormat">VList&lt;{0}&gt;</property>
          <property name="GenericListFormat">TList&lt;{0}&gt;</property>
          <property name="ProviderFormat">{0}Provider</property>
          <property name="InterfaceFormat">I{0}</property>
          <property name="BaseClassFormat">{0}Base</property>
          <property name="EnumFormat">{0}List</property>
          <property name="ManyToManyFormat">{0}From{1}</property>
          <property name="ServiceClassNameFormat">{0}Service</property>
          <property name="ParseDbColDefaultVal">False</property>
          <property name="ChangeUnderscoreToPascalCase">False</property>
          <property name="AliasFilePath" />
          <property name="ProcedurePrefix" />
          <property name="CustomProcedureStartsWith">_{0}_</property>
          <property name="CSPUseDefaultValForNonNullableTypes">False</property>
        </propertySet>
      </propertySets>
    </codeSmith>

     

    App.Config

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
     <configSections>
      <section name="netTiersService"
          type="Northwind.Data.Bases.NetTiersServiceSection, Northwind.Data"
          allowDefinition="MachineToApplication"
          restartOnExternalChanges="true" />


     </configSections>
     <connectionStrings>
      <add name="netTiersConnectionString" connectionString="Data Source=Laptop\SUNNY;Initial Catalog=NorthWind;Persist Security Info=True;User ID=sa; password=walking;" />
     </connectionStrings>
     
     <netTiersService defaultProvider="SqlNetTiersProvider">
      <providers>

       <add
       name="SqlNetTiersProvider"
       type="Northwind.Data.SqlClient.SqlNetTiersProvider, Northwind.Data.SqlClient"
       connectionStringName="netTiersConnectionString"
       providerInvariantName="System.Data.SqlClient"
       entityFactoryType="Northwind.Entities.EntityFactory"
       useEntityFactory="true"
       enableEntityTracking="true"
       enableMethodAuthorization="false"
       useStoredProcedure="false"
      />

      </providers>
     </netTiersService>
    </configuration> 

    Form1.cs - has 1 button on form and thats it

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using Northwind.Data;
    using Northwind.Entities;
    using Northwind.Services;

    namespace WindowsApplication1
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }

            private void button1_Click(object sender, EventArgs e)
            {
                Northwind.Services.CategoriesService c = new CategoriesService();
                TList<Categories> cats = c.GetByCategoryName("Beverages");

            }
        }

     

     

    • Post Points: 5
  • 03-20-2007 1:05 PM In reply to

    • bgjohnso
    • Top 10 Contributor
    • Joined on 09-15-2005
    • Spokane, WS
    • Posts 763
    • Points 22,465

    RE: RE: Problems with getting Winforms App to work 'could not load file or assembly Data.SqlClient or one of its dependendies. error'

    So, Northwind.Data.SqlClient is in your bin folder of the Win application?

    Ben Johnson
    ------------------------------
     Member of the .NetTiers team
     Visit http://www.nettiers.com
    ------------------------------
    • Post Points: 35
  • 03-20-2007 1:12 PM In reply to

    • Satvinder
    • Not Ranked
    • Joined on 03-20-2007
    • Posts 4
    • Points 95

    Re: RE: RE: Problems with getting Winforms App to work 'could not load file or assembly Data.SqlClient or one of its dependendies. error'

    I feel so stupid....

     thank you for all your help, it works now.

     

    Regards

    Satvinder

     

    • Post Points: 5
Page 1 of 1 (6 items)
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems