-
Notifications
You must be signed in to change notification settings - Fork 49
Mono Support #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mono Support #15
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ | |
| using System.Security; | ||
| using System.Web; | ||
| using System.Web.Compilation; | ||
| using System.Web.Configuration; | ||
| using System.Web.Hosting; | ||
|
|
||
| namespace WebActivatorEx | ||
|
|
@@ -27,13 +28,32 @@ public static void Run() | |
| { | ||
| if (!_hasInited) | ||
| { | ||
| // In CBM mode, pass true so that only the methods that have RunInDesigner=true get called | ||
| RunPreStartMethods(designerMode: HostingEnvironment.InClientBuildManager); | ||
| bool _isRunningMono = Type.GetType("Mono.Runtime") != null; | ||
|
|
||
| if (_isRunningMono) | ||
| { | ||
| RunPreStartMethods(designerMode: false); | ||
| } | ||
| else | ||
| { | ||
| // In CBM mode, pass true so that only the methods that have RunInDesigner=true get called | ||
| RunPreStartMethods(designerMode: (bool)typeof(HostingEnvironment).GetProperty("InClientBuildManager").GetValue(null, null) == true); | ||
| } | ||
|
|
||
| // Register our module to handle any Post Start methods. But outside of ASP.NET, just run them now | ||
| if (HostingEnvironment.IsHosted) | ||
| { | ||
| Microsoft.Web.Infrastructure.DynamicModuleHelper.DynamicModuleUtility.RegisterModule(typeof(StartMethodCallingModule)); | ||
| Type startMethodType = typeof(StartMethodCallingModule); | ||
|
|
||
| if (_isRunningMono) | ||
| { | ||
| HttpModuleActionCollection modules = (WebConfigurationManager.GetWebApplicationSection("system.web/httpModules") as HttpModulesSection).Modules; | ||
| modules.Add(new HttpModuleAction(startMethodType.FullName, startMethodType.AssemblyQualifiedName)); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't know you could do this. Does this work in .NET as well, or only Mono?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did not check because I assumed it'd be safer to stick with what was there. I peeked inside and it seems that DynamicModuleUtility.RegisterModule() then simply invokes System.Web.HttpApplication.RegisterModule(), another method not implemented in Mono. I'm not sure what the base implementation in HttpApplication is but whatever it is, it currently works in .NET. Best to stick with that.
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, I was just curious. BTW, the reason I'm calling |
||
| } | ||
| else | ||
| { | ||
| Microsoft.Web.Infrastructure.DynamicModuleHelper.DynamicModuleUtility.RegisterModule(startMethodType); | ||
| } | ||
| } | ||
| else | ||
| { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strange, I had a comment here but it's gone. You can avoid reflection here by moving this to a helper method and calling the real thing (assuming Mono jitter works the same as .NET).