.NET Windows窗体应用程序更新自身的最佳方法是什么?

我使用自行开发的系统,应用程序通过Web服务自行更新。 但是,我似乎记得在最初的.NET销售宣传中有关自动更新组件的东西,这些组件是.NET的内置function。 有一个应用程序更新本身和/或它使用的程序集的最佳实践是什么?

Microsoft Enterprise Library类型加载exception无法加载Microsoft.Practices.EnterpriseLibrary.Common.Configuration.EnterpriseLibraryContainer

我正在尝试整理朋友服务。 基本上,一旦我在构造函数中启动它就会出错。 这是代码片段。 public class DefaultCacheManager : ICacheManager { private readonly Microsoft.Practices.EnterpriseLibrary.Caching.ICacheManager _cacheManager; public DefaultCacheManager() { //Code blows here _cacheManager = CacheFactory.GetCacheManager(); } 我得到的错误如下。 未处理的exception:System.TypeInitializationException:’Test.TypeManagement’的类型初始值设定项引发exception。 —> Microsoft.Practices.Unity.ResolutionFailedException:依赖项的解析失败,type =“Test.DefaultCacheManager”,name =“CacheManager”。发生exception时:调用构造函数Test.DefaultCacheManager()。 例外情况是:TypeLoadException – 无法从程序集“Microsoft.Practices.EnterpriseLibrary.Common,Version = 6.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35”加载类型“Microsoft.Practices.EnterpriseLibrary.Common.Configuration.EnterpriseLibraryContainer”。 – – – – – – – – – – – – – – – – – […]

在浏览器中打开文件而不是下载它

我使用ssrs通过报表服务器使用ReportExecutionService.Render()生成一个resultStream字节数组,我目前使用以下代码为用户提供服务。 有没有办法可以使用这个相同的字节数组在新的浏览器窗口中自动打开报表,而不是进入保存/打开对话框? public void RenderReport (byte[] reportDigits, ReportItem reportItem) { HttpResponse response = HttpContext.Current.Response; response.Clear(); response.ContentType = reportItem.ReportMimeType; response.AddHeader(“Content-Disposition”, string.Format(“attachment; filename={0}”, reportItem.ExportName)); response.OutputStream.Write(reportDigits, 0, reportDigits.Length); response.End(); } 在过去,我使用了一个单独的ReportViewer.aspx页面,我先打开然后显示报告,但如果可能的话,我想在代码后面全部完成。 谢谢

如何解锁COM端口

我的应用程序必须在另一个应用程序之后工作。 第二个应用程序有一个错误,导致COM端口在特定情况下不能关闭。 我想在我的应用程序中以编程方式关闭所有COM端口,以确保报告的关闭端口没有错误。 如果我没有打开COM端口的对象,是否可能? 我需要一个关于.NET Framework,C#的解决方案。

是否有可能在.Net的编译时有条件地隐藏属性?

根据预处理程序指令,我想将类中的所有属性设置为EditorBrowsableAttribute.Never。 我考虑过创建一个从EditorBrowsableAttribute派生的自定义属性,但遗憾的是该类是密封的。 我已经看过ICustomTypeDescriptor,但在GetProperties方法中,我可以获取每个属性描述符,但属性集合是readonly。 有任何想法吗?

代码Behing更新web.config映射问题

我从后面的代码我需要更新我的web.config。 这在以前从来就不是问题,但是我最近收到了一个错误。 错误说“无法映射路径’/’。” 注释掉的线条是我尝试的不同变化。 //Configuration myWebConfig = WebConfigurationManager.OpenWebConfiguration(Server.MapPath(“~”)); //Configuration myWebConfig = WebConfigurationManager.OpenWebConfiguration(“~”); //Configuration myWebConfig = WebConfigurationManager.OpenWebConfiguration(null); Configuration myWebConfig = WebConfigurationManager.OpenWebConfiguration(“.”); // update pages theme RoleManagerSection section = (RoleManagerSection)myWebConfig.GetSection(“system.web/roleManager”); section.DefaultProvider = “SqlRoleManager”; section.Providers.Clear(); ProviderSettings providerSettings = new ProviderSettings(); providerSettings.Name = “SqlRoleManager”; providerSettings.Type = “System.Web.Security.SqlRoleProvider”; providerSettings.Parameters.Clear(); providerSettings.Parameters.Add(“connectionStringName”, “SimpleTickConnection”); providerSettings.Parameters.Add(“applicationName”, “TheaterSales”); section.Providers.Add(providerSettings); myWebConfig.Save();

C#和XPath – 如何查询

我有一个XML文件,它具有以下结构: … The Title 42 … … more page items … 我稍微了解一下XPath-Query并编写了以下代码: _xmlArticlesDocument = new XmlDocument(); _xmlArticlesDocument.Load(xmlArticlesFileName); 现在我想抓住具有给定id-Subelement的页面Element。 所以我写道: XmlNode node = _xmlArticlesDocument.DocumentElement.SelectSingleNode (“//mediawiki/page[id=” + id.ToString() + “]”); 但节点始终为空。 我尝试了几个查询,包括“page / id”,“page”,“/ page”,“// page”来获取任何内容 ,但node始终为null。 我通过快速检查检查了_xmlArticlesDocument变量,它包含具有预期结构的正确XML文件。 在我看来,我错过了一些非常基本的东西,但不知道是什么。 也许这里有人有想法? 谢谢,弗兰克

如何检索.NET运行时生成的所有已关闭generics类型的列表?

根据MSDN文档,.NET运行时将根据需要动态生成基于generics类型定义的封闭类型。 https://msdn.microsoft.com/en-us/library/f4a6ta2h.aspx 是否可以检索与运行时生成的闭合类型相对应的System.Type实例的集合?

SQLDependency + Service Broker

我正在使用SqlDependency在某些表中的数据发生更改时获取通知。 private void subscribeBroker() { using (var conn = new SqlConnection(connString)) { conn.Open(); var cmd = new SqlCommand(“SELECT text FROM dbo.Test”); cmd.Connection = conn; var dependency = new SqlDependency(cmd); dependency.OnChange += dependency_OnChange; SqlDependency.Start(connString); cmd.ExecuteNonQuery(); } } void dependency_OnChange(object sender, SqlNotificationEventArgs e) { //Do something… subscribeBroker(); } 它有效,但我有一些问题。 1)我没有找到一种方法来获取哪些行被更改的信息。 我需要读取整个表中的所有数据,看看有什么不同。 有没有办法获得这些信息? (主要ID,或者其他)也许使用与SqlDependency不同的方法? 2)如果“某人”非常快速地改变数据怎么办? 某些更改可能不会被通知? (我关注通知和再次订阅时间之间的时间。 谢谢。

用于计算class级计数的部分语法

我需要计算正确的C#源文件中的类数。 我写了下面的语法: grammar CSharpClassGrammar; options { language=CSharp2; } @parser::namespace { CSharpClassGrammar.Generated } @lexer::namespace { CSharpClassGrammar.Generated } @header { using System; using System.Collections.Generic; } @members { private List _classCollector = new List(); public List ClassCollector { get { return _classCollector; } } } /*—————————————————————— * PARSER RULES *——————————————————————*/ csfile : class_declaration* EOF ; class_declaration : (ACCESSLEVEL […]