草庐IT

kotlin-reflect

全部标签

c# - "Inspecting the state of an object in the debuggee of type System.Reflection.MethodBase is not supported in this context"

我不知道这个错误是什么意思。我使用的是VisualStudioforMac7.5.0社区版。我在带有ASP.NETCore的EntityFramework中使用延迟加载。publicpartialclassAdminUser{publicAdminUser(){RoleAssign=newHashSet();}publicGuidUserId{get;set;}publicstringFirstName{get;set;}publicstringLastName{get;set;}publicstringEmail{get;set;}publicstringUserName{get;s

c# - 使用 Reflection.Emit 创建一个实现接口(interface)的类

我需要使用实现以下接口(interface)的Reflection.Emit生成一个类。publicinterfaceIObject{TGet(stringpropertyName);}有没有人举例说明我将如何发出以下内容作为简单的测试用例?classGeneratedObject:IObject{publicTGet(stringpropertyName){//thisisthesimplestpossibleimplementationreturndefault(T);}} 最佳答案 如果您正在使用Reflection.Emit

c# - ASP.NET MVC 如何知道如何填充您的模型以提供 Controller 的操作?它涉及反射(reflection)吗?

定义了一个模型publicclassHomeModel{[Required][Display(Name="FirstName")]publicstringFirstName{get;set;}[Required][Display(Name="Surname")]publicstringSurname{get;set;}}并具有以下ControllerpublicclassHomeController:Controller{[HttpPost]publicActionResultIndex(HomeModelmodel){returnView(model);}publicActionRe

c# - "+"在成员 c# 之后反射(reflect)的全名和 '*' 是什么意思#

我目前正在处理C#中的反射。之后:Assembly.LoadFile(@"C:\ProgramFiles\dotnet\shared\Microsoft.NETCore.App\2.0.7\System.Numerics.Vectors.dll").GetTypes()我发现了这个:[System.Numerics.Matrix4x4]、[System.Numerics.Matrix4x4+CanonicalBasis]、[System.Numerics.Matrix4x4+VectorBasis](有来自“System.Numerics.Vectors.dll”的反射类型)我知道Ma

c# - 我试图理解我反射(reflect)过的微软的 Do​​ubleUtil.AreClose() 代码

如果您反射(reflection)WindowsBase.dll>MS.Internal.DoubleUtil.AreClose(...),您将获得以下代码:publicstaticboolAreClose(doublevalue1,doublevalue2){if(value1==value2){returntrue;}doublenum2=((Math.Abs(value1)+Math.Abs(value2))+10.0)*2.2204460492503131E-16;doublenum=value1-value2;return((-num2num));}我试图理解两件不同的事情:

c# - System.Reflection.Assembly 的空引用异常

我开发了一个用于内部电子邮件报告的库。当我从另一个项目使用该库时(通过添加引用)。它在下一行给出了NullReferenceException。System.Reflection.Assembly.GetEntryAssembly().GetName().Name知道为什么Assembly为空吗? 最佳答案 这是预期的,尤其是在由非托管运行时加载的Windows服务中。使用:Process.GetCurrentProcess().MainModule.FileName获取非托管入口点文件。更新看来您正在寻找这个:System.Ref

c# - 反射(reflect)接口(interface)的所有属性,包括继承的属性?

我有一个表示接口(interface)的System.Type实例,我想获取该接口(interface)上所有属性的列表——包括从基接口(interface)继承的那些。我基本上希望从接口(interface)获得与类相同的行为。例如,给定这个层次结构:publicinterfaceIBase{publicstringBaseProperty{get;}}publicinterfaceISub:IBase{publicstringSubProperty{get;}}publicclassBase:IBase{publicstringBaseProperty{get{return"Bas

c# - 反射(reflection):如何在 C# 7.0 中查找和调​​用本地函数?

我有一个私有(private)静态泛型方法,我想使用反射调用它,但实际上我想将它“捆绑”到另一个方法中。C#7.0支持本地函数,因此这绝对是可能的。你会说“你为什么不直接调用它呢?”但我正在使用它来获得以强类型方式使用对象和System.Type的能力,因此我需要动态调用它。如果我拥有这段代码,它就已经可以工作了,因为它是自己的私有(private)静态泛型方法。privatestaticvoidHandleResponse(objectdata,TypeasType){varapplication=typeof(Program);application.GetMethod(nameo

c# - 反射(reflection)使用 out 参数的静态重载方法

我在通过反射调用带有out参数的重载静态方法时遇到一些问题,希望得到一些指示。我希望动态创建一个类型,如System.Int32或System.Decimal,然后调用静态TryParse(string,outx)方法。下面的代码有两个问题:t.GetMethod("TryParse",newType[]{typeof(string),t})未能返回我期望的MethodInfomi.Invoke(null,newobject[]{value.ToString(),concreteInstance})似乎成功但未设置输出参数concreteInstance到解析后的值交织到这个函数中,您

c# - ServiceController status 没有正确反射(reflect)实际的服务状态

如果我的服务正在启动或停止,我会使用此代码运行powershell脚本。Timertimer1=newTimer();ServiceControllersc=newServiceController("MyService");protectedoverridevoidOnStart(string[]args){timer1.Elapsed+=newElapsedEventHandler(OnElapsedTime);timer1.Interval=10000;timer1.Enabled=true;}privatevoidOnElapsedTime(objectsource,Elaps