c#-2.0

MaxConnections and App.config question

杀马特。学长 韩版系。学妹 提交于 2019-12-06 07:33:14
问题 I have a multipart downloader, and to get it working I'm using this app.config <?xml version="1.0"?> <configuration> <startup><supportedRuntime version="v2.0.50727"/></startup> <system.net> <connectionManagement> <add address="*" maxconnection="65000" /> </connectionManagement> </system.net> </configuration> How can I put that file into my executable or somehow set this param internally? 回答1: You can use: ServicePointManager.DefaultConnectionLimit = 65000; http://msdn.microsoft.com/en-us

C# Batch plot application (PrintServer & PrintQueue issues)

蓝咒 提交于 2019-12-06 05:27:24
问题 I have a problem that I need help with. For my current project I need to make a Batch Plot application. This application will have around ~2000 AutoCAD drawings that it will need to print. The application needs 5 printers, 1 for each format, going from A4 to A0. No problems yet so far. Now we all understand that we can not queue 2000 drawings simultaneously without some kind of trouble. I've did my research online and found methods to look at the current printer Queue. Using PrintServer and

Use to c# in html to perform if statement

耗尽温柔 提交于 2019-12-06 03:03:34
问题 I've previously seen answers on Stackoverflow that involve using 'the c# construct' to essentially perform an 'if' statement in the html of a asp.net page. So imagine i want to display Eval("option1") if its not null OR Eval("option2") if option 1 is null. How do i do this??? Hope that makes sense.... Many Thanks!!!! 回答1: You don't need if statement for it. Just use <%= Eval("option1") ?? Eval("option2") %> 回答2: Is this the "if" semantics you are looking for? <% if (condition == true) { %>

C#: XPath to select node with attribute containing a substring?

半腔热情 提交于 2019-12-05 23:00:01
Could I use XPath to select country node whose code containing UK? <country-list> <Country code="TW,UK,MY" /> <Country code="US,CA,MX" /> <Country code="IN,PR,VI,IR" /> <Country code="Others" /> </country-list> Thanks. Try the contains() XPath function. Something like: /Country[fn:contains(@code, "UK")] A quick Google search turns up details on XPath functions: http://www.w3schools.com/xpath/xpath_functions.asp RRaveen You need write it this way: /country-list/Country[contains(@code,'UK')] robert.oh. You could use Linq to XML - just as an idea Something like this: var countryElement = from

How make two way binding numericUpDown to member class

百般思念 提交于 2019-12-05 14:44:07
I need twoway binding configClass.RaMsize to numericUpDown. BindField(this.upDownRamSize, "Value", configClass, "RaMsize");//all right this.upDownRamSize.Value = 1213;// configClass.RaMsize - not change - it's bad! Method: public static void BindField(Control control, string propertyName, object dataSource, string dataMember) { Binding bd; for (int index = control.DataBindings.Count - 1; (index == 0); index--) { bd = control.DataBindings[index]; if (bd.PropertyName == propertyName) control.DataBindings.Remove(bd); } control.DataBindings.Add(propertyName, dataSource, dataMember); } I assumed

Web service variable shared for the lifetime of the webservice?

不打扰是莪最后的温柔 提交于 2019-12-05 12:21:07
How can I make a variable (object) available for the whole lifetime of the webservice? Static variable seem to work but is there an other way to do it? Static variables exist for the lifetime of the App Domain that contains them. In the case of a web service, this is usually the ASP.Net Worker Process. What that means is that when IIS decides to cycle the worker process, your static variable will be gone. This may be what you want, in which case it is probably a good choice. (Putting asside discussions of whether or not static variables are proper in a given context). Within the scope of a web

How to resolve the winforms error “A generic error occurred in GDI+. ”?

倖福魔咒の 提交于 2019-12-05 11:57:55
I am facing the following exception in my C#.net win forms application. A generic error occurred in GDI+. at System.Drawing.Graphics.CheckErrorStatus(Int32 status) at System.Drawing.Graphics.DrawRectangle(Pen pen, Int32 x, Int32 y, Int32 width, Int32 height) at WeifenLuo.WinFormsUI.Docking.DockWindow.OnPaint(PaintEventArgs e) at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs) at System.Windows.Forms.Control.WmPaint(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc

Getting a StringCollection out of AppSettings through the configuration manager

你说的曾经没有我的故事 提交于 2019-12-05 10:39:39
I am accessing my assembly's configuration like this: ExeConfigurationFileMap map = new ExeConfigurationFileMap(); map.ExeConfigFilename = Assembly.GetExecutingAssembly().Location + ".config"; Configuration conf = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None); AppSettingsSection appSettings = conf.AppSettings; My .config file contains a section like this <configSections> <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" > <section name=

How to select nodes where node name contains “mystring”

风格不统一 提交于 2019-12-05 08:30:47
I need to get XmlNodeList where node name contains "mystring" XML <?xml version="1.0" encoding="utf-8"?> <root> <node1> node1 value </node1> <node2_mystring> node2 value </node2_mystring> <node3> node3 value </node3> <node4_mystring> node 4 value </node4_mystring> </root> Desired output is <?xml version="1.0" encoding="utf-8"?> <root> <node2_mystring> node2 value </node2_mystring> <node4_mystring> node 4 value </node4_mystring> </root> I tried something like XmlNodeList mystringElements = xmlDocument.SelectNodes(@"//*[contains(name,'mystring')]"); But it returns zero node. What should I put in

set Enums using reflection

扶醉桌前 提交于 2019-12-05 08:28:25
How to set Enums using reflection, my class have enum : public enum LevelEnum { NONE, CRF, SRS, HLD, CDD, CRS }; and in runtime I want to set that enum to CDD for ex. How can I do it ? public class MyObject { public LevelEnum MyValue {get;set,}; } var obj = new MyObject(); obj.GetType().GetProperty("MyValue").SetValue(LevelEnum.CDD, null); Try use of class Enum LevelEnum s = (LevelEnum)Enum.Parse(typeof(LevelEnum), "CDD"); value = (LevelEnum)Enum.Parse(typeof(LevelEnum),"CDD"); So basically you just parse the string corresponding to the enum value that you wish to assign to the variable. This