Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在Spring.Net中用相同数量的参数实例化具有多个构造函数的类型_C#_Spring_Spring.net - Fatal编程技术网

C# 如何在Spring.Net中用相同数量的参数实例化具有多个构造函数的类型

C# 如何在Spring.Net中用相同数量的参数实例化具有多个构造函数的类型,c#,spring,spring.net,C#,Spring,Spring.net,我想用Spring.Net实例化一个System.Net.IPEndPoint。 以下是我的xml代码: 但这会导致出现Spring.Core.TypeMismatchException,其中包含其他信息:无法将[System.Net.IPAddress]类型的属性值转换为属性“”所需的[System.Int64]类型 IPEndPoint有两个构造函数: spring似乎使用了第一个构造函数,这实际上是个坏主意 那么我如何告诉spring它应该使用第二个构造函数呢 更新: 我想出了如何将

我想用Spring.Net实例化一个
System.Net.IPEndPoint
。 以下是我的xml代码:


但这会导致出现
Spring.Core.TypeMismatchException
,其中包含其他信息:无法将[System.Net.IPAddress]类型的属性值转换为属性“”所需的[System.Int64]类型

IPEndPoint有两个构造函数:

spring似乎使用了第一个构造函数,这实际上是个坏主意

那么我如何告诉spring它应该使用第二个构造函数呢

更新:

我想出了如何将IPAddress转换为长地址:


但现在我遇到了一个异常:无法将[System.Int64]类型的属性值转换为属性“”所需的[System.Net.IPAddress]类型


现在看来Spring使用了另一个构造函数。这是什么

我自己找到了解决办法。如果构造函数不适合传递的参数,Spring.Net将抛出此异常。但是Spring.Net稍后会捕获此异常并尝试下一个构造函数。所以我的问题是,我必须告诉VisualStudio,它不应该因为这个异常而中断-。

谢谢你,你说得对,我会直接问微软的人。我只是想,因为这里有相关的问题,比如:我也可以得到答案,你可以在这里得到答案。甚至可能是完全正确的答案。但它们仍然不在网站的范围之内。。。所以我同意:最好问问微软的人,当他们发现你有什么不对劲的时候。。。然后他们就这样做了;-)
public IPEndPoint(long address, int port);
public IPEndPoint(IPAddress address, int port);
<object id="DestinationEndPoint" type="System.Net.IPEndPoint">
  <constructor-arg name="address" expression="T(System.Net.IPAddress).Parse('239.239.239.1')"/>
  <constructor-arg name="port" value="2010"/>
</object>