我想在.NET Lambda中使用.NET Framework 4.7解决方案和.NET Core解决方案之间共享代码。.NET Framework 4.7中的.NET标准类库项目
我已经创建了一个.NET Standard 1.6类库项目,并已将一些代码从.NET Framework 4.7解决方案移到此项目中以便共享它。
除了一件事情之外,所有工作都很好 - 代码是由.NET解决方案中的BinaryFormatter序列化的DTO类。
例如:
[Serializable]
public class BillableOptionalOperationDto
{
public string OperationDescription { get; set; }
public string Note { get; set; }
public decimal UnitPriceIncGst { get; set; }
}
我创建了一个填充工具使代码在.NET标准项目编译。
namespace System
{
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Delegate)]
public class SerializableAttribute : Attribute
{
}
}
.NET标准项目作为Nuget包发布到TeamCity中的Nuget服务器。
在.NET Framework解决方案,我(非常正确)收到此错误:
Error CS0433 The type 'SerializableAttribute' exists in both 'AutoGuru.Shared.Quoting, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' and 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
有没有在.NET 1.6标准类库使用的BinaryFormatter一个类的方法吗?