随笔分类 - .Net
摘要:public enum WindowsMessages: int {WM_NULL = 0x0000,WM_CREATE = 0x0001,WM_DESTROY = 0x0002,WM_MOVE = 0x0003,WM_SIZE = 0x0005,WM_ACTIVATE = 0x0006,WM_SETFOCUS = 0x0007,WM_KILLFOCUS = 0x0008,WM_ENABLE = 0x000A,WM_SETREDRAW = 0x000B,WM_SETTEXT = 0x000C,WM_GETTEXT = 0x000D,WM_GETTEXTLENGTH = 0x000E,WM_PA
阅读全文
摘要:最近在开发一个.Net程序,其中涉及到对com组件的调用,在调用完以后如果使用一些小的测试程序继续运行,一切正常,但是在使用带有GUI的form程序继续执行时,总是出现以下异常Exception: System.ArithmeticExceptionMessage: 算术运算中发生溢出或下溢。Source: System.Drawing at System.Drawing.Font.Initialize(FontFamily family, Single emSize, FontStyle style, GraphicsUnit unit, Byte gdiCharSet, Boolean g
阅读全文
摘要:配置文件内容如下:<?xml version="1.0" encoding="utf-8" ?><configuration> <configSections> <section name="mySection" type="System.Configuration.NameValueSectionHandler"/> <section name="mySingleTagSection" type="System.Configura
阅读全文
摘要:默认情况下,控件不支持透明背景色。但是,通过使用构造函数中的 Control.SetStyle 方法,可以让控件拥有不透明、透明或半透明的背景色。Control 类的 SetStyle 方法用于为控件设置特定的样式首选项,并可用来启用或禁用对透明背景色的支持。使控件拥有透明背景色 在控件的代码编辑器中找到构造函数。 在构造函数中调用窗体的 SetStyle。 SetStyle(ControlStyles.SupportsTransparentBackColor, true);这将使控件能够支持透明背景色。 在步骤 1 中添加的代码行下再添加下面的代码行。这将把控件的 BackColor 设置为
阅读全文
摘要:使用log4net-1.2.0-beta8在项目的AssemblyInfo.cs文件中设置[assembly: log4net.Config.DOMConfiguratorAttribute(Watch=true)]添加并编辑项目配置文件(默认为App.config),内容如下:<?xml version="1.0" encoding="utf-8" ?><configuration><configSections><section name="log4net" type="log4
阅读全文
摘要:使用C#在应用程序间发送消息作者:kongxx首先建立两个C#应用程序项目。第一个项目包含一个Windows Form(Form1),在Form1上有一个Button和一个TextBox。第二个项目包含一个Windows Form(Form1),在Form1上有两个Button,分别用来测试第一个应用程序中Button的Click事件和修改第一个应用程序中TextBox的值。第一个应用程序中Form的代码如下:using System;using System.Drawing;using System.Collections;using System.ComponentModel;using
阅读全文
摘要:代码如下: using System;using System.Reflection;using System.Reflection.Emit ; public class TestReflection {private String file = @"TestReflection.exe"; static void Main(String[] args) {TestReflection test = new TestReflection();test.DisplayModules();test.DisplayTypes();test.DisplayMethods();te
阅读全文
摘要:使用NUnit进行DotNet程序测试 作者:kongxx 介绍 NUnit是目前比较流行的.Net平台的测试工具,以下就简单介绍一下他的开发。 准备 要使用NUnit,首先要确保您的机器上有NUnit的开发包,您可以从http://www.nunit.org/ 地方获取并安装(目前版本是NUnit v2.1.91)。正确安装后会在开始菜单下添加一个NUnit 2.2项目。 属性说明 在开始写例子之前,先把NUnit的属性说明一下: TestFixture (NUnit2.0) 标识当前类是一个包含测试方法的类。 注意:这个类必须有一个默认的构造方法,并且也必须声明成Public。 例如 ..
阅读全文
摘要:JBoss开发Web Service作者:kongxx配置使用JBoss版本3.2.3。JBoss.Net是用来提供Web Service的模块,建立在Apache的Axis项目之上。通常我们使用的“default”server中不包括JBoss.Net服务,而是包含在“all”server中。因此如果需要使用Web Service则需要使用“all”server,或者新建一个server来提供Web Service。在$JBOSS_HOME/server/下新建一个目录(如:kongxx),然后复制$JBOSS_HOME/all下所有文件到kongxx下,使用一下命令启动JBoss:run
阅读全文
摘要://The Server using System;using System.IO;using System.Net;using System.Net.Sockets;using System.Text; namespace SocketTest{public class Server3{public Server3(){}public void run() {string data;IPEndPoint ipep = new IPEndPoint(IPAddress.Any, 9050);Socket newsock = new Socket(AddressFamily.InterNetwo
阅读全文
摘要:using System;using System.Text;using System.Runtime.InteropServices;namespace DevInfo{??? class DeviceInfo??? {??????? public const int DIGCF_PRESENT??? = (0x00000002);??????? public const int MAX_DEV_LEN = 1000;??????? public const int SPDRP_FRIENDLYNAME = (0x0000000C);? ????????? // FriendlyName (
阅读全文
摘要:using System;using System.Runtime.InteropServices;using System.Text;namespace DevClasses{/// /// Summary description for Class./// class DeviceClasses{? /// ? /// The main entry point for the application.? /// ? public const int MAX_NAME_PORTS=7;? public const int RegDisposition_OpenExisting=(0x0000
阅读全文
摘要://取CPU编号 private String GetCpuID() {ManagementClass mc = new ManagementClass("Win32_Processor");ManagementObjectCollection moc = mc.GetInstances(); String strCpuID = null ;foreach( ManagementObject mo in moc ) {strCpuID = mo.Properties["ProcessorId"].Value.ToString();break; }retu
阅读全文