Tag: .net

从汇编中读取嵌入文件

我必须将配置文件的路径传递给框架方法(Gurok SmartInspect)。 配置文件是程序集的嵌入式资源。 目前,我从程序集中读取文件并将其存储在外部,然后传递pathName。 有没有更好/更简单的方法来实现这个目标,而不复制文件? private static void ConfigLogger() { const string embeddedFileName = “xxx.SmartInspect.properties”; const string configFileName = “SmartInspect.properties”; ExtractFileFromAssembly(embeddedFileName, configFileName); SiAuto.Si.LoadConfiguration(configFileName); } private static void ExtractFileFromAssembly(string assemblyFileName, string configFileName) { using (Stream s = Assembly.GetExecutingAssembly().GetManifestResourceStream(assemblyFileName) ) { byte[] buffer = new byte[s.Length]; int read = s.Read(buffer, 0, (int)s.Length); using (FileStream fs = new […]

将字节从sql server渲染到图像控件?

标记: 代码隐藏: public void ProcessRequest(HttpContext context) { //write your handler implementation here. string username = Convert.ToString(context.Request.QueryString[“username”]); if (username != null) { DataSet ds = new DataSet(); SqlDataAdapter da = new SqlDataAdapter(); byte[] arrContent; DataRow dr; string strSql; strSql = “Select Image from GalleryImages where username = ‘” + username + “‘”; da = new SqlDataAdapter(strSql, […]

能够在WCF中将主要对象从客户端传送到服务端

在WCF中,在客户端,用户将被认证,他的角色/权限将存储在客户端的Principal / Identity对象中。 经过身份validation后,用户应该只能在某个角色中调用服务方法。 为此,我需要将客户端Principal / Identity对象传输到服务端。 但是一旦我到达服务端,主要对象是Windows Principal,Identity是Windows Identity。 这不允许我检查是否应该根据客户端凭据调用服务方法。 是否可以将我的主体和身份对象从客户端传输到服务器端? 我想将我的主要对象(Generic Principal)传输到服务器端。 可能吗? 请帮忙。 之前我发过类似的问题如下: 将客户端定制的Principal对象转移到WCF服务端 我试图通过答案,但我无法inheritance我的主要对象。 这是细节。 在客户端,我的Principal对象和标识对象在调试期间在立即窗口中如下所示: System.Threading.Thread.CurrentPrincipal {System.Security.Principal.GenericPrincipal} [System.Security.Principal.GenericPrincipal]:{System.Security.Principal.GenericPrincipal} Identity:{System.Security.Principal.GenericIdentity} System.Threading。 Thread.CurrentPrincipal.Identity {System.Security.Principal.GenericIdentity} [System.Security.Principal.GenericIdentity]:{System.Security.Principal.GenericIdentity} AuthenticationType:“”IsAuthenticated:false名称:“” 在服务器端,我的主要对象和标识如下所示: System.Threading.Thread.CurrentPrincipal {System.Security.Principal.WindowsPrincipal} [System.Security.Principal.WindowsPrincipal]:{System.Security.Principal.WindowsPrincipal} Identity:{System.Security.Principal.WindowsIdentity} {System.Security .Principal.WindowsIdentity} [System.Security.Principal.WindowsIdentity]:{System.Security.Principal.WindowsIdentity} AuthenticationType:“NTLM”IsAuthenticated:true Name:“MyDomain \ MyLoginID” 我的WCF客户端如下所示 客户代码: namespace ConsoleApplication1 { class Program { static void Main(string[] args) { […]

英语桌面C#.net应用程序中的阿拉伯语本地化

我正在构建一个企业C#.net应用程序,要求是将有阿拉伯语和英语版本。 客户可以选择2个选项,可以将英语和阿拉伯语一起用于标签和说明,也可以在开始时使用英语和阿拉伯语进行combobox选择并继续使用该语言。 我想节省我的时间,并希望我可以建立一个英文版本,阿拉伯语必须自动翻译。 提前致谢。

充分利用.NET任务并行库

问题1。 使用Parallel.For和Parallel.ForEach更适合处理有序或无序的任务吗? 我问的原因是我最近更新了一个串行循环,其中一个StringBuilder用于根据各种参数生成一个SQL语句。 结果是,与使用标准foreach循环相比,SQL有点混乱(到了包含语法错误的程度),因此我的直觉是TPL不适合执行数据必须出现在特别的顺序。 问题2。 TPL是否自动使用多核架构,我必须在执行前配置任何内容吗? 我提出这个问题的原因与我提出的有关TPL操作性能分析的问题有关。 对这个问题的回答使我明白TPL并不总是比标准串行循环更有效,因为应用程序可能无法访问多个内核,因此创建额外线程和循环的开销会导致性能下降到标准的串行循环。

Winforms DataGridViewresize问题

我不是100%肯定我应该如何说出这个问题,但我会尽我所能。 我有一个PointCtrlForm,在TableLayoutPanel中有一个DataGridView。 DataGridView作为Fill停靠在表中。 PointCtrlForm停靠在另一个设置为MDIParent的窗口,并将dockstyle属性设置为Fill。 正确调整主窗口的大小可以调整PointCtrlForm的大小,然后也可以调整DataGridView的大小。 好吧,至少“一半”的resize正常。 扩大主窗口也会扩大datagridview,这是我的预期,但如果我将主窗口缩小到某个点,DataGridView会停止收缩并隐藏列而不显示滚动条。 我已检查所有列都没有启用Frozen属性,检查datagridview和子窗口是否已正确停靠,并检查scrollbars属性是否设置为两者。 编辑:AutoSizeColumnsMode也填充。 我将在这里发布Designer.cs的内容。 我很感激任何指导。 namespace DDCUI { partial class PointCtrlForm { /// /// Required designer variable. /// private System.ComponentModel.IContainer components = null; /// /// Clean up any resources being used. /// /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { if […]

在DetailsView的TemplateField中查找用户控件

我有一个我正在发布的DetailsView – 其中包含一个UserControl。 我在回发数据中遇到了一些困难。 举个例子: Some text here 当我回发时,我会假设我会做这样的事情: MyUserControlType ucUserControl = dvDetailsView.FindControl(“ucUserControl”) as MyUserControlType; 但这没有发现。 事实上,我甚至无法通过在QuickWatch中走动来找到这个孩子…… 我需要做些什么才能找到这个东西? 编辑:事实certificate我的usercontrol id正在改变 – 但为什么? 我在插入和编辑模板上都有相同的ID,但是注释掉它没有任何区别。

Ionic.Zip库无法提取.rar文件C#

我试图使用.net zip库(Ionic.Zip.dll)提取.rar文件。 我在执行以下代码时遇到错误“ 无法读取为zipfile ”; using (ZipFile zip1 = ZipFile.Read(“E:\\APPS\\package.rar”)){ } 我知道错误是自解释的,但Ionic.Zip的文档说它可以用来提取.rar文件。 有任何想法吗?

.net后面的代码表单

我想在后面的代码中创建一个post。 我有简单的htmlpost正在工作但是当我尝试使它成为WebRequest我无法使它工作。 在此先感谢您的时间。 这是工作> Untitled Page Mert1231058213.456.654.456asdsa123Auth 4522115422659661011312310181 12345678912 这不起作用> String ali = “Mert123xxxx213asdsa” + “123Auth12345678912345670113123” + “10xx112345678912”; WebRequest req = WebRequest.Create(“http://www.pay-pos.com/test.php?datafromuser=” + ali); req.Credentials = CredentialCache.DefaultCredentials; req.Method = “POST”; HttpWebResponse loWebResponse = (HttpWebResponse)req.GetResponse(); Encoding enc = Encoding.GetEncoding(1254); StreamReader loResponseStream = new StreamReader(loWebResponse.GetResponseStream(), enc); string lcHtml = loResponseStream.ReadToEnd(); loWebResponse.Close(); loResponseStream.Close(); 编辑:实验1 String postData = “Name=Mert” […]

Microsoft.Office.Interop.Excel或EPPlus用于读取大量(或不是)Excel文件

我写了一个代码来从Excel文件中读取一列。 我在这上面使用Microsoft.Office.Interop.Excel,首先读取整个Range,然后在System.Array中写入,然后我用System.Array值做一些操作,最后我将它转换为List,因为我填充了ListBox元素。 这是代码(仅相关部分): private List bd = new List(); private static System.Array objRowAValues; private List bl = new List(); private static System.Array objRowBValues; private List cm = new List(); private static System.Array objRowCValues; private List pl = new List(); private List bdCleanList; private static Microsoft.Office.Interop.Excel.Application appExcel; Excel.Application xlApp; Excel.Workbook xlWorkBook; Excel.Worksheet xlWorkSheet; Excel.Range rngARowLast, rngBRowLast, […]