Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8903565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:54:03+00:00 2026-06-15T01:54:03+00:00

I have an application that uses Process.Start to execute an exe. It works fine

  • 0

I have an application that uses Process.Start to execute an exe. It works fine for all the .exe that I have tested except when the .exe has a configuration file where it gets a connectionstring, when this happens I get a System.NullReferenceException. this is my code.

to execute the exe:

string eucApp = @"C:\Temp\app.exe"
startInfo = new ProcessStartInfo(eucApp);
using (Process execProcess = Process.Start(startInfo))
{
    execProcess.WaitForExit();
}

then the exe starts and the first thing that does is get the a connection string with this code line

strCadena = ConfigurationManager.ConnectionStrings("ConnectionString")

If I replace this with the connectionstring like this, it works fine

strCadena = "Data Source=HostName;Initial Catalog=MyDB;Integrated security=True"

I would remove the config file and put its values into the .exe code but the trouble is that I have more than 500 .exe’s that uses config files so if any one knows a way to avoide this please tell me!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T01:54:05+00:00Added an answer on June 15, 2026 at 1:54 am

    thanks for your help. I figured out the problem. Somehow the .exe was pointing to the app.config of the aplication that start’s the process. I added this class to the .exe that is developed in VB .Net

    Imports System.Configuration
    Imports System.Reflection
    Public Class AppConfig
      Implements IDisposable
      Public Shared Function Change(ByVal path As String) As AppConfig
    
        Return New ChangeAppConfig(path)
      End Function
      Public Overridable Sub Dispose() Implements IDisposable.Dispose
      End Sub
      Private Class ChangeAppConfig
        Inherits AppConfig
        Private ReadOnly oldConfig As String = AppDomain.CurrentDomain.GetData("APP_CONFIG_FILE").ToString
        Private disposedValue As Boolean
        Public Sub New(ByVal path As String)
          AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE", path)
          ResetConfigMechanism()
        End Sub
        Public Overrides Sub Dispose()
          If (Not disposedValue) Then
            AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE", oldConfig)
            ResetConfigMechanism()
            disposedValue = True
          End If
          GC.SuppressFinalize(Me)
        End Sub
        Private Shared Sub ResetConfigMechanism()
    
          GetType(ConfigurationManager).GetField("s_initState", BindingFlags.NonPublic Or BindingFlags.Static).SetValue(Nothing, 0)
          GetType(ConfigurationManager).GetField("s_configSystem", BindingFlags.NonPublic Or BindingFlags.Static).SetValue(Nothing, Nothing)
          Dim assemblies() As Type = GetType(ConfigurationManager).Assembly.GetTypes()
          For Each assembly As Type In assemblies
            If (assembly.FullName = "System.Configuration.ClientConfigPaths") Then
              assembly.GetField("s_current", BindingFlags.NonPublic Or BindingFlags.Static).SetValue(Nothing, Nothing)
              Exit For
            End If
          Next
        End Sub
      End Class
    End Class
    

    I call Change function at the begining of the program

    AppConfig.Change(Application.StartupPath & "\app.exe.Config")
    

    This way it take the right config file

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some code that I wanted to improve. It uses Process.Start and should
I have an application that has a main form and uses an event handler
I have an application that uses a ResourceDictionary to set the styles, which it
I have an application that uses Hibernate. It generated the following SQL statement. I
I have an application that uses multiple WebViews. Nowhere do I set the priority
I have an application that uses RPC for interprocess communications. Turns out that synchronous
I have an application that uses rest to communicate to a server, i would
I have an application that uses CoreData. I previously had a class named Marker
I have an application that uses the Paperclip plugin for image upload. Now that
We have an application that uses Hibernate's 2nd level caching to avoid database hits.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.