草庐IT

CTEST_CONFIGURATION_TYPE

全部标签

c# - 使用泛型类型参数代替 System.Type 类型的参数。是气味吗?

关闭。这个问题是opinion-based.它目前不接受答案。想要改进这个问题?更新问题,以便editingthispost可以用事实和引用来回答它.关闭3年前。Improvethisquestion我经常看到(例如在许多模拟库中)使用泛型类型参数代替System.Type类型参数的方法。我特别讨论的是泛型类型仅在typeof(T)操作中使用的情况(即,方法中的任何地方都没有使用类型T的实例,并且T没有被用于返回值类型或其他参数)。例如考虑以下方法:publicstringGetTypeName(System.Typetype){returntype.FullName;}这个方法通常伴

c# - IIS 抛出 ThreadAbortException 并回收 worker,IIS 日志记录为 "IIS configuration change"的可能原因是什么?

当后台线程正在运行时,我开始在Appharbor上托管的.NetMVC网络应用程序中看到错误-经过仔分割析-我无法找出原因。首先,我注意到的异常是ThreadAbortException。然而,这实际上只是表示线程正在被杀死。在线程被杀死之前,您可以看到IIS创建了一个新的worker,并在同一台机器上调用了Application_Start。新应用程序启动并运行后,IIS会终止旧应用程序并按预期处理新请求。同时,IIS记录一条消息:ShutDownMessage:IISconfigurationchangeHostingEnvironmentinitiatedshutdownHost

c# - 异步任务<IEnumerable<T>> 抛出 "is not an iterator interface type"错误

仅当我使用async时,下面的代码才会抛出isnotaniteratorinterfacetypeawait并包装IEnumerable与任务。如果我删除asyncawait,它将与IEnumerable>一起使用.privateasyncTask>>GetTableDataAsync(CloudTablecloudTable,TableQuerytableQuery)whereT:ITableEntity,new(){TableContinuationTokencontineousToken=null;do{varcurrentSegment=awaitGetAzureTableDa

c# - 旧格式或无效类型库。 (来自 HRESULT : 0x80028018 (TYPE_E_INVDATAREAD)) 的异常

这个问题在这里已经有了答案:Microsoft.Office.Interop.Exceldoesn'tworkon64bit(1个回答)关闭8年前。将数据GridView中的数据导出到Excel工作表时出现错误:error(Oldformatorinvalidtypelibrary.(ExceptionfromHRESULT:0x80028018(TYPE_E_INVDATAREAD)))在这一行:Microsoft.Office.Interop.Excel._Workbookworkbook=app.Workbooks.Add(Type.Missing);我该如何解决这个问题?我的完

c# - 编译器错误 : "error CS0307: The variable ' int' cannot be used with type arguments"

如果我有以下代码:privatevoidCheck(boola,boolb){}privatevoidCheck(inta,intb,intc,boolflag){Check(a(flag?c:b-10));}我在调用Check(int,int)时遇到编译时错误:errorCS0307:Thevariable'int'cannotbeusedwithtypearguments我也遇到了这些错误:errorCS0118:'b'isavariablebutisusedlikeatypeerrorCS0118:'a'isavariablebutisusedlikeatype为什么会出现这些错

c# - Type.GetType 返回 null

这个问题在这里已经有了答案:Type.GetType("namespace.a.b.ClassName")returnsnull(17个答案)关闭7年前。我正在尝试使用Type.GetType并传递“caLibClient.entity.Web2ImageEntity”完整类名。caLibClient.entity是命名空间,位于单独的程序集(caLibClient)中并添加到程序引用程序集列表中。当我从程序中调用Type.GetType时,它​​总是返回Null,有什么问题吗?

c# - 如何解决错误 : Inconsistent accessibility: parameter type for generic c# interface?

将此代码写入我的项目时出现错误Error1Inconsistentaccessibility:fieldtype'System.Collections.Generic.List'islessaccessiblethanfield'Jain_milan.addchild.m_children'Error2Inconsistentaccessibility:parametertype'System.Collections.Generic.List'islessaccessiblethanmethod'Jain_milan.addchild.addchild(System.Collectio

C# 泛型 : cast generic type to value type

我有一个泛型类,它保存指定类型T的值。该值可以是int、uint、double或float。现在我想获取值的字节以将其编码为特定协议(protocol)。因此我想使用方法BitConverter.GetBytes()但不幸的是Bitconverter不支持泛型类型或undefinedobject。这就是为什么我要转换值并调用GetBytes()的特定重载。我的问题:如何将通用值转换为int、double或float?这不起作用:publicclassGenericClasswhereT:struct{T_value;publicvoidSetValue(Tvalue){this._va

c# - .NET 自定义配置部分 : Configuration. GetSection 引发 'unable to locate assembly' 异常

我已经为一个插件DLL创建了一个自定义配置部分,它将.configXML存储在一个单独的(与主可执行应用程序不同的)文件中。这是自定义部分类的示例:usingSystem;usingSystem.Configuration;namespacePluginFramework.MyConfiguration{publicclassMyConfigurationSettings:ConfigurationSection{privateConfiguration_Config=null;#regionConfigurationProperties//////AcustomXMLsectionf

c# - 为什么不能将 Type 用作常量值?

引用MSDN-const(C#reference):Aconstantexpressionisanexpressionthatcanbefullyevaluatedatcompiletime.Therefore,theonlypossiblevaluesforconstantsofreferencetypesarestringandanullreference.根据:typeof(T)vs.Object.GetType()performance,typeof(T)是一个编译时表达式。那么为什么Type不能是常量值呢?以下代码不会编译:publicconstTypeINT_TYPE=ty