Click here to Skip to main content
15,885,981 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
im having huge problem with application i made for windows server 2008 R2.

The application works on .NET framework 3.5, and as far as i know windows server 2008 R2 contains such a framework.

Application itself is pretty massive, it is a server program for registering employees work time, by barcode scanner, then store it in .xml file, it also does update itself from update.xml file every few minutes.

To avoid having this application in focus all the time i used some methods to capture keypressed without focus on application.

So to the base of my problem, application is launching properly, it is also reading codes properly and identyfiing them, but application is apparently having prolem with "break:" and "return", and it simply does not launch one of my methods inside of my program. (it is simple static void method without any arguments)

Do i have to rewrite whole program to make it work without calling mehtods and all breaks and returns? Or what is the problem. This is quite important for me, deadline is more or less today. I could also add that this application is working perfectly fine on other pc's, and when im debuggin i on my pc, it also works as intented.

I won't post whole code here, it is simply too massive, but i can post parts of it to help you guys.

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Windows.Forms;
using System.Xml.Serialization;
using System.Xml;
using System.IO;
using System.Threading;
using System.Data;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
using Microsoft.Win32;
using System.Reflection;
using System.Security.AccessControl;

    static void Main()
    {
        var handle = GetConsoleWindow();
        ShowWindow(handle, SW_HIDE);
        appPath = Path.GetDirectoryName(Application.ExecutablePath);

        if (AutoStarter.IsAutoStartEnabled == false)
        {
            AutoStarter.SetAutoStart();
        }

        if (!Directory.Exists(appPath+"\\Raporty"))
        {
            Directory.CreateDirectory(appPath + "\\Raporty");
        }

        if (!File.Exists(appPath+"\\settings.jsn"))
        {
        utworzsetting();
        }
        sprawdzostatniawersje();
        uaktualnij();
        _hookID = SetHook(_proc);
        Application.Run();
        UnhookWindowsHookEx(_hookID);
     }





    private delegate IntPtr LowLevelKeyboardProc(
    int nCode, IntPtr wParam, IntPtr lParam);





    private static IntPtr HookCallback(
        int nCode, IntPtr wParam, IntPtr lParam)
    {
        if (nCode >= 0 && wParam == (IntPtr)WM_KEYDOWN)
        {
            int vkCode = Marshal.ReadInt32(lParam);

            switch (vkCode)
                {
                   case 48:
                     wiersz = "";
                     break;
                   case 49:
                     wiersz += "1";
                     break;
                   case 50:
                     wiersz += "2";
                     break;
                   case 51:
                     wiersz += "3";
                     break;
                   case 52:
                     wiersz += "4";
                     break;
                   case 53:
                     wiersz += "5";
                     break;
                   case 54:
                     wiersz += "6";
                     break;
                   case 55:
                     wiersz += "7";
                     break;
                   case 56:
                     wiersz += "8";
                     break;
                   case 57:
                     wiersz += "9";
                     break;
                   case 13:
                     if (wiersz != null)



Few more Ifs after that and

C#
if (aktualneID != -1) // Jezeli ID znajduje sie bazie danych
      {
          // MySettings settings = MySettings.Load(appPath + "\\settings.jsn");
          if (settings.limit == true && lPracownik[aktualneID].Dni.Count != 0)
          {
              czymoze();
              if (niemoze == false)
              {
                  Console.WriteLine("z limitem");
                  asdf();
                  Console.WriteLine("nie wywolalem metody");
              }
          }
          else
          {
              Console.WriteLine("bez limitu");
              asdf();
              Console.WriteLine("nie wywolalem metody");
          }
      }
  }
         wiersz = "";
         zapiszbaze();
  break;
default:
  break;




This is where is the problem, application goes to this moment "Console.WriteLine("bez limitu");" and thats it, it doesn't launch "asdf" method, it also doesn't go for wiersz = "";

I would appricaite any help, if u have any more questions, wants me to specify some things just tell.

PS. Im using VS 2010 Express, if u think that u can help me, i could send u entire solution.
Posted
Comments
Philip Stuyck 3-Sep-12 7:55am    
Isn't there some kind of exception being thrown by the application ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900