Created
December 11, 2012 10:18
-
-
Save hellboy81/4257567 to your computer and use it in GitHub Desktop.
Try to load module and access service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace DeviceControlContacts | |
{ | |
public interface IWLANAdapter | |
{ | |
bool getSignalQuality(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8" ?> | |
<SolutionProfile> | |
<Modules> | |
<ModuleInfo AssemblyFile="MyDeviceWiFiModule.dll" /> | |
</Modules> | |
</SolutionProfile> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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