Skip to content

Instantly share code, notes, and snippets.

@hellboy81
Created December 11, 2012 10:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hellboy81/4257567 to your computer and use it in GitHub Desktop.
Save hellboy81/4257567 to your computer and use it in GitHub Desktop.
Try to load module and access service
namespace DeviceControlContacts
{
public interface IWLANAdapter
{
bool getSignalQuality();
}
}
namespace MyDeviceWiFiModule
{
public class Module : ModuleInit
{
public override void Load() // seems to be not executed
{
Debug.WriteLine("Loading Module");
}
public override void AddServices() // seems to be not executed
{
RootWorkItem.Services.AddNew<WLANAdapter, IWLANAdapter>();
Debug.WriteLine("Services Added");
}
}
}
<?xml version="1.0" encoding="utf-8" ?>
<SolutionProfile>
<Modules>
<ModuleInfo AssemblyFile="MyDeviceWiFiModule.dll" />
</Modules>
</SolutionProfile>
[MTAThread]
static void Main()
{
Assembly assembly = Assembly.LoadFrom(Path.Combine(GetAssemblyPath(), "MyDeviceWiFiModule.dll"));
RootWorkItem.SetModuleInfoStore(new ResourceModuleInfoStore(assembly)); // RootWorkItem.Services contain OpenNETCF.IoC.WorkItem, OpenNETCF.IoC.ResourceModuleInfoStore, OpenNETCF.IoC.ModuleInfoStoreService
RootWorkItem.Modules.LoadModules(); // without exceptions: m_storeLoaded is true
var c = RootWorkItem.Modules.Count;
MessageBox.Show(c.ToString()); // 0
var WLANAdapterService = RootWorkItem.Services.Get<IWLANAdapter>(); // this is null
var sq = WLANAdapterService.getSignalQuality(); //
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment