.NET诊断工具?(.NET diagnostic tools? [closed])
有谁知道一些用于.NET应用程序的通用计算机或/和应用程序诊断工具吗?
例如,应用程序不会在客户的计算机上启动。 他可以运行诊断工具,执行一些简单的检查:
- 哪些.NET Framework版本安装?
- 安装的.NET Framework版本是否有效(或者可能是brocken)?
- ...
在.NET特定应用程序中从来没有见过类似的东西
does anyone know some generic computer or/and application diagnostic tools for .NET applications?
For example a applications doesn't start on the computer of a customer. He can run the diagnostics tool which does some simple checks like:
- Which .NET Framework Versions are installed?
- Is the installed .NET Framework version valid (or maybe brocken)?
- ...
Never seen something like this for .NET specific applications.
原文:https://stackoverflow.com/questions/5192034
最满意答案
CurrentUser
和temp
都是引用,调用temp == CurrentUser
只比较那些引用(而不是实际对象),因此它们永远不会成立。 如果你想比较你的实体,最好的办法是实现IEquatable
并覆盖obect.Equals()
和object.GetHashcode()
。 然后你可以调用temp.Equals(CurrentUser)
,这将给出所需的行为。 例如:public class User : IEquatable<User> { public int Id {get; set;} ... public bool Equals(User other) { return this.Id == other.Id; } public override bool Equals(object other) { return this.Id == (User)other.Id; } public override int GetHashcode() { return this.Id.GetHashCode(); } }
注意:您应该始终覆盖
object
上的Equals
和GetHashcode
方法。 例如,HashSet<T>
在内部使用这些方法而不是IEquatable<T>
实现的通用版本,因此如果不覆盖它们,则会得到错误的结果。Both
CurrentUser
andtemp
are references, callingtemp == CurrentUser
only compares those references (not the actual objects) so they will never be true. If you want to compare your entities, the best thing to do is implementIEquatable
and overrideobect.Equals()
andobject.GetHashcode()
. Then you can calltemp.Equals(CurrentUser)
and that will give the desired behavior. For example:public class User : IEquatable<User> { public int Id {get; set;} ... public bool Equals(User other) { return this.Id == other.Id; } public override bool Equals(object other) { return this.Id == (User)other.Id; } public override int GetHashcode() { return this.Id.GetHashCode(); } }
Note: you should always override the
Equals
andGetHashcode
methods onobject
too. For exampleHashSet<T>
uses those methods internally instead of the generic version implemented byIEquatable<T>
so if you don't override them, you will get the wrong results.
相关问答
更多-
您可以在不同的有界上下文中对同一实体进行不同的表示。 BC省公司的Company可能与User BC公司的公司截然不同。 他们必须分享的是某种相关性Id。 You can have different representations of the same entity in different bounded contexts. Company in Company BC can be very different from company in User BC. All they have to sha ...
-
CurrentUser和temp都是引用,调用temp == CurrentUser只比较那些引用(而不是实际对象),因此它们永远不会成立。 如果你想比较你的实体,最好的办法是实现IEquatable并覆盖obect.Equals()和object.GetHashcode() 。 然后你可以调用temp.Equals(CurrentUser) ,这将给出所需的行为。 例如: public class User : IEquatable
{ public int Id {get; set;} ... -
很难在网上论坛发布大量信息并保持可读性。 相反,我建议你阅读两本书: Windows Internals ,用于操作系统级概念(进程和线程)。 CLR通过C# ,用于.NET级概念(AppDomain和托管线程)。 It's difficult to post a lot of information in an online forum and keep it readable. Rather, I recommend that you read two books: Windows Internals, ...
-
由不同上下文创建的实体(甚至是相同上下文类型的不同实例)将不相同。 恕我直言,你必须自己处理它,因为不允许AnimalContext创建在FruitContext中定义的对象实例 - 在你的情况下是Apple实体,并在FruitContext加载后将Apple分配给Dog - 你需要在Dog上公开AppleId属性。 这可能通过处理ObjectContext.ObjectMaterialized事件处理程序中的inter连接以某种方式自动化,但它可以减慢对象加载速度,它可以使您的上下文紧密耦合。 您可以在A ...
-
我在VS2015中遇到了同样的错误。 我删除了源代码,修复了bug,并上传了带有链接依赖项的新NuGet包。 3个新套餐包括: MvcScaffolding.VS2015 T4Scaffolding.VS2015 T4Scaffolding.Core.VS2015 首先卸载MvcScaffolding及其依赖项,T4Scaffolding和T4Scaffolding.Core。 如果您只是安装MvcScaffolding包,其他包将被拉过。 希望这有助于其他人。 干杯。 I came across this ...
-
您可以使用AsNoTracking扩展方法来查询您的列表,而无需将对象附加到上下文中。 var repo = new RaceEventRepository(); EventRaces = repo.All.AsNoTracking() .Where(r => r.RaceName.Contains(eventName)) .ToList(); ...或者,您可以通过将其状态设置为Detached来从上下文中分离单个实体: context.Entry(raceEvent).State = ...
-
n3376 5.2.10 / 6 函数指针可以显式转换为不同类型的函数指针。 通过指向函数类型(8.3.5)的函数调用函数的效果是未定义的,该函数类型与函数定义中使用的类型不同。 除了将“指向T1的指针”类型的prvalue转换为“指向T2的指针”类型(其中T1和T2是函数类型)并返回其原始类型产生原始指针值之外,这种指针转换的结果未指定。 n3376 5.2.10/6 A function pointer can be explicitly converted to a function pointer ...
-
为实体框架中的不同上下文设置不同的执行策略(Setting different Execution Strategies for different contexts in Entity Framework)[2023-07-01]
请使用此处详述的解决方法: 重试执行策略的实体框架限制(EF6起) 或者在这里覆盖DbConfiguration的技术或在这里使用不同的DbConfiguration: 实体框架基于代码的配置(EF6以上) Either use the workarounds detailed here: Entity Framework Limitations with Retrying Execution Strategies (EF6 onwards) Or one the techniques for overri ... -
指示LINQ to Entities生成Oracle兼容SQL(Instruct LINQ to Entities to Generate Oracle Compatible SQL)[2022-02-15]
假设您有实体模型,请确保正确设置DDL生成模板。 此外,您可以删除数据库模式名称的dbo以匹配您的实际数据库。 Shortly after asking, i found a way to solve my problem I had this POCO class [Table("TEST_TABLE")] public class MyEntity { [Key, Column("VAL")] public string key_valye { get; set; } } The ge ... -
使用重叠的DbSets将DbContext拆分为多个上下文(Splitting DbContext into multiple contexts with overlapping DbSets)[2022-07-20]
如果需要使用跨越多个DbContext的事务,则会遇到问题。 无论所有DbContexts是否连接到同一数据库,它都将被提升为分布式事务。 这使事情变得非常缓慢。 您也将失去工作单元的好处,因为DbContexts将独立跟踪其模型。 您仍然可以分离模型并复制共享模型。 这不会导致各种DbContexts破坏关系或死锁,不止两个人同时运行两个软件副本。 但是,为了保持可管理性,您可以保留在一个DbContext中,但隐藏每个模块中不需要的模型。 采取以下DbContext - public class MyC ...