I would agree that moving the app services that are to have shared access to a separate library it the best practice approach, but for a plugin based application, this provides some difficulty for me. I am wanting the plugin system to be able to access all app code in the future without needed the app code to be modified or moved to a library. This way you develop the main app as normal, and the plugins can access all the code when they are created / needed.
I was planning on using unique interfaces for all app services like ASPNetzero uses out of the box, and dependency injection based on the interface to load the class at runtime. Using this i was able to create two plugins that compile and were tested. They would load, but would fail loading dependencies in the constructor if the dependent object wan not loaded yet.
Normally this would be fixed with the depends on attribute of the plugin. But those target the dependent class and not interface, and will not work without adding a actual reference to the dependent library for the class.
I was able to get it working with using the event bus trigger in AppServicesModule's post-init method to tell the host when it is loaded. During startup I moved the plugin load code to be inside of a event bus listener that when triggered after the AppServicesModule is loaded.
This way all parts of the base system are loaded before the plugin system loads. This is still in development, but seems to be working perfectly, and doesn't feel like there is any lag in the startup either.
Hi @mittera,
If you share the logs from the application, we may find the error. The application service methods in the plugin must work successfully.
This is a modular monolith example. However, the structure is similar to the plugin system. https://github.com/aspnetzero/aspnet-zero-samples/tree/master/ModularMonolithMvcDemo
Also the documentation https://aspnetboilerplate.com/Pages/Documents/Plugin
The second link is the documentation i used to build this and and using the repos it works.
Tonight i took a short break while debugging this and when i came back it worked via the app service.
The issue was timing, if i fire the the app service method before the app service is initialized the method does a return on the function. No error is logged. I would expect service not found or something...
So I guess the root question is when loading a plugin that calls an app service during the plugins post Init, how can i ensure the app service is loaded before attempting to call the service method? The depends on seems like the obvious choice, but then do i need my plugin to reference the application dll so it can depend on the module? i don't want to do this as I am referencing all the services via IServiceNameAppSerivce and have no other reliance on it. Currently i am only depending on "BaseAppCoreModule" and that is why the repos work... Can i set the dependency on an interface instead of a module? Thanks in advance for any help you can provide.
Do you have a example of an aspnetzero plugin that can reference Application.Shared dll for interfaces and load the service di dependency injection for use in the plugin?
I have been working on this, and it compiles, and i can step thru the plugin logic. In the constructor i use dependency injection to populate the private readonly service property.
In my plugin method i can display the service property and it successfully populated, but if I step into a method on the service property, the application returns from my method without calling the app service method or any code after it. It appears if something is hiding an exception as no error's are produced. I have tried this with my own appservices and the out of the box tenantAppService and same results. If i use the repos directly without going thru the app service it works as well. But i would rather use the app service to ensure no code duplication from having some code targeting repos and some targeting services....
Any ideas you have on what the issue could be would be helpful, but an example plugin project would be amazing!
The application is Using AspNet Core Angular 13.2
Below is a simple example of the issue.
In review of the blog post: https://aspnetzero.com/blog/modular-monolith-with-asp.net-zero
Is there an angular version of this? Or can one be created?
I have been attempting this for some time and have not been able to settle on the best approach.
Thanks for any help with this.
I am using 3.3.0
I have attached the entity json files to this link.
I notice the experience when I build Workflow, Workflow Symbol, ProductionOutput, WorkflowProperty, WorkflowSymbolProperty
Then try to rebuild the Workflow one again if you can even get this far before it has the issue.
Not 100% consistent, but it is persistently present.
In power tools templates, there are variables called "{{NP_Foreign_Entity_Name_Here}}" and "{{nP_Foreign_Entity_Name_Here}}".
Is there a plural version of these?
if so what are the variable names for them?
If not, can it be added?
These would be a big help to streamlining my development process.
In the application I am working on I have entity "A", "B", and "C".
"A" is a menu item with "B" as a master detail. "B is also on the menu with "C" as a master detail
If I regenerate in this order C, B, A it all works.
Then I can regenerate "A" without issue multiple times.
Then if I regenerate "B", it still works.
But then If I try to regenerate "A" again it will fail, with the JSON issue listed above.
So not sure it it is the three tired relationship, or just that it was built as both a master and a detail...
But after fixing the JSON I can regenerate "A" again...
Hope this additional information helps.
I can provide them but it requires a couple entity json files to make it happen as it only happens with Master Detail pages.
How do i go about getting you these files? Do I just a attach them here, or is there a better method?
The problem seems to happen randomly, or at least I haven't figured out the trigger yet.
But it usually happens when regenerating an entity that has at least one master detail property.
The build for the primary entity builds then it automatically tries to rebuild the foreign object.
This logs that it is starting in the console, but then just sits there, I have waited 30 minutes, and nothing.
So I cancel the generation, and rerun it, but now the primary entity will not even start...
In review of the json entity files, the primary entity and the foreign entity files have the same timestamp.
This is also the same time of the first failed execution. So both files were updated during the execution.
Nothing looks different in the primary entity file, but the foreign entity file is different with the navigation property looking like the image I sent in creating this ticket.
So I update the navigation property to move the "IsGeneratedbyMasterPage" to where it should be and save the file.
I then can then regenerate the primary entity again, and the foreign entity auto generates as well.
The problem is, Power Tools is reading in valid json using it and then replacing it with invalid json.
The other thing to note, is that once the invalid file is fixed, by simply moving the "IsGeneratedbyMasterPage" property, the fixed file is i identical to the original input file. So Power Tools over wrote it but was not intending to even make any changes..
This makes me wonder is there a way to ensure the entity json files are not auto updated during generation process, especially if the content is not changing.........
When adding a new master detail property to an existing entity, the process fails to generate code.
From looking into the issue it is related to the entity.json data being saved at the beginning of the file generation.
It appears there is a string concatenation issue related to the IsGeneratedByMasterpage property.