Iceman228
Iceman228
CC#
Created by Iceman228 on 11/29/2022 in #help
TcpClient connection
using TcpClient tcpClient = new(domain, port);
using TcpClient tcpClient = new(domain, port);
When I let this run on my local machine, it works fine. But on our server, I get System.Net.Internals.SocketExceptionFactory+ExtendedSocketException (10060). But only for some websites. I am using Port 443. Goal is to read the certificate with SslStream afterwards. When I tested it on the system of a colleague, he first had to run the program with Visual Studio, otherwise the exe produced the same errors for some websites as on the server. I have no idea what the issue could be.
2 replies
CC#
Created by Iceman228 on 10/18/2022 in #help
Remove list element
AddTabGroupChildren(Config.KpiSelection.TabHierarchy.TabBase);
private void AddTabGroupChildren(List<XmlTabBase> members)
{
members = members
.OrderBy(p => p.Order)
.ToList();

var children = members.OfType<XmlTabGroup>().ToLookup(group => group.GroupId);
foreach (var member in members.OfType<XmlTabGroup>().ToList())
{
member.TabBase.AddRange(new List<XmlTabGroup>(children[member.Order].ToList()));
member.TabBase = member.TabBase.OrderBy(p => p.Order).ToList();
if (member.GroupId != 0) members.RemoveAt(members.FindIndex(p => p.Order == member.Order));
}
}
AddTabGroupChildren(Config.KpiSelection.TabHierarchy.TabBase);
private void AddTabGroupChildren(List<XmlTabBase> members)
{
members = members
.OrderBy(p => p.Order)
.ToList();

var children = members.OfType<XmlTabGroup>().ToLookup(group => group.GroupId);
foreach (var member in members.OfType<XmlTabGroup>().ToList())
{
member.TabBase.AddRange(new List<XmlTabGroup>(children[member.Order].ToList()));
member.TabBase = member.TabBase.OrderBy(p => p.Order).ToList();
if (member.GroupId != 0) members.RemoveAt(members.FindIndex(p => p.Order == member.Order));
}
}
I have a method which takes a flat list and generates a tree from it. At the end I remove the elements from the list which have been added as a child. This is the part which isn't working anymore and I don't understand why. Meaning when I look at members inside the method, the list at the end is correct, but the actual property still has the deleted elements. The added children are correct though.
7 replies
CC#
Created by Iceman228 on 9/26/2022 in #help
XML Deserialization Null Exception
I have an XML element which usually looks like this
<LoginName><![CDATA[Name]]></LoginName>
<LoginName><![CDATA[Name]]></LoginName>
It is possible thought that someone deleted the whole cdata part and if that happened, when trying to deserialize it, I get a NullReferenceException.
public static XmlCDataSection ToCData(this string str)
{
return new XmlDocument().CreateCDataSection(str);
}

[XmlIgnore] public string LoginName { get; set; }
[XmlElement("LoginName")]
public XmlCDataSection CDataLoginName
{
get => LoginName.ToCData();
set => LoginName = value.Value;
}
public static XmlCDataSection ToCData(this string str)
{
return new XmlDocument().CreateCDataSection(str);
}

[XmlIgnore] public string LoginName { get; set; }
[XmlElement("LoginName")]
public XmlCDataSection CDataLoginName
{
get => LoginName.ToCData();
set => LoginName = value.Value;
}
How can I prevent this exception?
4 replies
CC#
Created by Iceman228 on 8/30/2022 in #help
Set property based on another
public class XmlTabColumnDefinition
{
[XmlIgnore] public string KeyValue { get; set; };
[XmlElement("KeyValue")] public XmlKeyValue XmlKeyValue { get; set; }
}
public class XmlKeyValue
{
[XmlAttribute("ColumnName")] public string ColumnName { get; set; };
}
public class XmlTabColumnDefinition
{
[XmlIgnore] public string KeyValue { get; set; };
[XmlElement("KeyValue")] public XmlKeyValue XmlKeyValue { get; set; }
}
public class XmlKeyValue
{
[XmlAttribute("ColumnName")] public string ColumnName { get; set; };
}
How can I set ColumnName based on KeyValue? Meaning when I change KeyValue during runtime, ColumnName gets the same value and the other way around.
7 replies