-
Notifications
You must be signed in to change notification settings - Fork 9
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
FAQ and .asmx support #24
Comments
We received this exception when running an
We also switched to using constructor chaining and manually injecting the services to get this going. |
@nathanrobb Can you share your project or a minimal reproduction? This is something I'd like to fix but I can't reproduce it. I believe it's doable by fiddling with the |
A minimal reproduction can be found at https://github.com/nathanrobb/AspNetDependencyInjectionWebServiceExample Adding this project nathanrobb/AspNetDependencyInjectionWebServiceExample@e33a532 This repo has a working And a currently working WebService with a default constructor workaround at: Removing the default constructor from the Hope this helps. Thanks. |
This most likely is not an issue with the AspNetDependencyInjection library, but with ASP.NET itself. Reading another article mentioning how to integrate Unity with WebForms dependency injection, near the end of the article it mentions where dependency injection can be used. In this list, Internally, this works by ASP.NET calling the internal method of either |
It looks like internal virtual void CreateServerInstance() {
target = Activator.CreateInstance(ServerType.Type);
WebService service = target as WebService;
if (service != null)
service.SetContext(context);
} |
Thanks to everyone that contributed to the quest! I don't think there will ever be a more elegant way than constructor chaining, the reason I opened this issue was just to highlight the need to update the paragraph at https://github.com/Jehoel/AspNetDependencyInjection/blob/master/GETTING_STARTED.md#can-i-use-constructor-dependency-injection-with-asmx-files , where it says it's untested but should work. Unfortunately, it does not (but this library is awesome anyway!). |
I've got an implementation of this almost done and working. How it works is you'll need to add a Gimmie a few more days to polish it off. My prototype implementation does look like it will be able to fully support async and non-async, and |
My proof-of-concept is almost ready for a beta release for this (for support for ASMX files). One last problem is the The method is I've resorted to trying out actual machine-code modification and replacement to replace the contents of |
I decided to try using HarmonyLib and that seems to work - but I don't like the idea of adding it as a dependency to the main package, so I'll put ASMX support in a separate package. |
The FAQs mention that asmx support should work - I'd be happy to discover I'm wrong, but from my tests on this regard, it seems that they do not.
A valid workaround is mentioned at https://www.milestonetg.com/blog/development/2018/02/17/adding-new-microsoft-extensions-to-legacy-wcf-and-asmx-web-services.html , i.e. use constructor chaining with the service locator:
The text was updated successfully, but these errors were encountered: