1

私のクライアントは、私がとても簡単にできるように思えることを私に尋ねます。彼は nopcommerce 1.9 Web サイトを所有しており、クライアントのアドレスを変更するための単純な Windows フォーム アプリケーションを開発したいと考えています。だから私はニュースウィンドウフォームプロジェクトを設定しようとしました:

static void Main(string[] args)
{
    // Code that runs on application startup
    NopConfig.Init();

    //initialize IoC
    IoC.InitializeWith(new DependencyResolverFactory());

    //initialize task manager
    TaskManager.Instance.Initialize(NopConfig.ScheduleTasks);
        TaskManager.Instance.Start();

        //open
        new FormClient().Show();

        TaskManager.Instance.Stop();
    }

次に、データを公開するサービス マネージャーを作成します。

public class ServiceManager
{
    public ICustomerService CustomerService;

    public ServiceManager()
    {
        var dbContext = IoC.Resolve<NopObjectContext>();
        CustomerService = new CustomerService(dbContext);
    }

}

CustomerService また、解決メソッドがインスタンス化する具体的なクラスを見つけられないため、メソッドにアクセスできませんNopObjectContext

(nop commerce 1.9 は次の場所にあります: http://nopcommerce.codeplex.com/downloads/get/176949 )

4

1 に答える 1

1

最後に、それは動作します:

App.config は次のようにする必要があります。

<?xml version="1.0"?>
<configuration>
  <configSections>
    <section name="NopConfig" type="NopSolutions.NopCommerce.BusinessLogic.Configuration.NopConfig, Nop.BusinessLogic" requirePermission="false"/>
    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <section name="NopSolutions.NopCommerce.BusinessLogic.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    </sectionGroup>

  </configSections>
  <appSettings>
    <add key="dependencyResolverTypeName" value="NopSolutions.NopCommerce.BusinessLogic.Infrastructure.UnityDependencyResolver, Nop.BusinessLogic" />
  </appSettings>
  <connectionStrings>
    <add name="NopEntities" connectionString="metadata=res://*/Data.NopModel.csdl|res://*/Data.NopModel.ssdl|res://*/Data.NopModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=EGG-BANKS;Initial Catalog=nopvierge2;Persist Security Info=True;User ID=sa;Password=sqlserver;MultipleActiveResultSets=True;Application Name=EntityFramework&quot;" providerName="System.Data.EntityClient" />
    <add name="NopSqlConnection" connectionString="Data Source=DAVID-TOSH\SQLEXPRESS;Initial Catalog=nop;Integrated Security=True;Persist Security Info=False;MultipleActiveResultSets=True;Connect Timeout=120" />

  </connectionStrings>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup>
  <applicationSettings>
    <NopSolutions.NopCommerce.BusinessLogic.Properties.Settings>
      <setting name="Nop_BusinessLogic_Clickatell_PushServerWS" serializeAs="String">
        <value>http://api.clickatell.com/soap/webservice_vs.php</value>
      </setting>
      <setting name="Nop_BusinessLogic_EuropaCheckVatService_checkVatService" serializeAs="String">
        <value>http://ec.europa.eu/taxation_customs/vies/services/checkVatService</value>
      </setting>
    </NopSolutions.NopCommerce.BusinessLogic.Properties.Settings>
  </applicationSettings>

  <NopConfig>
    <SqlServer ConnectionStringName="NopSqlConnection"/>
    <ScheduleTasks>
      <Thread seconds="60">
        <!--do NOT enable ClearCache task if you have enabled tracking online users-->
        <task name="ClearCache" type="NopSolutions.NopCommerce.BusinessLogic.Caching.ClearCacheTask, Nop.BusinessLogic" enabled="false" stopOnError="false"/>
        <task name="PurgeOnlineUsers" type="NopSolutions.NopCommerce.BusinessLogic.Audit.UsersOnline.PurgeOnlineUsersTask, Nop.BusinessLogic" enabled="true" stopOnError="false"/>
        <task name="Emails" type="NopSolutions.NopCommerce.BusinessLogic.Messages.SendQueuedMessagesTask, Nop.BusinessLogic" enabled="true" stopOnError="false" maxTries="5"/>
        <task name="KeepAlive" type="NopSolutions.NopCommerce.BusinessLogic.Utils.KeepAliveTask, Nop.BusinessLogic" enabled="true" stopOnError="false" path="keepalive/ping.ashx"/>
      </Thread>
      <Thread seconds="600">
        <task name="DeleteExpiredCustomerSessions" type="NopSolutions.NopCommerce.BusinessLogic.CustomerManagement.DeleteExpiredCustomerSessionsTask, Nop.BusinessLogic" enabled="true" stopOnError="false" deleteExpiredCustomerSessionsOlderThanMinutes="43200"/>
        <task name="DeleteExpiredShoppingCarts" type="NopSolutions.NopCommerce.BusinessLogic.Orders.DeleteExpiredShoppingCartsTask, Nop.BusinessLogic" enabled="false" stopOnError="false" deleteExpiredShoppingCartsOlderThanMinutes="259200"/>
      </Thread>
      <Thread seconds="60">
        <task name="UpdateExchangeRates" type="NopSolutions.NopCommerce.BusinessLogic.Directory.ExchangeRates.UpdateExchangeRateTask, Nop.BusinessLogic" enabled="true" stopOnError="false"/>
      </Thread>
      <Thread seconds="3600">
        <task name="DatabaseMaintance" type="NopSolutions.NopCommerce.BusinessLogic.Maintenance.DatabaseMaintanceTask, Nop.BusinessLogic" enabled="false" stopOnError="false"/>
      </Thread>
    </ScheduleTasks>
  </NopConfig>
</configuration>

program.cs ファイルを使用:

    static void Main(string[] args)
    {

        // Code that runs on application startup
        NopConfig.Init();

        //initialize IoC
        IoC.InitializeWith(new DependencyResolverFactory());

        //initialize task manager
        TaskManager.Instance.Initialize(NopConfig.ScheduleTasks);
        TaskManager.Instance.Start();

        new form1().show();

        TaskManager.Instance.Stop();
    }
于 2012-06-03T07:55:35.703 に答える