草庐IT

qt5_use_modules

全部标签

c# - 异常(HRESULT : 0x800AC472) when using Excel. 工作表。调用 Excel.Workbook.SaveAs 后选择

我正在打开一个xlsx文件并将每张纸保存到一个csv文件中。保存的相关代码如下:inti=0;foreach(Excel.Worksheetsinapp.ActiveWorkbook.Sheets){s.Select(true);//ErrorhereStringoutfile=outputpath+"("+i+")"+outputfilename+".csv";wkb.SaveAs(outfile,Excel.XlFileFormat.xlCSVMSDOS);++i;}输出文件名或路径没有问题,输出文件不存在。它保存前两张纸然后崩溃。我尝试使用具有4张纸的不同输入文件,它运行良好,所

c# - EF6 : Renaming namespace using Code First Migrations

我可以重命名我整个项目的命名空间(当然包括:DbContext类、迁移配置类等)而不破坏任何东西或不必重新创建我的所有迁移?比如说,我有ProjectMyProject,命名空间是Foo.MyProject我的配置类在Foo.MyProject.Migrations假设我想为Bar重命名Foo命名空间,当然我的Configurations命名空间现在将是Bar.MyProject.Configurations是否有任何正确的方法可以做到这一点并保持我当前的所有迁移仍然有效?这些方法是否涉及手动编辑___MigrationHistory表或其他内容?(我一眼就看到了ContextKey列

c# - 自定义 "using" block

我正在使用一个数据库,并且有一种情况我想关闭其中的一个特性。关闭该功能看起来像这样......DatabaseContext.Advanced.UseOptimisticConcurrency=false;开启它同样简单。这功能很好。但我对某些东西很好奇,想探索它......是否可以像处理dispose和unsafe那样将其包装在“using”block中?例如……using(DatabaseContext.Advanced.UseOptimisticConcurrency=false){//dothings!}//thefeatureisturnedbackonautomatical

c# - 复合WPF : EventAggregator - when to use?

我一直在寻找CompositeApplicationLibrary,这很棒,但我无法决定何时使用EventAggregator...或者更确切地说-何时不使用它。再看看StockTraderRI的例子,我就更糊涂了。他们在某些情况下使用EventAggregator,在其他情况下使用“经典”事件(例如在IAccountPositionService接口(interface)中)。我已经决定用它来与繁重的工作任务通信,它应该在后台线程上运行。在这种情况下,EventAggregator在幕后提供线程编码,因此我不必为此担心太多。除此之外,我喜欢这种方法提供的解耦。所以我的问题是:当我开始

c# - 发送邮件异步 : An asynchronous module or handler completed while an asynchronous operation was still pending

在使用SendMailAsync时出现以下错误:Anasynchronousmoduleorhandlercompletedwhileanasynchronousoperationwasstillpending我的代码:publicstaticasyncTaskSendEmail(MessageContentmessageContent,stringemailBody){SmtpClientsmtpClientNoSend=newSmtpClient();awaitsmtpClientNoSend.SendMailAsync(mailMessage);}来自Controller的调用:

c# - 在 Using 语句中从 DataLayer 返回 DataReader

我们有很多数据层代码都遵循这种非常普遍的模式:publicDataTableGetSomeData(stringfilter){stringsql="SELECT*FROM[SomeTable]WHERESomeColumn=@Filter";DataTableresult=newDataTable();using(SqlConnectioncn=newSqlConnection(GetConnectionString()))using(SqlCommandcmd=newSqlCommand(sql,cn)){cmd.Parameters.Add("@Filter",SqlDbType

c# - 是否所有一次性对象都在 using block 中实例化?

这是我过去多次问自己的问题,因为我嵌套了using语句5深。阅读docs并且没有发现任何关于block内实例化的其他一次性用品的提及,我认为这是一个很好的SO文件Q。考虑一下:using(varconn=newSqlConnection()){varconn2=newSqlConnection();}//isconn2disposed? 最佳答案 不,他们不是。只有在using子句中明确列出的变量集才会被自动释放。 关于c#-是否所有一次性对象都在usingblock中实例化?,我们在S

c# - 跨线程操作无效(How to access WinForm elements from another module events?)

我有一个带有串行端口信号事件的模块serialPort.DataReceived.AddHandler(SerialDataReceivedEventHandler(DataReceived));DataReceived在哪里letDataReceivedab=rxstringProcessData正在调用WinForms方法letProcessData(a,b)=dataProcessor.Invoke(a,b)|>ignore这是privatevoidProcessData(objectsender,EventArgse){byte[]m=Core.ncon.ArrayRead;s

c# -/平台 :anycpu32bitpreferred is not a valid setting for option/target:library or/target:module

我创建了一个Windows服务项目,后来决定将其输出类型更改为类库,这样我就可以将服务类包含在另一个项目中,该项目将创建要作为服务安装的.exe。但是现在,当我尝试构建第一个项目时,它失败并出现错误:/platform:anycpu32bitpreferredisnotavalidsettingforoption/target:libraryor/target:module我该如何解决这个问题? 最佳答案 尝试卸载项目(在解决方案资源管理器中右键单击)编辑.csproj(右键单击解决方案资源管理器)删除true重新加载项目。

c# - 返回用于在 using C# 中使用的变量

我在using语句中返回我在using语句中创建的变量(听起来很有趣):publicDataTablefoo(){using(DataTableproperties=newDataTable()){//dosomethingreturnproperties;}}这会Dispose属性变量吗??这样做之后我仍然收到这个警告:Warning34CA2000:Microsoft.Reliability:Inmethod'test.test',callSystem.IDisposable.Disposeonobject'properties'beforeallreferencestoitare