Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9259041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:33:37+00:00 2026-06-18T12:33:37+00:00

I’m trying to register a new UPNP device(and trying to understand how it works

  • 0

I’m trying to register a new UPNP device(and trying to understand how it works by the way).

For now, I’m just trying to create a simple test, to have something working and build from there.

I’m using the UPnP Device host for now, I’ve the following code:

IUPnPRegistrar registrar = (IUPnPRegistrar)new UPnPRegistrarClass();
String description = GetDescription();
String path = GetPath();
registrar.RegisterDevice(description, "Test1", "Init", "Container", path, 900);

The GetDescription method return this:

<?xml version="1.0" encoding="utf-8" ?>
<root xmlns="urn:schemas-upnp-org:device-1-0">
    <specVersion>
        <major>1</major>
        <minor>0</minor>
    </specVersion>
    <device>
        <UDN>@@UDN@@</UDN>
        <friendlyName>Test device</friendlyName>
        <deviceType>urn:schemas-upnp-org:device:XmsHostService:1</deviceType>
        <manufacturer>Test</manufacturer>
        <manufacturerURL>http://www.test.com</manufacturerURL>
        <modelName>Test model name</modelName>
        <modelNumber>0.1</modelNumber>
        <modelDescription>Test device</modelDescription>
        <modelURL>http://www.test.com/test-model-url</modelURL>
        <serialNumber>0000001</serialNumber>
        <UPC>00000-00001</UPC>
        <serviceList>
            <service>
                <serviceType>urn:schemas-upnp-org:service:XmsHost:1</serviceType>
                <serviceId>urn:upnp-org:serviceId:XmsHost</serviceId>
                <controlURL></controlURL>
                <eventSubURL></eventSubURL>
                <SCPDURL>serviceDescription.xml</SCPDURL>
            </service>
        </serviceList>
    </device>
</root>

And my C:\upnphost\service.xml contains the following code:

<?xml version="1.0" encoding="utf-8"?>
<scpd xmlns="urn:schemas-upnp-org:service-1-0">
    <specVersion>
        <major>1</major>
        <minor>0</minor>
    </specVersion>
    <actionList>
        <action>
            <name>GetPort</name>
            <argumentList>
                <argument>
                    <name>_ReturnValue</name>
                    <direction>out</direction>
                    <retval />
                    <relatedStateVariable>A_ARG_TYPE_GetPort_RetType</relatedStateVariable>
                </argument>
            </argumentList>
        </action>
    </actionList>
    <serviceStateTable>
        <stateVariable sendEvents="no">
            <name>A_ARG_TYPE_GetPort_RetType</name>
            <dataType>ui4</dataType>
        </stateVariable>
        <stateVariable sendEvents="no">
            <name>Port</name>
            <dataType>ui4</dataType>
        </stateVariable>
    </serviceStateTable>
</scpd>

So, first, does this xml code looks right?

When I call the register device, I got this exception:

    System.ArgumentException was unhandled
  Message=Value does not fall within the expected range.
  Source=UPnPHostLib
  StackTrace:
       at UPnPHostLib.IUPnPRegistrar.RegisterDevice(String bstrXMLDesc, String bstrProgIDDeviceControlClass, String bstrInitString, String bstrContainerId, String bstrResourcePath, Int32 nLifeTime)
       at UPnPHosterTester.Hoster.Start() in E:\Dev\Discovery\XMS_SW_Discovery_B\Solution\UPnPHosterTester\Hoster.cs:line 32
       at UPnPHosterTester.Program.Main(String[] args) in E:\Dev\Discovery\XMS_SW_Discovery_B\Solution\UPnPHosterTester\Program.cs:line 19
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 

But I don’t see what can be wrong, the 900 is the min value accepted. Other linked question: I know that I have to implement the IUPnPDeviceControl interface and insert in my previous code instead of Test1, but I don’t know what I should return in the GetServiceObject

EDIT
Here is the GetDescription method:

private string GetDescription()
{
    string xml = File.OpenText("DeviceDescription.xml").ReadToEnd();
    xml = xml.Replace("@@UDN@@", "uuid:" +Guid.NewGuid().ToString());
    return xml;
}

EDIT 2
I tried, as recommended to remove all non-mandatory properties:

<?xml version="1.0" encoding="utf-8" ?>
<root xmlns="urn:schemas-upnp-org:device-1-0">
    <specVersion>
        <major>1</major>
        <minor>0</minor>
    </specVersion>
    <device>
        <UDN>@@UDN@@</UDN>
        <friendlyName>Test device</friendlyName>
        <deviceType>urn:test-com:device:HostDevice:1</deviceType>
        <manufacturer>Test</manufacturer>
        <modelName>Test model name</modelName>
    </device>
</root>

But I still have the exact same error

Edit 3
I did found that there is an utility to check the good structure of the service xml file(not the device :() here: http://msdn.microsoft.com/en-us/library/aa381938(v=vs.85).aspx You can use it with VS studio command prompt: validatesd.exe. It validates my service

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T12:33:38+00:00Added an answer on June 18, 2026 at 12:33 pm

    The COM Object progid must correspond to something real, ie: “Test1” must be a valid COM object registered in the current registry for the RegisterDevice call to succeed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to create an if statement in PHP that prevents a single post
I am trying to loop through a bunch of documents I have to put
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I'm new to using the Perl treebuilder module for HTML parsing and can't figure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.