ApplicationServer's dataservices loading and db connection retrival

Hello,
in our actual framework bootstrapping sequence (in a specific runlevel) we dynamically load some dll (some of those contains also dataservices and services) and after that we want to run the application server.
The problem is that in those DLLs we would like to use DA’s connection layer through the “Engine.ConnectionManager”, but we’re facing some problems:

public class ApplicationServerExt : ApplicationServer
{
	...
	protected override void LoadApplicationServerConfiguration()
	{
                 //1)
		base.LoadApplicationServerConfiguration();
                 //2)
	}   
	...
}

If we set the “dll loading” phase in 1), a configuration exception occurs because “the configuration has not been yet loaded”, instead if we set it in 2) we have the configuration but the services inside DLLs are not loaded anymore.

What can we do?

Thank you

Hello

.NET runtime can load assemblies on the fly for GUI apps, console apps and Web services. On of the consequences of that strategy is that is you perform services initialization in a method (i.e. not directly in the LoadApplicationServerConfiguration method’s code but in some method called by LoadApplicationServerConfiguration) then .NET won’t load types and assemblies containing them until these methods are executed.

This means that code that performs services initialization in base.LoadApplicationServerConfiguration() won’t see these assemblies and won’t be able to properly initialize internal SDK infrastructure properly.

Possible solutions:

a)

If you have service dll assemblies as references than you just need to use proper ApplicationServer’s constructor:

public ApplicationServer(String applicationName, params Type[] serviceTypes)

Note the last parameter. If you’ll list there your service types then .NET will load service dlls immediately on application startup. Then you’ll be able to perform required initialization at the place you marked as 2)

b)

This approach is more appropriate when assemblies are being loaded dynamically or you don’t want to list service types in the Program.cs:

Use the place 1) to perform initialization but add this code to the initialization method:

RemObjects.DataAbstract.Server.Engine.Load();

It will initialize the Data Abstract connection manager.

Regards

1 Like

Awesome, thanks