Hi Stack Overflow and sorry for my non-native English level
Currently programming an UPnP discovery service for a project in C# using .NET 4.0 on Visual Studio 2010.
I'm using the official Microsoft UPnP COM API and it's my first time using UPnP. My problem is that I'm trying to iterate on the services of the devices discovered by the library and a COM HRESUT:0X80040500 exception is thrown.
Here is a sample of my code:
IList<UpnpDevice> result = new List<UpnpDevice>();
UPnPDevices upnpDiscoveryResult = m_UPnPFinder.FindByType(upnpType, 0);
var upnpDiscoveryResultEnumerator = upnpDiscoveryResult.GetEnumerator();
while (upnpDiscoveryResultEnumerator.MoveNext())
{
var upnpDiscoveryDevice = (IUPnPDevice)upnpDiscoveryResultEnumerator.Current;
UPnPServices services = upnpDiscoveryDevice.Services;
var allServices = services.GetEnumerator();
// ------ Exception is thrown just below
while (allServices.MoveNext())
{
UPnPService service = allServices.Current as UPnPService;
if (service.Id == "urn:schemas-upnp-org:service:WANIPConnection:1")
{
}
else if (service.Id == "urn:schemas-upnp-org:service:WANPPPConnection:1")
{
}
}
I am lost on what to do.
According to these people which I think I may be having the same error...
- How do I access services of UPnP device?
- http://social.msdn.microsoft.com/Forums/en-US/b16a1e3b-9e85-480a-8240-82a2af73b924/could-not-iterate-upnp-services-of-a-device-using-microsoft-upnpdll)
...the problem may come from the official DLL and I guess I should better use a new one, but I wanted to ask here first. It seems weird to me that such an obvious bug could indeed come from the API.