Reputation: 179
I have a C# console application that runs fine if executed locally, however when trying to remotely execute, my logger (Nlog) logs an Oracle exception. Specifically it's: ORA-12154: TNS:could not resolve the connect identifier specified
This is my PowerShell script to invoke the application remotely:
# Define the remote server's hostname or IP address
$remoteServer = "Computer"
# Define the credentials to use for logging into the remote server
$username = "Username"
$password = ConvertTo-SecureString "Password" -AsPlainText -Force
$credentials = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $password
# Define the path to the .NET program you want to execute on the remote server
$programPath = "D:\Application\ABD\ABD.exe"
# Define parameters to pass to the .NET program
$parameters = "-s1"
# Use Invoke-Command to execute the program on the remote server
$result = Invoke-Command -ComputerName $remoteServer -Credential $credentials -ScriptBlock {
param($programPath, $parameters)
# Execute the .NET program with parameters and capture the exit status
$exitCode = & $programPath $parameters
# Return the exit status
return $exitCode
} -ArgumentList $programPath, $parameters
# Output the exit status returned by the .NET program
Write-Output "Exit Status: $result"
I was getting this error locally as well but after installing Oracle Client on the host computer, the application runs fine locally.
My question is why would I not be able to run the application without an Oracle Exception remotely, if it runs fine locally?
Update I switched the TNS_ADMIN environment variable to the host computer instead of a shared location and I got it to run. I'm guessing I have to pass the environment variable in the PowerShell script.
Upvotes: 0
Views: 68