Juce hosting a juce based DLL

i want to create a simple plugin interface for my app
in short a create a dll that exports a entry and exit symbols
they look like this

extern "C" __declspec (dllexport) Component* dynamicComponentEntry(void)
{
	initialiseJuce_GUI();
	return (contentComponent = new DynamicComponent());
}

extern "C" __declspec (dllexport) void dynamicComponentExit(void)
{
	deleteAndZero (contentComponent);
	shutdownJuce_GUI();
}

they create a new JUCE component and delete it when the host asks.
in the host i do

typedef Component* (*dynamicComponentEntry)(void);
typedef void (*dynamicComponentExit)(void);

dllHandle	= PlatformUtilities::loadDynamicLibrary (T("DynamicComponent\\DynamicComponent.dll"));

entryHandle	= dynamicComponentEntry)PlatformUtilities::getProcedureEntryPoint (dllHandle, T("dynamicComponentEntry"));		

exitHandle  = (dynamicComponentExit)PlatformUtilities::getProcedureEntryPoint (dllHandle, T("dynamicComponentExit"));


Component *component = (entryHandle)();

at this point i can call component->getName() for example and it works
but when in the host i try to do:

// this works
Logger::writeToLog (T("Plugin::ctor loaded component name: ") + component->getName());

// this does not
DialogWindow::showModalDialog (T("plugin"), component, 0, Colours::white, true, false, false);

this fails on

    // not possible to check on an already-deleted object..
    jassert (componentToWatch_->isValidComponent());

what am i doing wrong here ? it looks like the component is not valid, getName() works but i can’t display this component.

is there something i should know about?

If you’ve got dlls that run in different memory spaces, then the different dlls will probably have separate messagemanager objects - so when it checks whether a comp is valid (by asking the messagemanager is the comp is registered), then it’s probably asking the wrong instance. There are all sorts of problems like this when you start using dlls…

so is there any simple way to have Dynamic components (plugins), cause i can’t think of any other than DLLs?

It’s sure it’s possible with a dll, I guess you’d just need to be careful about where the comps get constructed. I’ve never actually tried it though, so can’t predict if there are any hidden pitfalls…