문제

While hacking some data into my settings.settings in VS 2010, i discovered i can use many different types from a variety of libraries i use, for example, the HTTPListener from the System.Net-namespace.

But for some strange reason i can't see why, i can't use the IPAddress-type, which i need actually. Why is this so and how can i fix this, since for me, this is nothing more than an annoying bug.

I don't know what to try to fix this?

도움이 되었습니까?

해결책

System.Net.IPAddress has the Serializable-Attribute

That's not relevant, [Serializable] only matters to binary serialization. Settings are serialized with XML serialization. Which is the core problem, that only works when the type has a default constructor. So the deserializer can create a new object and set the public fields and properties. IPAddress doesn't have one.

Consider using a simple string instead. Use IPAddress.Parse() and ToString() in your code to convert.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top