Program fails to start; Event Viewer logs ConfigurationsErrorException - c#

Issue: On my development machine, everything works fine. However, when I copy the executable to the server, my program doesn't start
What I've done so far: I checked the event viewer and the error stack looks like this:
Application: Project.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Configuration.ConfigurationErrorsException
Stack:
at System.Configuration.ClientConfigurationSystem.EnsureInit(System.String)
at System.Configuration.ClientConfigurationSystem.PrepareClientConfigSystem(System.String)
at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(System.String)
at System.Configuration.ConfigurationManager.GetSection(System.String)
at System.Configuration.ConfigurationManager.get_ConnectionStrings()
at Project.BaseService..ctor()
at Project.Service..ctor()
at Project.Program.Main()
I checked online and, most of the times, this error is generated by some misplacement of configSections on the .config files. To make sure this was not the case, I let both app.config and .exe.config files clean (only the section was there), but my program still didn't work.
Then, I generated a dump file from the failing process and here is where things get strange: the exception that is thrown when I'm calling ConfigurationManager.ConnectionStrings is "Configuration System failed to initialize", with a "The 'add' start tag on line 257 position 6 does not match the end tag of 'connectionManagement'. Line 258, position 3." inner exception. I double-checked my entire project and there is not a single reference to "connectionManagement" anywhere! I even tried to check AppDomain.CurrentDomain.SetupInformation.ConfigurationFile's value and it indicates the right config file.
By fixing this connectionManagement issue I'll probably be able to run my application, but do you guys have any idea about where this might be coming from?

Problem was on the machine.config file on the server. Changing it solved the problem!

Related

ODP.Net new OracleConnection "Value cannot be null Parameter Name: path"

I have a project using ODP.Net version 12.2.1100. This project was working fine until opening today. The following line of code is causing the error:
using (var cn = new OracleConnection("User Name={userID}, etc, etc"))
The error being returned is:
Value cannot be null.
Parameter name: path
Inner exception
at System.Security.Permissions.FileIOPermission.CheckIllegalCharacters(String[] str, Boolean onlyCheckExtras)
Things I have tried so far to resolve the issue:
Changed connection string from EZ Connect to full Oracle string
Uninstalled and resintalled Oracle.ManagedDataAccess.dll (through NuGet)
Ensured all config files were up to date
Created a new simple test console project (which connected fine)
I had the same issue. It occurred also with the Managed Data Provider and it happens with the first Oracle class that gets instantiated, e.g. OracleParameter. But it only happens in the debugger of a unit test or in other cases where Assembly.GetEntryAssembly() returns null.
The call stack of the error gave me a hint: It calls System.Web.HttpRuntime.AppDomainAppPath. This throws the exception. By looking at the Oracle code I found a try-catch around it that should catch the exception but for some reason that sometimes fails.
In another project I get the same exception but this time it gets caught before it hits my code. Strange.
The following work around works for me:
try
{
new OracleDependency();
}
catch
{
}
This triggers the static constructor of ConfigBaseClass and ignores the error. It is sufficient to call this once in your code, e.g. also in a static constructor. I used OracleDependency as it doesn't require a Dispose as most other Oracle classes.
So next on my list was checking in my project and asking a colleague to open it to determine if the problem travelled with the code. He was able to execute successfully. I deleted my working copy and pulled it down from TFS, everything started working again. I suspect that something was corrupt in the bin directory.
I got this error in my integration test project. After deleting the bin folder and rebuilding, the error disappeared.

Unexpected error launching Internet Explorer. IELaunchURL() returned 800700C1

Every time I launch Selenium WebDriver on one of my test servers, I'm receiving the following error from the SDK:
System.InvalidOperationException: System.InvalidOperationException:
Unexpected error launching Internet Explorer. IELaunchURL() returned
800700C1 for URL 'http://localhost:5555/' (NoSuchDriver).
The rest of my test servers are not having any trouble. Also, I verified that all of the internet zones were set to protected.
Delete the "C:\Program" file from your system
Answer from https://code.google.com/p/selenium/issues/detail?id=6181
It seems a bit odd, but when I checked, there was a 0 byte "Program" file in the root of the C drive. I deleted the file and the issue went away.

Exception occurred during store operation: Staging of a component file (Office.dll) did not succeed

When we deployed the recent build of our ClickOnce product, we get the following error:
APPLICATION SUMMARY
* Installable application.
* Trust url parameter is set.
ERROR SUMMARY
Below is a summary of the errors, details of these errors are listed later in the log.
* Activation of https://install.dev.sl.bta.cc/PA/Assette%20Presentations.application resulted in exception. Following failure messages were detected:
+ Exception occurred during store operation.
+ Value does not fall within the expected range.
COMPONENT STORE TRANSACTION FAILURE SUMMARY
* Transaction at [9/17/2011 9:39:06 AM]
- Staging of a component file (Office.dll) did not succeed.
- Staging of a component (dev.Appender.dll.genman) did not succeed.
- Staging of a component file (dev.Appender.dll) did not succeed.
There has been nothing changed except few references. Any idea why does this happen?
The main reason of this is that the some files of the application is being opened or running during the the setup of the click once package. Make sure all the files of the application are closed
Virus scanner was the cause of this for me. After uninstalling AVG (no luck with temporarily disabling it) installation went fine.

Issue with Microsoft Enterprise Library 5.0 and custom powershell cmdlet

