Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Compact Framework / August 2007

Tip: Looking for answers? Try searching our database.

Setting IP address of an ad-hoc wireless connection

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David Hearn - 23 Aug 2007 16:18 GMT
I've successfully used OpenNETCF to create an ad-hoc wireless connection
on a WM5 PDA (with the intention of talking to another PDA).  The IP
address is assigned automatically by APIPA (Automatic Private IP
Addressing) and in the range 169.254.x.y with subnet mask 255.255.0.0.

I need to be able to change the IP addresses assigned.  I cannot have
any external devices (other than 2 PDAs) and everything needs to be
controlled programmatically.

Is there any way to manually override/set the IP address using the
Compact Framework or OpenNETCF, or even native/PInvoke calls?

Thanks

David
<ctacke/> - 23 Aug 2007 18:57 GMT
The Smart Device Famrework has a "CurrentIPAddress" field for the Adapter
class.  Simply set it (and probably set DhcpEnabled to false)

Signature

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World
www.OpenNETCF.com

> I've successfully used OpenNETCF to create an ad-hoc wireless connection
> on a WM5 PDA (with the intention of talking to another PDA).  The IP
[quoted text clipped - 11 lines]
>
> David
Paul G. Tobey [eMVP] - 27 Aug 2007 18:07 GMT
I think that just setting the wireless adapter to *not* get the IP address
via DHCP and setting a static IP that you want is probably the right way to
fix the problem permanently.  You're going to get weird things going on if,
every time you start up, you change the IP address of the device.  If you
look through the registry under HKEY_LOCAL_MACHINE/Comm, you'll find a key
of the form <AdapterName><Number> where the AdapterName is the name
associated with the wireless network adapter.  Under that key, you'll find a
subkey, Parms, and under that, TcpIp.  In the TcpIp key branch, you'll find
things like EnableDHCP, a value that you can set to 0 to turn off DHCP for
getting addresses, and IpAddress, SubnetMask, and DefaultGateway, which are
multi-string values which you can set to the static IP, subnet, and gateway
that you want the adapter to use for itself.

Paul T.

> The Smart Device Famrework has a "CurrentIPAddress" field for the Adapter
> class.  Simply set it (and probably set DhcpEnabled to false)
[quoted text clipped - 14 lines]
>>
>> David
David Hearn - 30 Aug 2007 12:27 GMT
> The Smart Device Famrework has a "CurrentIPAddress" field for the Adapter
> class.  Simply set it (and probably set DhcpEnabled to false)

For some reason, after reading the online docs I thought it was a
read-only property - but looking again at the docs it clearly shots both
get and set.  Similarly, I thought DhcpEnabled was read only - although
probably as I read the description as "Indicator of whether DHCP (for IP
address assignment from a server), is enabled for the adapter."

I should read the docs more closely.

Now the problem.

I tried this and it generates an exception.  Specifically, I tried:

textBoxLog.Text += String.Format("IP: {0}\r\n",
wirelessNetworkAdaptor.CurrentIpAddress);

string currentIPAddress = wirelessNetworkAdaptor.CurrentIpAddress;

wirelessNetworkAdaptor.DhcpEnabled = false;
wirelessNetworkAdaptor.CurrentIpAddress = currentIPAddress;

textBoxLog.Text += String.Format("IP: {0}\r\n",
wirelessNetworkAdaptor.CurrentIpAddress);

And I get "InvalidCastException at OpenNETCF.Net.Adapter.set_DhcpEnabled()"

If I comment out the .DhcpEnabled = false line, I then get:

"InvalidCastException at OpenNETCF.Net.Adapter.set_CurrentIpAddress()"

I originally tried setting the IP manually via a hard coded string, so
tried getting the IP address and then setting it to the same IP address
to ensure the format was the same, but it made no difference.

I see that other people, using both 1.4 and 2.1 have experienced this
too:
http://www.opennetcf.org/forums/post.asp?method=TopicQuote&TOPIC_ID=8683&FORUM_ID=17

Any advice?

Thanks

David
<ctacke/> - 30 Aug 2007 13:41 GMT
Yes, it was a reported bug:
http://bugzilla.opennetcf.com/show_bug.cgi?id=107

If you've purchased the SDF, send an email to support[at]OpenNETCF.com to
get a patch, otherwise you'll have to wait for our next release.

Signature

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World
www.OpenNETCF.com

>> The Smart Device Famrework has a "CurrentIPAddress" field for the Adapter
>> class.  Simply set it (and probably set DhcpEnabled to false)
[quoted text clipped - 41 lines]
>
> David
David Hearn - 30 Aug 2007 14:53 GMT
> Yes, it was a reported bug:
> http://bugzilla.opennetcf.com/show_bug.cgi?id=107
>
> If you've purchased the SDF, send an email to support[at]OpenNETCF.com to
> get a patch, otherwise you'll have to wait for our next release.

I'm using the community edition, so I guess I'll have to wait.

With the Extensions for VS product, it comes with the sources. Would
this mean that we could, in theory, fix it ourselves?  If so, it might
be a cheaper option than doing with the maintenance agreement option.

Thanks

D
<ctacke/> - 30 Aug 2007 15:05 GMT
> With the Extensions for VS product, it comes with the sources. Would this
> mean that we could, in theory, fix it ourselves?  If so, it might be a
> cheaper option than doing with the maintenance agreement option.

Not just "in theory".  We can send you the fixed code and you can rebuild it
yourself, we just aren't at a state where we can recompile and release
another version the entire community edition for this fix.

Signature

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World
www.OpenNETCF.com

Paul G. Tobey [eMVP] - 30 Aug 2007 16:19 GMT
David,

You can manually make this change, if you want to and, when the fix comes
out, easily drop back to it.  The IP address is stored in the registry at
the location I mentioned in my other message.  Make the changes you need to
EnableDHCP and IPAddress, SubnetMask, and DefaultGateway, and then do an
Adapter.RebindAdapter() and the new information will be picked up from the
registry.

Paul T.

>> Yes, it was a reported bug:
>> http://bugzilla.opennetcf.com/show_bug.cgi?id=107
[quoted text clipped - 11 lines]
>
> D
David Hearn - 31 Aug 2007 11:37 GMT
> David,
>
[quoted text clipped - 6 lines]
>
> Paul T.

Excellent - I'll give that a go.

Thanks

David

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.