How to load XcoAppSpaces.Discovery.dll in ASP.NET Web App

Feb 2, 2011 at 4:14 PM

I have an application that can either be loaded within the context of a Windows Service or an ASP.NET web application. My application utilizes the Discovery service feature of the XCoordination Application Space. Everything works fine when loaded under the Windows Service context but I continuously receive the following error when trying to load within the ASP.NET web application:

"XcoAppSpaces.Discovery.XcoDiscoveryException: Discovery service could not be found.
   at XcoAppSpaces.Discovery.XcoAppSpaceExtensions.DiscoverWorker[T](IXcoAppSpace space, String workerName)"

It seems as though the loose coupling between the XcoAppSpaces.dll and XcoAppSpaces.Discovery.dll is causing an issue here. Any suggestions? Thanks!

Feb 3, 2011 at 3:29 PM

Update - I modified the latest build script to merge the XcoAppSpaces.dll and the XcoAppSpaces.Discovery.dll into a single assembly named XcoAppSpacesMerged.dll. Now I am able to successfully use the Discovery functionality within a web app. This seems to fall in line with my assumption that the loose coupling through the Activator.CreateInstance() call is the problem (i.e. the WebApp is not loading the XcoAppSpaces.Discovery.dll since it is not directly referenced). Does anyone know of a better way to do this rather than actually merging these two assemblies?

Coordinator
Feb 4, 2011 at 8:07 AM

Hi husterk,

We haven't tried yet to use the XcoAppSpaces.Discovery.dll in an ASP.NET project. But from what you say it seems likely that the source of the problem is that the web application is not loading the DLL when it is not directly referenced in the code. Other than merging the DLLs, a solution would probably be that you are forcing the loading of the discovery DLL by directly referencing one of its classes. For example you could do something like this before instantiating the appspace:

var forceDiscoServiceDllLoad = typeof(XcoDiscoveryService);

Or you could use the fluent interface for handing over the discovery service at appspace startup:

XcoAppSpace space = XcoAppSpace.ConfigureWithConfigString("...").UsingService(new XcoDiscoveryService("server:8001"))

We will see if we can find a way to load such loosely coupled assemblies dynamically in a web app.