StackOverflowException inside SimpleInjector in MVC WebApi project - asp.net-mvc-5

We are building a website with UI and API, both hosted within single ASP.NET MVC project ("usual" MVC + MVC WebApi under one hood). We are using SimpleInjector (the latest version, 2.8 as of now) for dependency injection. We have single composition root class to construct containers for both UI and API parts.
Since recently (noticed a couple of weeks ago) we are receiving connection reset errors (ERR_CONNECTION_RESET) when we try accessing any API method in QA. The same code in UAT works just fine.
Locally, the same code errors out with StackOverflowException if run under IIS, but works fine under IIS Express and under IIS if we run it with debugger attached.
Our current code gives the following stack trace when we attach to iis worker process after the exception occurs:
SimpleInjector.Compiled!DynamicInstanceProducer3.GetInstance(object[] constants)
SimpleInjector.dll!SimpleInjector.CompilationHelpers.CompileInDynamicAssemblyAsClosure<System.__Canon>.AnonymousMethod__1a()
SimpleInjector.dll!SimpleInjector.InstanceProducer.GetInstance()
SimpleInjector.dll!SimpleInjector.Container.GetInstance(System.Type serviceType)
System.Web.Http.dll!System.Web.Http.Dispatcher.DefaultHttpControllerActivator.GetInstanceOrActivator(System.Net.Http.HttpRequestMessage request, System.Type controllerType, out System.Func<System.Web.Http.Controllers.IHttpController> activator)
System.Web.Http.dll!System.Web.Http.Dispatcher.DefaultHttpControllerActivator.Create(System.Net.Http.HttpRequestMessage request, System.Web.Http.Controllers.HttpControllerDescriptor controllerDescriptor, System.Type controllerType)
System.Web.Http.dll!System.Web.Http.Controllers.HttpControllerDescriptor.CreateController(System.Net.Http.HttpRequestMessage request)
System.Web.Http.dll!System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsync()
mscorlib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start<System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsync>(ref System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsync stateMachine)
System.Web.Http.dll!System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsync(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken)
System.Net.Http.dll!System.Net.Http.HttpMessageInvoker.SendAsync(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken)
System.Web.Http.dll!System.Web.Http.Dispatcher.HttpRoutingDispatcher.SendAsync(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken)
System.Web.Http.dll!System.Web.Http.HttpServer.SendAsync()
mscorlib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start<System.Web.Http.HttpServer.SendAsync>(ref System.Web.Http.HttpServer.SendAsync stateMachine)
System.Web.Http.dll!System.Web.Http.HttpServer.SendAsync(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken)
System.Net.Http.dll!System.Net.Http.HttpMessageInvoker.SendAsync(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken)
System.Web.Http.WebHost.dll!System.Web.Http.WebHost.HttpControllerHandler.ProcessRequestAsyncCore()
mscorlib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start<System.Web.Http.WebHost.HttpControllerHandler.ProcessRequestAsyncCore>(ref System.Web.Http.WebHost.HttpControllerHandler.ProcessRequestAsyncCore stateMachine)
System.Web.Http.WebHost.dll!System.Web.Http.WebHost.HttpControllerHandler.ProcessRequestAsyncCore(System.Web.HttpContextBase contextBase)
System.Web.dll!System.Web.TaskAsyncHelper.BeginTask(System.Func<System.Threading.Tasks.Task> taskFunc, System.AsyncCallback callback, object state)
System.Web.dll!System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
System.Web.dll!System.Web.HttpApplication.ExecuteStep(System.Web.HttpApplication.IExecutionStep step, ref bool completedSynchronously)
System.Web.dll!System.Web.HttpApplication.PipelineStepManager.ResumeSteps(System.Exception error)
System.Web.dll!System.Web.HttpApplication.BeginProcessRequestNotification(System.Web.HttpContext context, System.AsyncCallback cb)
System.Web.dll!System.Web.HttpRuntime.ProcessRequestNotificationPrivate(System.Web.Hosting.IIS7WorkerRequest wr, System.Web.HttpContext context)
System.Web.dll!System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(System.IntPtr rootedObjectsPointer, System.IntPtr nativeRequestContext, System.IntPtr moduleData, int flags)
System.Web.dll!System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(System.IntPtr rootedObjectsPointer, System.IntPtr nativeRequestContext, System.IntPtr moduleData, int flags)
[Native to Managed Transition]
[Managed to Native Transition]
System.Web.dll!System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(System.IntPtr rootedObjectsPointer, System.IntPtr nativeRequestContext, System.IntPtr moduleData, int flags)
System.Web.dll!System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(System.IntPtr rootedObjectsPointer, System.IntPtr nativeRequestContext, System.IntPtr moduleData, int flags)
[AppDomain Transition]
I.e., looks like nothing bad happens inside our code.
When we take some old code (one that is currently in production, for instance, and is working fine), we also have StackOverflowException, but in static constructor of our EntityFramework DB context (code first) on line
Database.SetInitializer(new MigrateDatabaseToLatestVersion<MyContextType, Configuration>());
Funny thing is that it no longer suggests to attach to the process with old code, so I cannot provide the stack trace - I will update the question, if I manage to grab it.
Note that usual MVC works normally still (while using the same Composition Root class with slight natural differences for WebApi and MVC creation modes).
I can provide further code snippets, if it is reasonable, but the project is quite big, so I am not sure small snippets will help here.
Any ideas what this might be? Can it be because of the number of dependencies?
UPDATE: The issue does not appear after in one of the services which depends on four other services I removed the dependencies from the constructor, injected the container there, and resolved the dependencies manually in the constructor. I.e., it was:
public MyDependentService(IDependency1 dependency1, IDependency2 dependency2, IDependency3 dependency3, IDependency4 dependency4)
{
this.dependency1 = dependency1;
this.dependency2 = dependency2;
this.dependency3 = dependency3;
this.dependency4 = dependency4;
}
and it became
public MyDependentService(Container container)
{
this.dependency1 = container.GetInstance<IDependency1>();
this.dependency2 = container.GetInstance<IDependency2>();
this.dependency3 = container.GetInstance<IDependency3>();
this.dependency4 = container.GetInstance<IDependency4>();
}
So now everything works, but of course this is not the right way to deal with dependencies. This is actually not IoC anymore. What's going on?

