gpt4 book ai didi

.net - SGEN 错误反射(reflect)类型

转载 作者:行者123 更新时间:2023-12-05 00:36:27 25 4
gpt4 key购买 nike

我已经实现了 Generating an Xml Serialization assembly as part of my build 接受的答案中提到的更改

<Target Name="AfterBuild" DependsOnTargets="AssignTargetPaths;Compile;ResolveKeySource" Inputs="$(MSBuildAllProjects);@(IntermediateAssembly)" Outputs="$(OutputPath)$(_SGenDllName)">
<!-- Delete the file because I can't figure out how to force the SGen task. -->
<Delete Files="$(TargetDir)$(TargetName).XmlSerializers.dll" ContinueOnError="true" />
<SGen BuildAssemblyName="$(TargetFileName)" BuildAssemblyPath="$(OutputPath)" References="@(ReferencePath)" ShouldGenerateSerializer="true" UseProxyTypes="false" KeyContainer="$(KeyContainerName)" KeyFile="$(KeyOriginatorFile)" DelaySign="$(DelaySign)" ToolPath="$(SGenToolPath)" Platform="$(Platform)">
<Output TaskParameter="SerializationAssembly" ItemName="SerializationAssembly" />
</SGen>
</Target>

构建 exe 项目的错误消息:

Error 14 There was an error reflecting type 'myNamespace.myAssembly.myForm.MicroContact'. C:\dev\src\myClient\myClient\SGEN myClient



这是 MicroContact 的代码(这里没有什么独特之处):
Public Class MicroContact
Implements IComparable

Private _id As Long
Private _name As String

Public Property Id() As Long
Get
Return _id
End Get
Set(ByVal value As Long)
_id = value
End Set
End Property

Public Property NoTitleFullName() As String
Get
Return _name
End Get
Set(ByVal value As String)
_name = value
End Set
End Property

Public Sub New()
_name = ""
End Sub

Public Sub New(ByVal id As Long, ByVal name As String)
_id = id
_name = name
End Sub

Public Function CompareTo(ByVal obj As Object) As Integer Implements System.IComparable.CompareTo
Return String.Compare(Me.NoTitleFullName, CType(obj, MicroContact).NoTitleFullName, True)
End Function

End Class

有什么办法可以让我得到构建错误的内部异常吗?

最佳答案

正如 Marc Gravell 指出的,运行 sgen /v MyClient.exe在 bin 目录中产生了更多信息。

该问题是由多个类共享相同名称引起的,在这种情况下,两个表单都实现了相同的 MicroContact 类,因为一个是从另一个中复制而来的。

关于.net - SGEN 错误反射(reflect)类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8033429/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com