public static void Trace(E_TraceMessageType type, String str)
        {
            if (m_hWnd == null)
            {
                return;
            }

            StackTrace trace = new StackTrace();
            StackFrame frame = trace.GetFrame(2);

            System.Reflection.MethodBase method = frame.GetMethod();
            String methodName = method.Name;
            String file       = frame.GetFileName();
            int    lineNumber = frame.GetFileLineNumber();


            byte[]         cArr = System.Text.Encoding.Default.GetBytes(str);
            COPYDATASTRUCT myCD;

            myCD.dwData = (IntPtr)500;
            int size = 4 * 3 + str.Length + 1 + methodName.Length + 1;                  //4*3 4bytes per size + type + lineNum

            myCD.cbData = size;

            byte[] strSize    = BitConverter.GetBytes(size);
            byte[] strType    = BitConverter.GetBytes((int)type);
            byte[] strLineNum = BitConverter.GetBytes(lineNumber);

            String strTmp = System.Text.ASCIIEncoding.ASCII.GetString(strSize);

            strTmp += System.Text.ASCIIEncoding.ASCII.GetString(strType);
            strTmp += System.Text.ASCIIEncoding.ASCII.GetString(strLineNum);

            byte[] info = System.Text.Encoding.ASCII.GetBytes(str);
            strTmp += System.Text.ASCIIEncoding.ASCII.GetString(info);

            byte[] zero = { 0 };
            strTmp += System.Text.ASCIIEncoding.ASCII.GetString(zero);                  //0

            info    = System.Text.Encoding.ASCII.GetBytes(methodName);
            strTmp += System.Text.ASCIIEncoding.ASCII.GetString(info);

            strTmp += System.Text.ASCIIEncoding.ASCII.GetString(zero); //0

            myCD.lpData = strTmp;                                      //

            try
            {
                SendMessage(m_hWnd, WM_COPYDATA, 0, ref myCD);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #2
0
		public static void Trace(E_TraceMessageType type, String str)
		{
			if (m_hWnd == null)
				return;

			StackTrace trace = new StackTrace();
			StackFrame frame = trace.GetFrame(2);
			System.Reflection.MethodBase method = frame.GetMethod();
			String methodName = method.Name;
			String file = frame.GetFileName();
			int lineNumber = frame.GetFileLineNumber();


			byte[] cArr = System.Text.Encoding.Default.GetBytes(str);
			COPYDATASTRUCT myCD;
			myCD.dwData = (IntPtr)500;
			int size = 4 * 3 + str.Length + 1 + methodName.Length + 1;	//4*3 4bytes per size + type + lineNum
			myCD.cbData = size;

			byte[] strSize = BitConverter.GetBytes(size);
			byte[] strType = BitConverter.GetBytes((int)type);
			byte[] strLineNum = BitConverter.GetBytes(lineNumber);

			String strTmp = System.Text.ASCIIEncoding.ASCII.GetString(strSize);
			strTmp += System.Text.ASCIIEncoding.ASCII.GetString(strType);
			strTmp += System.Text.ASCIIEncoding.ASCII.GetString(strLineNum);

			byte[] info = System.Text.Encoding.ASCII.GetBytes(str);
			strTmp += System.Text.ASCIIEncoding.ASCII.GetString(info);

			byte[] zero = { 0 };
			strTmp += System.Text.ASCIIEncoding.ASCII.GetString(zero);	//0

			info = System.Text.Encoding.ASCII.GetBytes(methodName);
			strTmp += System.Text.ASCIIEncoding.ASCII.GetString(info);

			strTmp += System.Text.ASCIIEncoding.ASCII.GetString(zero);	//0

			myCD.lpData = strTmp;//

			try
			{
				SendMessage(m_hWnd, WM_COPYDATA, 0, ref myCD);
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}