I get the following error message when I try to start my console application:
The application is in break mode
Your app has entered a break state, but no code is currently executing
that is supported by the selected debug engine (e.g. only native
runtime code is executing).
I have put a break point directly at the Main method and the code never gets there.
The only thing I have added is the following values to App.config:
<appSettings>
<add key="QueueItemsToGet" value="25" />
</appSettings>
If I check the exception in Output -> Debug or Diagnostics Tools I can only see this error:
Exception thrown: 'System.TypeInitializationException' in NLog.dll
An unhandled exception of type 'System.TypeInitializationException' occurred in Unknown Module.
The type initializer for 'MyApp.Program' threw an exception.
However if I remove the <appSettings> section everything works, including Nlog.
I should have looked twice, it seems this error can occur if you add sections twice. In my case it was two definitions of appSettings since further down in the config the area was already added. I hope this can help someone else who makes the same mistake.
It was happening to me when I got an error on a static field initialization, for example, if you have a static Uri variable that is initialized with an invalid Uri (an empty string, in my case)
Related
While converting an OWIN app to the new csproj format I hit a few issues. The first issue had to do with the changed output directory (since it now includes the runtime in the path). This threw the following error:
Could not load file or assembly 'Microsoft.Owin.Host.SystemWeb' or one of its dependencies. The system cannot find the file specified.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Owin.Host.SystemWeb' or one of its dependencies. The system cannot find the file specified.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
I was able to fix this by setting the path in the Web.config:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="bin/net461" />
</assemblyBinding>
</runtime>
After that I am now confronted with this issue:
The following errors occurred while attempting to load the app.
- No assembly found containing an OwinStartupAttribute.
- The given type or method 'ClientWebAPI.Startup' was not found. Try specifying the Assembly.
To disable OWIN startup discovery, add the appSetting owin:AutomaticAppStartup with a value of "false" in your web.config.
To specify the OWIN startup Assembly, Class, or Method, add the appSetting owin:AppStartup with the fully qualified startup class or configuration method name in your web.config.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.EntryPointNotFoundException: The following errors occurred while attempting to load the app.
- No assembly found containing an OwinStartupAttribute.
- The given type or method 'ClientWebAPI.Startup' was not found. Try specifying the Assembly.
To disable OWIN startup discovery, add the appSetting owin:AutomaticAppStartup with a value of "false" in your web.config.
To specify the OWIN startup Assembly, Class, or Method, add the appSetting owin:AppStartup with the fully qualified startup class or configuration method name in your web.config.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
I have declared the entry point using the assembly attribute:
[assembly: OwinStartup(typeof(API.Startup))]
namespace API
{
public class Startup
{ /*...*/ }
}
The "Sdk" style csproj, sometimes called the VS2017 project format, does not yet support ASP.NET 4 projects. See the following issues:
https://github.com/dotnet/sdk/issues/491 (1)
https://github.com/dotnet/project-system/issues/2670 (2)
There are two layers of issues here: (1) MSBuild and (2) Visual Studio. If you understand how targets and imports work well enough, you could workaround (1) and make the Sdk style csproj work for an Owin project.
The more difficult part is (2) - Visual Studio. When switching to the Sdk style project, under the hood, VS is switching to an entirely new implementation of the project system, the one that is open sourced in https://github.com/dotnet/project-system. This project system does not yet fully support ASP.NET 4 projects.
You can workaround (2) by using Microsoft.Owin.SelfHost instead of using Microsoft.Owin.Host.SystemWeb. To make using Microsoft.Owin.Host.SystemWeb work, VS needs to know how to generate web.config and applicationhost.config file for IIS Express, how to launch the IIS Express site, and attach to process once launched. Much of that is not ported to the new project system, and I'm not sure if it will be. The new project system was designed to work with ASP.NET Core which uses a very different method for launching and configuring IIS Express.
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!
I have a hosted MVC 4 application with MEF system in it. Everytime the system tries to create the controller that is injected by the MEF, this error occurs:
The composition produced a single composition error. The root cause is
provided below. Review the CompositionException.Errors property for
more detailed information.
1) Specified argument was out of the range of valid values. Parameter
name: site
Resulting in: An exception occurred while trying to create an instance
of type 'EAccountingControllers.EAccountingController'.
Resulting in: Cannot activate part
'EAccountingControllers.EAccountingController'. Element:
EAccountingControllers.EAccountingController -->
EAccountingControllers.EAccountingController --> AssemblyCatalog
(Assembly="EAccounting, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null")
Resulting in: Cannot get export
'EAccountingControllers.EAccountingController
(ContractName="EAccounting")' from part
'EAccountingControllers.EAccountingController'. Element:
EAccountingControllers.EAccountingController
(ContractName="EAccounting") -->
EAccountingControllers.EAccountingController --> AssemblyCatalog
(Assembly="EAccounting, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null")
It is fine If I hosted on my local IIS, but it produces error when I hosted on external hosting provider.
What is causing this error?
Try checking what is happening in the constructor of EAccountingController. I had this same issue in a Windows service/console application and it turned out that I had an unhandled exception in the constructor of the MEF part being loaded (due to an environment difference between my development and production environments).
The key part of the error message was:
An exception occurred while trying to create an instance of type '[somenamespace.sometypename]'.
In your case, it is EAccountingControllers.EAccountingController.
This is not so much a MEF error as it is an unhandled exception occurring while trying to create an instance of EAccountingController (i.e. probably in the constructor).
The answer to what the problem is likely lies within EAccountingController and what it does when an instance is being created.
There is a webservice project written in VS2010 few years ago and the problem is all code exactly same (same PC , Tested with vs2010 and 2015 with the same code) but in vs2015 it gives error on debug mode. Options > "Projects & Solutions" settings are all same. I took this error and definition of it;
An unhandled exception of type 'System.StackOverflowException' occurred in System.Runtime.Serialization.dll
System.StackOverflowException was unhandled Message: An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll
Anyone have idea about it , I'm really glad to attention. I could't share code because it's nearly 30.000 lines.
SOLVED
Add this to the appSettings in your web.config:
<add key="vs:EnableBrowserLink" value="false" />
After VS 2013, by default VS automatically enables Browser Link. The StackOverflowException occurs, but doesn't include any details of what happened. You can check this link for more information about the browser link feature in VS 2013: https://blogs.msdn.microsoft.com/webdev/2013/06/28/browser-link-feature-in-visual-studio-preview-2013/
You got this error, what you gonna do ....
Your project stops and not working, but that is usually not about your code.
Of course, that depends how you coding but if you didn’t write any infinite loop than its completely fine.
It’s about Visual Studio 2013, it tries to send long serialized data to browser because of “enable browser link” option.
You can fix this issue by two ways..
Add this in appSettings in your web.config
<add key="vs:EnableBrowserLink" value="false" />
Or
You can disable following option in tool menu
I'm using VS 2008. I have a C# application.
When I try to build/run the project it opens the JUST IN TIME debugger for some reason disabling me from stepping through my code where the exception occurred.
How can I get rid of this JUST IN TIME prompt?
I did go to tools=>options-->debugging and disabled JUST IN TIME and now it is giving me an error message:
an unhandled win32 exception occurred in projectname. just in time debugging this exception failed with the following error...basically i guess it's trying to open just in time
How do I get normal compiler debugging capabilities?
Check out the following MSDN article: Just-In-Time Debugging. It sounds like in your case, you might want to make sure you have registry keys for JIT deleted.
Also, the following seems to be applicable in your case:
An unhandled win32 exception occurred in . Just-In-Time
debugging this exception failed with the following error: The logged
in user did not have access to debug the crashing application.
This message indicates that Just-In-Time debugging failed because you
do not have proper access permissions. For information on the required
permissions, see [Obsolete] Remote Debugging Permissions.