Dynamically change parts (DLLs) when using a DirectoryCatalog - dll

Using MEF, after adding new plugins (DLLs containing parts) to plugins folder, calling a refresh on DirectoryCatalog would update container (if recomposition is allowed) and new added plugins become accessible.
My question is what if we need to replace a DLL (part) dynamically ?
I tried this but all loaded parts are locked (write-protected) by MEF and cannot be replaced.

It's .NET that has a lock on your DLLs. You can't unload assemblies from an AppDomain, and while they are loaded there will normally be a lock. You can enable shadow copying for the AppDomain to let you delete the DLLs. They would still be loaded but the DirectoryCatalog would see they were gone when you called Refresh and remove them from the catalog.

Related

UWP Using Pages from different Project

Is it possible to have all pages in a different project from where the app.xaml/cs is in?
I tested this by creating a new "Class Library (Universal Windows)" or "Windows Runtime Component" project, then I created the new pages in those projects.
After I add this project as a reference to the main UWP app and call the page(s) in the "rootFrame.Navigate(typeof(MainShellView), e.Arguments)" I get the exception
system.accessviolationexception attempted to read or write protected memory
Is it possible to have the pages, controls in different projects than the UWP main project and use them as references?
You will need to keep an empty/dummy MainPage.xaml page in the main project as there is a hard-coded reference to it in the project system. With that in place you can load all your pages (incl. the initial start page) from other projects that you are referencing in the solution.
I will log a bug on the hard-coded dependency on the existence of "MainPage.xaml". Thanks for reporting!

Javafx dynamically fxml load at Runtime

I have an application that cover a wide number of use cases each with completely independent workflows but workflows are pretty static after installation.
I have therefore created an HBox placeholder that will load the workflow for an installation.
Is there a way to dynamically load a section of the fxml from a database or a separate file archive? This fpml will have to have its own set of images and resources needed to achieve the workflows functionality.
TBH, I don't know where to start on this one.
Regards
I do not quite understand your problem. You can modify the scene graph at any time you want. So, of course it is possible to load a part of the scene graph from an FXML file at any time and hook it up to the already existing part. In your controller you have access to your HBox placeholder and when you have loaded the second part of the scene graph you can just add it via hbox.getChildren().add(newpart), were newpart is the root node of your second scene graph part. Of course you have to make sure that the layout works correctly for your constellation.
Your question seems nonsense because the FXML is always loaded dynamically. My guess is you are confused because most of the examples use FXML in the same bundle as the classes and so are loaded trough the getResource method. But the FXML loader takes any kind of InputStream, so you can just open a database blob or a file as an InputStream and give that InputStream as an argument to the loader. Be sure to catch the runtime exceptions though :)
Hope this helps.

Checked use Core Data in new project

When I created my Xcode project i checked the checkbox "use Core Data" because I thought I was going to use that. Now however it turns out I never used Core Data and would like to disable it. My project is way to big to just simply create a new project and leave the checkbox unchecked.
Does anyone know what methodes and files I need to delete in order to have a project without Core Data? I think some project settings need to be changed as well.
Just create a new empty project and find out. Must of the methods will be in your App delegate. You also have to remove the Data model (.xcdatamodel) file from your project

After adding new class file to App_Code, build action is Content instead of Compile

In VS2008, I am adding new classes to a web project.
When I right-click on App-Code -> Add -> New Item -> Class ...
The build action for the newly created item is set to content instead of compile. This seems like it would be a problem with the template. I've found several others through google who have run into this issue, but nobody seemed to have found a more permanent solution, other than "change it from content to compile after creation."
My question: Does anyone know of a fix for this, official or otherwise?
App_Code is a special folder meant for folder based projects.
This is just a hunch, but it might be that you have a project file based project, instead of a simple folder based one.

Are the contents of a fragment visible outside the host plugin?

I have never worked with plug-in fragments before. I thought that by creating a new class within a fragment and exporting the package that contains it in the fragment's manifest, I'd be able to access that class from another plug-in that already has a dependency on the host plug-in. However, I cannot seem to make this work. Are the contents of a fragment ever visible to any plug-in besides the host plug-in? If so, is there something special I have to do to allow this?
The problem is not, that the contents of the fragment aren't visible to another plugin: They are - just try loading e.g. a properties file from the classpath, it still works if that properties file is provided by the fragment.
But what you don't have, is compile-time information about the fragment's contents. That's the principle of a fragment: You can't have a dependency on it. And you don't know, if somebody has fragments installed or not.
It's also not only a problem that just "any plug-in besides the host plug-in" has. It's a problem, that even the host-plugin itself has. It doesn't know about the fragment's existence at compile-time.
You also can't reliably use a fragment to override parts of the host plug-in's classes: FAQ Can fragments be used to patch a plug-in? , if that's what you want to do. The page also describes, how it can be done.
Hope this helps.