草庐IT

system_t

全部标签

c# - 获取程序集中的类型(错误 : System. Reflection.ReflectionTypeLoadException)

我收到类型为“异常详细信息:System.Reflection.ReflectionTypeLoadException:无法加载一种或多种请求的类型。检索LoaderExceptions属性以获取更多信息。”的异常。使用以下代码:publicIEnumerableFindClassesOfType(TypeassignTypeFrom,IEnumerableassemblies,boolonlyConcreteClasses=true){foreach(varainassemblies){foreach(vartina.GetTypes())我需要获取每个程序集中定义的类型,但似乎无法

c# - 模拟 'System.Console' 行为

是否有一种标准方法可以通过针对接口(interface)而不是System.Console进行编程来使C#控制台应用程序可单元测试?例如,使用IConsole界面?你做过吗,用的是什么方法?当您的应用程序需要写入标准输出时,您是否公开了事件? 最佳答案 我认为您使用接口(interface)的方法可行,但我认为我不会使用事件。假设应用程序不接受命令行参数以外的用户输入,我可能会使用类似这样的东西来包装Console.Write/Console.WriteLine:publicinterfaceIConsoleWriter{voidW

c# - 无法加载文件或程序集“System.Runtime.InteropServices.RuntimeInformation

每当我尝试使用应用程序洞察力和EntityFramework运行webjob项目时,我都会收到此错误。System.IO.FileLoadException:'Couldnotloadfileorassembly'System.Runtime.InteropServices.RuntimeInformation,Version=0.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a'oroneofitsdependencies.Thelocatedassembly'smanifestdefinitiondoesnotmatchth

c# - 如何将字符转换为等效的 System.Windows.Input.Key 枚举值?

我想写一个这样的函数,publicSystem.Windows.Input.KeyResolveKey(charcharToResolve){//Codegoeshere,thatresolvesthecharToResolve//intotheKeyenumeratedvalue//(Forexamplewith'.'asthecharacterforKey.OemPeriod)}我知道我可以写一个巨大的Switch-case来匹配角色,但还有其他方法吗?问题是Key枚举的字符串可能与字符不匹配,因此Enum.IsDefined将不起作用有什么想法吗?更新:这是在Windows环境下

c# - System.Runtime.InteropServices.COMException (0x80040154) :

关闭。这个问题不符合StackOverflowguidelines.它目前不接受答案。这个问题似乎与helpcenter中定义的范围内的编程无关。.关闭4年前。Improvethisquestion我在C#项目中遇到异常:System.Runtime.InteropServices.COMException(0x80040154):RetrievingtheCOMclassfactoryforcomponentwithCLSID{877AA945-1CB2-411C-ACD7-C70B1F9E2E32}failedduetothefollowingerror:80040154.这意味着

c# - 'System.Data.Entity.Internal.AppConfig' 的类型初始值设定项在子网站上抛出异常

我有2个网站,一个是另一个的子目录,但它是一个应用程序例如:/root&/root/Services他们都使用EntityFramework6.x但子网站正在抛出ThetypeinitializerforSystem.Data.Entity.Internal.AppConfig'throwanexception因为它似乎看到了许多条目由于嵌套的web.config而用于相同的EF数据库提供程序有没有办法清除提供程序集合,这样我就不会收到此错误?我试过没有效果。如果我注释掉providers部分就可以了但我不想这样做,因为并非每个环境都会有嵌套网站。并且NuGet倾向于将其放回原处。我可

c# - LINQ to Entities 无法识别方法 'Int32 Int32(System.String)' 方法,并且无法将此方法翻译成存储表达式

我正在尝试使用LinqtoEntities查询数据库上下文,但出现此错误:LINQtoEntitiesdoesnotrecognizethemethod'Int32Int32(System.String)'method,andthismethodcannotbetranslatedintoastoreexpression.`代码:publicIEnumerableGetCourseName(){varcourse=fromoinentities.UniversityCoursesselectnewCourseNames{CourseID=Convert.ToInt32(o.Course

c# - 我如何允许在 VS2010 中中断 'System.NullReferenceException'?

我有一个VS2010C#.NET4项目。问题是程序在调试期间不会因“NullReferenceException”错误而中断。输出窗口将显示以下内容:myProgram.exe中发生类型为“System.NullReferenceException”的第一次机会异常...但是调试器将退出该函数并继续运行程序的其余部分。如何更改此行为,以便调试器在遇到这些异常时中断? 最佳答案 转到调试->异常->搜索NullReferenceException并选中“抛出”复选框。 关于c#-我如何允许

c# - 无法读取配置部分 'system.web.webPages.razor',因为它缺少部分声明

我卡住了..Razor不再在VS2013中工作,我在浏览器中收到此消息:我相信它在消息中missingasectiondeclaration但我不知道是什么做..请帮忙!!HTTPError500.19-InternalServerErrorTherequestedpagecannotbeaccessedbecausetherelatedconfigurationdataforthepageisinvalid.ModuleIISWebCoreNotificationUnknownHandlerNotyetdeterminedErrorCode0x80070032ConfigErrorT

c# - System.Windows.MessageBox 在开始之前不会等待用户输入!

...而且这是没有道理的。T-T在我的Application_Startup事件处理程序中,我的代码看起来有点像这样:privatevoidApplication_Startup(objectsender,StartupEventArgse){stringerrorMessage;if(CheckStartUpConditions(outerrorMessage)){(newMainWindow()).Show();}else{MessageBox.Show(errorMessage,"ApplicationStartup",MessageBoxButton.OK,MessageBox