Related

WindowsIdentity.Impersonate throws ''Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))' after April 2018 (1803) update

Our installer app uses the following code to verify service account permissions:
try
{
using (svcIdentity.Impersonate())
{
using (SqlConnection conn = new SqlConnection(builder.ConnectionString)) // <<<
{
conn.Open();
...
Omitted for brevity:
The svcIdentity WindowsIdentity is obtained by using the Win32 LSA LogonUser function in advapi32.dll and LOGON32_LOGON_SERVICE.
builder is a SqlConnectionStringBuilder that builds a connectionstring to a local SQL Server database.
Targeting .Net Framework 4.6.
The app runs elevated (requestedExecutionLevel level='requireAdministrator' in the app.manifest).
This code ran flawless until Windows 10 version 1803 (April 2018 update). Since then, the SqlConnection constructor (marked <<<) throws an exception:
The type initializer for 'System.Data.SqlClient.SqlConnection' threw an exception.
The inner exception provides more insight:
Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))
Stack trace:
at System.Security.Policy.PEFileEvidenceFactory.GetLocationEvidence(SafePEFileHandle peFile, SecurityZone& zone, StringHandleOnStack retUrl)
at System.Security.Policy.PEFileEvidenceFactory.GenerateLocationEvidence()
at System.Security.Policy.PEFileEvidenceFactory.GenerateEvidence(Type evidenceType)
at System.Security.Policy.AssemblyEvidenceFactory.GenerateEvidence(Type evidenceType)
at System.Security.Policy.Evidence.GetHostEvidenceNoLock(Type type)
at System.Security.Policy.Evidence.GetHostEvidence(Type type, Boolean markDelayEvaluatedEvidenceUsed)
at System.Security.Policy.AppDomainEvidenceFactory.GenerateEvidence(Type evidenceType)
at System.Security.Policy.Evidence.GetHostEvidenceNoLock(Type type)
at System.Security.Policy.Evidence.RawEvidenceEnumerator.MoveNext()
at System.Security.Policy.Evidence.EvidenceEnumerator.MoveNext()
at System.Configuration.ClientConfigPaths.GetEvidenceInfo(AppDomain appDomain, String exePath, String& typeName)
at System.Configuration.ClientConfigPaths.GetTypeAndHashSuffix(AppDomain appDomain, String exePath)
at System.Configuration.ClientConfigPaths..ctor(String exePath, Boolean includeUserConfig)
at System.Configuration.ClientConfigPaths.GetPaths(String exePath, Boolean includeUserConfig)
at System.Configuration.ClientConfigurationHost.RequireCompleteInit(IInternalConfigRecord record)
at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
at System.Configuration.ConfigurationManager.GetSection(String sectionName)
at System.Data.SqlClient.SqlConnection..cctor()
The stack trace indicates the SqlConnection constructor fails to open a configuration section. Our app.config does not have a connectionstrings section and machine.config and security.config on the tested computers haven't changed since 2017.
The code works when:
Commenting out using (svcIdentity.Impersonate),
or
when setting a breakpoint on the line immediately above the SqlConnection constructor ({) and stepping through the code (???),
or
when adding our application to the registry key mentioned at the end of KB945701
That KB article about a fix for Internet Explorer 9 seems unrelated, except that GetLocationEvidence on the first line of the stack trace seems to take a SecurityZone into account, which applications listed in the corresponding registry key seem to ignore.
Now my question:
Can anybody help me understand what exactly is going wrong, and if there is a better way to fix this than with an obscure registry key? It seems a 'coincidence' that this registry change works and I'm afraid our code might break again if we don't understand exactly why it fails.
Thx.

WP Silverlight BackgroundTask Communication with Azure

Hello I have a silverlight project for WP8.1 that is a game. I use a backgroundTask to alert the user about when he last played, if he is too slow to comply I would like to make a call to the server from the bagroundTask to resign from the games.
The backgroundTask is made using stackoverflow and this blog, just basic implementations of the backgroundTask.
I then install the NuGet Package Microsoft.Azure.Mobile.Client and everything is fine, I then do a compile, everything succeeds.
The app installs and splashscreen appears, then I get an error in the main project at the initialization of MobileServiceClient in App.xaml.cs
public MobileServiceClient MobileService = new MobileServiceClient(
"https://xxxxx.azurewebsites.net"
);
The exception in the above line states:
An exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.ni.dll but was not handled in user code
Additional information: Could not load file or assembly 'System.Runtime.InteropServices, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
The only change was the install of the NuGet package in the backgroundTask project. The stack trace output for the exception above.
at System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type)
at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean isDecoratedTargetSecurityTransparent)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType)
at System.Reflection.RuntimeAssembly.GetCustomAttributes(Type attributeType, Boolean inherit)
at System.Attribute.GetCustomAttributes(Assembly element, Type attributeType, Boolean inherit)
at Microsoft.WindowsAzure.MobileServices.PlatformInformationExtensions.GetVersionFromAssemblyFileVersion(IPlatformInformation platformInformation)
at Microsoft.WindowsAzure.MobileServices.PlatformInformation.get_Version()
at Microsoft.WindowsAzure.MobileServices.MobileServiceHttpClient.GetUserAgentHeader()
at Microsoft.WindowsAzure.MobileServices.MobileServiceHttpClient..ctor(IEnumerable`1 handlers, Uri applicationUri, String installationId)
at Microsoft.WindowsAzure.MobileServices.MobileServiceClient..ctor(Uri mobileAppUri, HttpMessageHandler[] handlers)
at Microsoft.WindowsAzure.MobileServices.MobileServiceClient..ctor(String mobileAppUri, HttpMessageHandler[] handlers)
at BC_Menu.App..ctor()
I have not been able to solve this issue.
Extra
I am able to do normal http calls to the web by using the proposed code, replicated here:
BackgroundTaskDeferral _deferral;
public async void Run(IBackgroundTaskInstance taskInstance)
{
_deferral = taskInstance.GetDeferral();
// your async code
_deferral.Complete();
}
Update based on Adrian Halls Answer
The code works, my front application can communicate with the server and everything. The backgroundTask, can extract information from the device everything is fine, everything compiles and runs.
I then add the NuGet package to the backgroundTask and suddenly the above error appears, when I deploy this solution to the client.
I am running VS2015, Win10, and have v2.0.1 installed of Microsoft.Azure.Mobile.Client. I have seen some odd behaviours with silverlight projects on win10 before.
The error indicates a problem with your .NET setup - the error is in mscorlib (the basic library for .NET). Try to add a reference to the specific library that you need. Also, ensure that you have installed v2.0.1 (or later) or the Microsoft.Azure.Mobile.Client library.

Windows azure redis cache migration issue

We are hosting our site on windows azure where site is running on multiple instances.Due to multiple instances we were using shared cache for storing session values. As Microsoft is going to stop shared cache and recommended to use redis cache to store session. I modified project to use redis cache and it worked for most of the pages. My problem is that, we have a very important page "search page" (we are using lucene.net for search functionality) in our site which stores a lot of data in session and this page is not working. After hitting search button, it shows connecting status in address bar for a long time and goes to oops page of website. We are recording error messages in DB so after looking at there we found following error message.
System.Runtime.Serialization.SerializationException: Type 'myWeb.clsSearchCriteria+ContentCriteria' in Assembly 'HelmBriscoeWeb, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable.
at System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(RuntimeType type)
at System.Runtime.Serialization.FormatterServices.GetSerializableMembers(Type type, StreamingContext context)
at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemberInfo()
at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter, SerializationBinder binder)
at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter, SerializationBinder binder)
at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck)
at Microsoft.Web.Redis.RedisUtility.GetBytesFromObject(Object data)
at Microsoft.Web.Redis.RedisUtility.AppendUpdatedOrNewItemsInList(ChangeTrackingSessionStateItemCollection sessionItems, List`1 list)
at Microsoft.Web.Redis.RedisConnectionWrapper.TryUpdateIfLockIdMatchPrepare(Object lockId, ISessionStateItemCollection data, Int32 sessionTimeout, String[]& keyArgs, Object[]& valueArgs)
at Microsoft.Web.Redis.RedisConnectionWrapper.TryUpdateIfLockIdMatch(Object lockId, ISessionStateItemCollection data, Int32 sessionTimeout)
at Microsoft.Web.Redis.RedisSessionStateProvider.SetAndReleaseItemExclusive(HttpContext context, String id, SessionStateStoreData item, Object lockId, Boolean newItem)
at System.Web.SessionState.SessionStateModule.OnReleaseState(Object source, EventArgs eventArgs)
at System.Web.SessionState.SessionStateModule.OnEndRequest(Object source, EventArgs eventArgs)
at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
I am not sure if this is related to my problem but seems if this is fixed, page will work properly. Has anyone any idea why this error occurred and how can I fix it?
Thanks
I solved this problem myself by adding serialization attribute to class like below.
<Serializable()> _
Public Class clsSearchCriteria
Thanks

