草庐IT

start-using-html

全部标签

c# - 通过 using block 使用进程

这个问题在这里已经有了答案:关闭11年前。PossibleDuplicate:WhathappensifIdon'tcloseaSystem.Diagnostics.ProcessinmyC#consoleapp?由于System.Diagnostics.Process继承自实现IDisposable的Component,我是否应该始终创建一个Process使用usingblock?例如,这个...:using(varprocess=newProcess()){process.StartInfo.FileName="someprocess.exe";process.Start();pr

c# - 三重 DES : Specified key is a known weak key for 'TripleDES' and cannot be used

我正在使用.NET3.0类System.Security.Cryptography.MACTripleDES类来生成MAC值。不幸的是,我正在使用使用“1111111111111111”(十六进制)作为单一长度DESkey的硬件设备。System.Security.Cryptography库会对key进行完整性检查,如果您尝试使用加密强度较弱的key,则会返回异常。例如:byte[]key=newbyte[24];for(inti=0;i抛出异常System.Security.Cryptography.CryptographicException:Specifiedkeyisaknow

c# - "Data Source cannot be empty. Use :memory: to open an in-memory database"是什么意思?

我最近将我的SQLServer数据库转换为SQLite数据库。但是当我尝试使用.Open()打开我的SQLite时,它​​抛出了这个错误:DataSourcecannotbeempty.Use:memory:toopenanin-memorydatabase编辑:添加连接字符串:ConnectionString=@"DataSource=D:\XXX.db;Version=3";connection=newSQLiteConnection(connectionString);connection.Open();为什么我会得到这个?我将相同的SQLServer数据库转换为SQLCE和my

c# - Using block 中的异步

我在C#中有以下异步函数:privateasyncTaskCallDatabaseAsync(Func>execAsync){using(varconnection=newSqlConnection(_connectionString)){connection.Open();returnawaitexecAsync(connection);}}它允许执行任何异步函数execAsync,该函数将SQL连接作为参数并使用它来进行数据库调用,方法是提供连接对象并确保其正确关闭。然后从WebApiController中的操作调用此函数,如下所示:publicasyncTaskMyAction(

c# - 属性规范中奇怪的歧义(两个 using 指令)

背景在attributespecification,有时有两种有效的方法来编写应用的属性。例如,如果属性类的名称为HorseAttribute,您可以将该属性应用为[HorseAttribute]或只是[Horse]。歧义可以用@解决,例如[@Horse]。以下是一个有效的程序:usingSystem;usingAlpha;usingBeta;namespaceN{[Horse]classC{}}namespaceAlpha{//validnon-abstractattributetypewithaccessibleconstructorclassHorseAttribute:Attr

c# - ASP.NET MVC : Views using a model type that is loaded by MEF can't be found by the view engine

我正在尝试创建一个框架,以允许将Controller和View动态导入到MVC应用程序中。到目前为止,它是这样工作的:我正在使用.NET4、ASP.NETMVC3RC和RazorViewEngine每个项目都使用MEF导出和导入Controller-我将给定项目中的一组Controller和View称为“模块”BuildManager使用应用前启动方法和BuildManager.AddReferencedAssembly动态引用使用MEF发现的程序集。使用构建事件将二进制文件(来自导出项目)和View复制到目标项目的文件夹结构中使用自定义Controller工厂选择Controller

c# - 在 MVC 3 中,我无法让 @Html.DisplayFor 呈现格式化字符串

我希望这是一个非常简单的问题,尽管经过大量谷歌搜索后,我还是无法解决。我正在使用MVC3开发购物车网站,并使用代码优先EntityFramework。我发送的模型是一个Product对象列表,每个对象都包含这个属性:[Required(ErrorMessage="Thisisarequiredfield.")][DataType(DataType.Currency)][Range(1.00,500.00,ErrorMessage="Productscannotbefree.")][DisplayFormat(DataFormatString="{0:C}")][DisplayName(

c# - 在什么情况下 Process.Start() 方法会返回 false?

来自MSDN:Thereturnvaluetrueindicatesthatanewprocessresourcewasstarted.IftheprocessresourcespecifiedbytheFileNamememberoftheStartInfopropertyisalreadyrunningonthecomputer,noadditionalprocessresourceisstarted.Instead,therunningprocessresourceisreusedandfalseisreturned.尝试这样的事情:varinfo=newProcessStart

c# - The non-generic method cannot be used with type arguments in this context 是什么意思?

我有以下类和方法:publicclassUserManager:IDisposablewhereTUser:class,global::Microsoft.AspNet.Identity.IUserwhereTKey:global::System.IEquatable{publicvirtualTaskFindByIdAsync(TKeyuserId);和:privateApplicationUserManager_userManager;publicApplicationUserManagerUserManager{get{return_userManager??Request.Ge

c# - 从 CefSharp 网络浏览器获取 HTML 源代码

我正在使用aCefSharp.Wpf.ChromiumWebBrowser(版本47.0.3.0)加载网页。页面加载后的某个时刻,我想获取源代码。我打过:wb.GetBrowser().MainFrame.GetSourceAsync()但是它似乎并没有返回所有源代码(我相信这是因为有子框架)。如果我调用:wb.GetBrowser().MainFrame.ViewSource()我可以看到它列出了所有源代码(包括内部框架)。我想获得与ViewSource()相同的结果。请有人指出我正确的方向吗?更新–添加了代码示例注意:网络浏览器指向的地址也只能在10/03/2016之前有效。之后它