I'm creating a custom powershell 1.0 cmdlet that will allow me to feed exceptions from powershell scripts to the Microsoft Enterprise Library v5.0 exception handling block.
I load up my Exception handling config from an external file since the cmdlet is compiled into a dll, and then try to create an instance of ExceptionManager using the config.
Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource config =
new Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource(configFile);
WriteDebug("Config loaded from " + Path.GetFullPath(configFile));
EnterpriseLibraryContainer.Current = EnterpriseLibraryContainer.CreateDefaultContainer(config);
exManager = EnterpriseLibraryContainer.CreateDefaultContainer(config).GetInstance<ExceptionManager>();
This fails when I call my command from powershell with the following error:
Microsoft.Practices.ServiceLocation.ActivationException: Activation error occured while trying to get instance of type ExceptionManager, key "" ---> Microsoft.Practices.Unity.ResolutionFailedException: Resolution of the dependency failed, type = "Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionManager", name = "(none)".
Exception occurred while: while resolving. Exception is: InvalidOperationException - The type ExceptionManager cannot be constructed. You must configure the container to supply this value.
The frustrating thing is that the code works perfectly fine when used in a stand-alone console application with the exact same configuration. I'm not really sure why I'm getting this error; I've made sure that I'm using the same assemblies that are referenced in the config file and I've made sure that I'm referencing all the necessary enterprise library dlls in my project.
Additionally, I've had to copy the Enterprise Library dlls into the powershell install directory (%SystemRoot%\system32\WindowsPowerShell\v1.0), otherwise I would receive FileNotFoundExceptions about not being able to find the correct library while the configuration file was being processed. I don't have too much experience with powershell or enterprise library, but I'm guessing that this might be resolved by playing around with AppDomain settings.
Turns out I wasn't giving an absolute path to my configuration file, which was causing weirdness. I originally just set it to "widgit.dll.config", and threw it under %systemroot%\System32, since that's the default working directory of my powershell, and seemed to get rid of the initial "file not found" errors I was having (didn't want to change the working directory until I understood the entire problem). On a hunch, I copied the config into the powershell directory and renamed it powershell.exe.config, and that solved my other problem.
Putting stuff into system directories isn't the most elegant solution at this point, but it's sufficient for my current problem.

Test run errors with MSTest in VS2010

When I run my Unit Tests, all tests pass, but instead of "Test run succeeded" or whatever the success message is, I get "Test run error" in the little bar that tells me how many of my tests pass, even though all my tests passed.
When i click the text, I'm taken to a page that tells me the following two things happened:
Warning: conflict during test run deployment: deployment item '[...]\Booking.Web.dll' directly or indirectly referenced by the test container [...]\Booking.Web.Tests.dll cannot be deployed to 'Booking.Web.dll' because otherwise the file '[...]\Booking.Web.dll' would override deployment item '[...]\Booking.Web.dll' directly or indirectly referenced by '[...]\Booking.Web.Tests.dll'
Error: Cannot initialize the ASP.NET project 'Booking.Web'
Exception was thrown: The website could not be configured correctly; getting ASP.NET proccess information failed. Requesting 'http://localhost:54131/VSEnterpriseHelper.axd' returned an error: The remote server returned an error: (500) Internal Server Error.
I don't understand half of what it's complaining about. How do I get rid of these errors?
(And for reference: Booking.Web is an ASP.NET MVC 2 project, Booking.Web.Tests is a Test project, [...] is the full local path to the projects in my environment, in most of the cases above to the /bin/debug/ folder inside the Booking.Web project)
Update: As instructed, I looked for more info in Event Viewer. Here's what I found:
3008
A configuration error has occurred.
5/8/2010 2:26:15 AM
5/8/2010 12:26:15 AM
4ffbe9180c3d4c02adb9ac4d61dd0928
1
1
0
4484bbf4-1-129177519750954331
Full
/
D:\...\Booking.Web\
AASLOEG
1876
WebDev.WebServer40.EXE
Aasloeg\Tomas
ConfigurationErrorsException
Could not load file or assembly 'Ninject.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=79764a4ef1548af1' or one of its dependencies. Strong name signature could not be verified. The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key. (Exception from HRESULT: 0x80131045) at
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) at
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() at
System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) at
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) at
...stack trace in absurdum.
First of all - you have Code Coverage enabled. You can read here about it. So there is no problems with Unit Tests. This is code coverage problem.
Second thing - this warning is ok - never mind about it.
Third thing - this error - this is the key problem.
There can be different problems - most common is that you should refference more assemblies. To find out what exactly should be loaded you must go to Event Viewer and look at at Windows Logs->Application
I had the same error related to MS-Test complaining that a DLL could "override deployment item blah.dll".
This was happening because I was running MS-Test for multiple DLL's at once like so:
mstest.exe /testcontainer:Tests.web.dll /testcontainer:Tests.svcs.dll /testcontainer:Tests.core.dll
When MS-Test was running this, it tried to take all the output DLL's from the tests and place them in out /Out directory of the test run. In my case, Tests.svcs.dll and Tests.core.dll both referenced the same assembly (Core.dll) and therefore it tried to copy that DLL to the same spot twice (thus causing the warning).
To resolve this, I separated the test runs for each assembly which gave each test run it's own /Out folder for output DLL's
mstest.exe /testcontainer:Tests.web.dll
mstest.exe /testcontainer:Tests.svcs.dll
mstest.exe /testcontainer:Tests.core.dll

Categories

Resources