Why is IIS Management crashing when I select a user in "Configure Web Deploy Publishing Dialog"?

I am running IIS 8 and Windows Server 2012. I have installed Web Deploy and when I try to select a user to give publishing permissions to, I immediately crash without any error dialogs. When I go into the Event Viewer, I am able to see the following error:
IISMANAGER_CRASH
IIS Manager terminated unexpectedly.
Exception:System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.OverflowException: Arithmetic operation resulted in an overflow.
at Microsoft.Web.Deployment.UI.ObjectPickerWrapper.ShowObjectPicker(IntPtr parentHandle, Boolean usersOnly)
at Microsoft.Web.Deployment.UI.SelectExistingUserForm.OnWindowsBrowseButtonClick(Object sender, EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
at Microsoft.Web.Management.Host.UserInterface.ManagementUIService.ShowDialogInternal(Form form, IWin32Window parent)
at Microsoft.Web.Management.Host.UserInterface.ManagementUIService.Microsoft.Web.Management.Client.Win32.IManagementUIService.ShowDialog(DialogForm form)
at Microsoft.Web.Deployment.UI.SetupPublishingDialog.SelectUserButton_Click(Object sender, EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
at Microsoft.Web.Management.Host.UserInterface.ManagementUIService.ShowDialogInternal(Form form, IWin32Window parent)
at Microsoft.Web.Management.Host.UserInterface.ManagementUIService.Microsoft.Web.Management.Client.Win32.IManagementUIService.ShowDialog(DialogForm form)
at Microsoft.Web.Deployment.UI.PackagingModule.SetupPublishing(HierarchyInfo info)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at System.Windows.Forms.ToolStripItemClickedEventHandler.Invoke(Object sender, ToolStripItemClickedEventArgs e)
at System.Windows.Forms.ToolStripDropDown.OnItemClicked(ToolStripItemClickedEventArgs e)
at System.Windows.Forms.ToolStrip.HandleItemClick(ToolStripItem dismissingItem)
at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
at System.Windows.Forms.ToolStripDropDown.OnMouseUp(MouseEventArgs mea)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ToolStrip.WndProc(Message& m)
at System.Windows.Forms.ToolStripDropDown.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at Microsoft.Web.Management.Host.Shell.ShellApplication.Execute(Boolean localDevelopmentMode, Boolean resetPreferences, Boolean resetPreferencesNoLaunch)
Process:InetMgr
I thought Microsoft had a complete process in place eliminating such easy to find bugs. What gives?
I encountered this exact issue when attempting to configure web deploy publishing; IIS Manager would crash instantly when clicking the Select... button when attempting to select a user to give publishing permissions.
To work around it, I manually entered the username into the text field, in the format COMPUTERNAME\Username.
For me
adding required User with the "IIS Manager Permissions" GUI for the
site
simply choose them from the drop down (instead of choosing the Ellipse to search for /
select a user)
Avoided the issue entirely and all seems to have worked fine
This is a bug that hasn't been fixed and apparently is of low priority. The only fix for me that works is to use an account with administrator privileges and ignore the dialog. A standard user account may work, but you have to find out what permissions needs to be applied. Frankly, Microsoft's security scheme is too complex to setup, which is why many sysadmins just turn it off or give full privileges to get around authentication denied problems. Web Deploy is a big rats nest of inter-operating components all of which have to have their permissions carefully tweaked. If someone has the time, which I don't have much of, download process explorer and setup a filter to watch for access denial errors and apply the appropriate permissions to the process or user.
Microsoft software has always been bad, but it's been getting progressively worse. If it were a company run by two guys operating out of their basement, this and other bugs would be perfectly understandable. But this is a multi-billion dollar corporation and it can't get basic software that's critical for its own survival right.
Microsoft is fighting too many battles and it's losing all of them. It's losing in the mobile market, the web server market and it will eventually lose the enterprise and the desktop market, since applications are moving away from the desktop. If there's no way of simply deploying web applications, it can just forget about the cloud market.
If you're a Microsoft only developer, you should start seriously looking at a career change. Don't base your livelihood on a sinking ship.

Web API throws exception after installing AttributeRouting

I developed a simple VB .NET Web API project using .NET 4.5
This project was working perfectly fine, but I decided to install the AttributeRouting nuget package. After installing this package every function seems to raise the following exception:
The constraint entry 'inboundHttpMethod' on the route with route
template 'Company' must have a string value or be of a type which
implements 'IHttpRouteConstraint'.
In this message 'Company' is the route name to a simple GET method that simple returns one object. Every route results in this error message. The stacktrace is:
[InvalidOperationException: The constraint entry 'inboundHttpMethod'
on the route with route template 'Company/{Id}' must have a string
value or be of a type which implements 'IHttpRouteConstraint'.]
System.Web.Http.Routing.HttpRoute.ProcessConstraint(HttpRequestMessage
request, Object constraint, String parameterName,
HttpRouteValueDictionary values, HttpRouteDirection routeDirection)
+346 System.Web.Http.Routing.HttpRoute.ProcessConstraints(HttpRequestMessage
request, HttpRouteValueDictionary values, HttpRouteDirection
routeDirection) +201
System.Web.Http.Routing.HttpRoute.GetRouteData(String virtualPathRoot,
HttpRequestMessage request) +430
AttributeRouting.Web.Http.Framework.HttpAttributeRoute.GetRouteData(String
virtualPathRoot, HttpRequestMessage request) +250
System.Web.Http.WebHost.Routing.HttpWebRoute.GetRouteData(HttpContextBase
httpContext) +191
System.Web.Routing.RouteCollection.GetRouteData(HttpContextBase
httpContext) +233
System.Web.Routing.UrlRoutingModule.PostResolveRequestCache(HttpContextBase
context) +60
System.Web.Routing.UrlRoutingModule.OnApplicationPostResolveRequestCache(Object
sender, EventArgs e) +82
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
+136 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69
I found the following thread which describes my problem: https://github.com/mccalltd/AttributeRouting/issues/191
Unfortunately, this fix does not seem to help: https://github.com/mccalltd/AttributeRouting/issues/191#issuecomment-13814025
Any ideas on how to fix this?
In your case, I definitely feel like this issue is related with in memory hosting and do have a solution in the link that you mention above.
After updating to MVC 5 I came across this issue and following the workout in this link which ultimately helped me out.
Here is how I did it.
In global.ascx page, I have the following:
AttributeRoutingHttpConfig.RegisterRoutes(GlobalConfiguration.Configuration.Routes);
In AttributeRoutingHttpConfig class, I replaced the code
routes.MapHttpAttributeRoutes();
with
routes.MapHttpAttributeRoutes(cfg =>
{
cfg.InMemory = true;
cfg.AutoGenerateRouteNames = true;
cfg.AddRoutesFromAssemblyOf<Your_API_Controller>();
});
You can overwrite Your_API_Controller with any of your ApiController class. (Yes, don't know why but any api controller you want works ;) )
Hope this helps,

Resources