Elad Benda
Elad Benda

Reputation: 36654

console application works only from vs2010

I wrote a console application project.

When I debug it through visual studio 2010 it runs and performs as needed.

When I run its exe from the cmd,

I don't see the log4net that (are redirected to the console)

No errors are shown on the console

The DB isn't updated.

What can cause this?

32bit proccess vs. 64?

My build is to 32bit.

I run on win7 with VS2010 dotNet 4

update:

My exe works.

but I cannot attach-to-it via visual studio

Log4net doesn't show logs to the console

this is my config file btw

<?xml version="1.0"?>
<configuration>
   <configSections>
    <section name="DBSubscriptionStorageConfig"
         type="NServiceBus.Config.DBSubscriptionStorageConfig, NServiceBus.Core" />
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>
  </configSections>

  <connectionStrings>
    <add name="ToolbarsDB" connectionString="server=DEV-DBSRV50;database=TOOLBARSDB;PASSWORD=toolbarsapp;UID=toolbarsapp" providerName="System.Data.SqlClient" />
  </connectionStrings>


  <log4net>
    <root>
      <level value="DEBUG" />
          <appender-ref ref="LogFileAppender" />
          <appender-ref ref="ConsoleAppender" />
      <level value="INFO" />
          <appender-ref ref="LogFileAppender" />
          <appender-ref ref="ConsoleAppender" />
      <level value="ERROR" />
          <appender-ref ref="LogFileAppender" />
          <appender-ref ref="ConsoleAppender" />
      <level value="FATAL" />
          <appender-ref ref="LogFileAppender" />
          <appender-ref ref="ConsoleAppender" />
    </root>
    <appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender" >
      <param name="File" value="log.txt" />
      <param name="AppendToFile" value="true" />
      <rollingStyle value="Size" />
      <maxSizeRollBackups value="10" />
      <maximumFileSize value="10MB" />
      <staticLogFileName value="true" />
      <layout type="log4net.Layout.PatternLayout" xmlns="">
        <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
      </layout>
    </appender>
    <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
      </layout>
    </appender>
  </log4net>

  <!--Publisher-->
  <DBSubscriptionStorageConfig>
    <NHibernateProperties>
      <add Key="connection.provider"
           Value="NHibernate.Connection.DriverConnectionProvider"/>
      <add Key="connection.driver_class"
           Value="NHibernate.Driver.SqlClientDriver"/>
      <add Key="connection.connection_string"
           Value="Data Source=DEV-DBSRV80;Initial Catalog=CPServicesDB;Persist Security Info=True;User ID=CPServicesDBUser;Password=oire^3jd!"/>
      <add Key="dialect"
           Value="NHibernate.Dialect.MsSql2005Dialect"/>
    </NHibernateProperties>
  </DBSubscriptionStorageConfig>
  <!-- End Publisher-->

  <appSettings>
    <add key="assemblyName" value="Conduit.CPServices.Logic.Bundlator"/>
    <add key="typeName" value="Conduit.CPServices.Logic.Bundlator.BundlatorMessageHandlers"/>
  </appSettings>

  <runtime>
    <loadFromRemoteSources enabled="true"/>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="NHibernate" publicKeyToken="AA95F207798DFDB4" culture="neutral"/>
        <bindingRedirect oldVersion="0.0.0.0-3.2.0.4000" newVersion="3.2.0.4000"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="CPServicesGeneralServiceBehavior">
          <serviceMetadata httpGetEnabled="false"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  </startup>
</configuration>

Upvotes: 0

Views: 333

Answers (1)

eandersson
eandersson

Reputation: 26352

If I understood you correctly you do not see the output when you run the application in Command Prompt, but it works fine in Debug Mode.

Are you reading the settings from a app.config by any chance? Maybe you need to copy the Application XML Configuration File as well as the Executable.

The file is normally called MyApplication.exe.config.

Upvotes: 1

Related Questions