|
am making a Windows service application using the C# .Net framework.
I have installed the setup and when I try to start my service from the Services in the Administrative tools in control panel, I get the following error:
JIT Debugging failed with the following error: Access is denied.
JIT Debugging was initiated by the user account 'NT AUTHORITY\LOCAL SERVICE'.
Please give me any clues how to debug the JIT error.
Thank you.
|
|
|
|
|
You need to grant the NT AUTHORITY\LOCAL SERVICE user debug privileges. That's actually a very bad idea, though. Anyone with debugging privileges can do quite a few things to your system that would go unchecked (like overwriting memory addresses without taking advantage of security holes). Instead, while debugging your service you should run it as you (which, presumably, already has debugging privileges).
To give NT AUTHORITY\LOCAL SERVICE debugging privileges or to make sure you have them (if you can debug, you have them), use the local security policy editor in Control Panel->Administrative Tools->Local Security Policy. Drill down to Local Policies->User Rights Assignment. Note that if you're in a domain, the domain administrator might have set these and taken away your ability to change them.
Again, giving NT AUTHORITY\LOCAL SERVICE debug privileges is a bad idea - it is a security hole. Just change the login credentials for your service to you for the time being to find the problem. Do run it as NT AUTHORITY\LOCAL SERVICE to make sure everything works once yo've figured out the problem, however.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
hi guys!
..eeeh only this, i can't run a c# app on a pc with win 2k but without .NET framework installed.
why this... ?
can i do something?
thanx!!
PD: sorry my english is so bad
|
|
|
|
|
jl_araya wrote:
can i do something?
Sure, you can. Install the framework.
jl_araya wrote:
why this... ?
Roughly spoken, your C# app contains no machine code and needs the Common Language Runtime which is part of the framework to execute.
I think you should read a bit in MSDN[^].
|
|
|
|
|
.Net IL simply put are instructions that no hardware processor will understand on its own. How do you expect it to run on a machine that has no idea how to handle it?
|
|
|
|
|
thanks, now i understand.
bye!
|
|
|
|
|
I'm writing a class and and app to test the class. My hope is that when I'm done, the class will be portable, and I can reuse it in other projects. I also want to learn the proper structure on how to do this.
In the Form in my main app, I have set a textBox that I want to use as feedback to the user on the processing that is done in the class. What is the best way to pass strings back to the form textbox from the class?
I tried to use an event, but couldn't quite make it work. Is this the correct way to go about this?
I also tried a public string that appeneded to the textbox in the set. it gave me some error about object reference.
Since I will be writing to the log at various points in the class, I think it should be a simple one line statement.
Any hints?
|
|
|
|
|
If you are talking about unit testing your class then I strongly recommend you check out nUnit http://www.nunit.org/[^]. This is a ready made tool for testing, and means that you won't need to put together a WinForms test harness. All you need to do is create an new testing assembly that calls in to your class and then nUnit picks it up. There is a quick start tutorial that comes with it that is really easy to follow.
There are lots of additional testing strategies that you can employ. One of the easiest is to use Debug.Assert statements throughout your code, especially in UI code which I find particularly hard to test. These debugging commands are stripped out in the release version of the code so they won't impact on the performance of production code, but for development they can show up problems quickly.
Does this help? Or have I just thrown your test strategy into confusion?
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
My Blog
|
|
|
|
|
I really haven't gotten into serious testing yet.
I'm just asking for the best practice for sending a string from a class back to the form that called the instance of the class.
My case is where I have a form with a text box, and I create an instance of a class to do some processing on an input file. I would like to send feedback and debug info back to the form to be displayed in a textbox.
How can I do that cleanly without having to explicitly know what object in the form I'm sending the data to?
Is an event the way to do this?
Thanks.
|
|
|
|
|
pidhead wrote:
My case is where I have a form with a text box, and I create an instance of a class to do some processing on an input file. I would like to send feedback and debug info back to the form to be displayed in a textbox.
I'm not sure that is really the best way to test the class. Even if you are not into "serious testing yet". Take a look at some of the classes available in the System.Diagnostics namespace and you'll find a number of features of .NET that help you test your code.
You can use Debug.WriteLine to send information to the OutputWindow in VS.NET which will provide a much more efficient solution, especially as you seem to want to get information out from within the class's code, rather than just checking return values.
I still recommend taking a look at nUnit because it does what you are trying to achieve in a more structured way. Also, it allows you to selectively choose which tests to run or you can run the tests over the whole system so you can check if any recent changes broke other code elsewhere you didn't expect to be affected (I common occurrance for all developers, and even more so if you are new to programming).
To get back to what you actually asked for:
pidhead wrote:
How can I do that cleanly without having to explicitly know what object in the form I'm sending the data to?
Is an event the way to do this?
You already knew the answer as your second question answers your first. Yes, you can use an event in this senario. But remember you won't be sending information directly to the object in the form, but to an event handling method that will receive the event and that will alter the control for you. After all, the TextBox or whatever knows nothing of your event.
Finally, (sorry, I'm going to get back on my writing-clean-code-for-the-situation-is-the-most-important-thing hobby-horse again) do you really want to load up your class with events that are only used for testing. What will happen to all these events being fired when you're done with testing? Okay, so they won't go anywhere but they will slow the code down, and encasing them in #ifdef #endif blocks so that you omit them when not testing is going to make the code almost unreadable.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
My Blog
|
|
|
|
|
Dear Sir and Madam
After I close MemoryStream, how to open it to read again?
MemoryStream m = new MemoryStream();
. . .
. . .
m.Close
How to open it to do the following?
m.Seek(0, SeekOrigin.Begin);
Thank You.
Sorry for bad English.
|
|
|
|
|
A memorystream is like a marriage; once you have closed the door on it, there is no going back.
my blog
|
|
|
|
|
hi all,
I want programmaticly retrieving a list of machine names of the other computers in my LAN ....
how can i do that plz..
ADEL K Khalil
|
|
|
|
|
This has been asked far too many times on this forum. Please search[^] the forums first before posting. Every forum has a "Search comments" link directly above the message board itself and you can even search multiple forums at once.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
in my program, at the constructor of the main driver class, it loads about 6 DLLs (managed) using the Assembly.LoadFile method and then invoking the needed
methods using reflections functions.
Anyway, when i want to quit the program, sometimes some of the dlls can not be accessed since "they are in use by another program". I've checked the Windows Task Manager and my process do not appear there... any ideas guys?
i thought maybe using Dispose procedure or a destructor. can anyone help me with deciding which road to take? and how?
10x
|
|
|
|
|
Don't know if this will help but I have started taking advantage of the "Using" keyword to automatically fire the dispose method. The feature is specific to C# as far as I know. You have to be sure the type you are using implements the IDisposable or it will throw a compile time error.
public void YourMethod()
{
using(MyObj m = new MyObj())
{
MyObj.DoWhatYouWant()
// Dispose() is called automatically for you when the
// Using block exits
}
}
Good luck and I hope it helps.
|
|
|
|
|
i extended textBox and set its styles to:
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.DoubleBuffer,true);
to avoid flickering, but now the text i enterd doesnt show in the textbox,
i noticed that ControlStyles.AllPaintingInWmPaint is the cause,
how can i overcome this problem and still avoid flickering?
|
|
|
|
|
First of all, the ControlStyles enumeration is attributed with the FlagsAttributE (and any enumeration in the .NET base class library that is plural always does, as should other libraries when the developers follow naming guidelines), so the three lines (resulting in 3 * 4 = 12 instructions) can be done in one line (4 instructions):
SetStyle(ControlStyles.UserPaint | ControlStyles.DoubleBuffer
| ControlStyles.AllPaintingInWmPaint, true); This is far more efficient.
Second, when you specify these parameters you must override OnPaint and paint the text yourself. The documentation for these UserPaint and <code.allpaintinginwmpaint< code=""> state this.
Third, the <code>TextBox's text is not painted by .NET. Almost every control in Windows Forms (in the .NET BCL) wraps the native common controls equivalent. You should not try to draw these yourself because they aren't not drawn by .NET, but by Windows itself.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi
Does someone know a fast method to get CRCs or Hashes of files, in order to compare two files?
thanks
----------------------
Instead of printing "No errors have been found", a compiler should rather print "None of your errors have been found", which would be, in most cases, true.
|
|
|
|
|
Try this[^]Knowlege Base article.
Paul Lyons, CCPL Certified Code Project Lurker
|
|
|
|
|
Check out the HashAlgorithm.ComputeHash() Method. Open a Stream on the file you want to input and this method will give you the hash.
Note that the HashAlgorithm Class is an abstract class. You probably want the derived class MD5CryptoServiceProvider. MD5 hashes are very reliable for your needs.
~L
|
|
|
|
|
I get the following message:
The type or namespace name 'Soap' does not exist in the class or namespace 'System.Runtime.Serialization.Formatters' (are you missing an assembly reference?)
On this line here:
using System.Runtime.Serialization.Formatters.Soap;
What am I missing or has something chnaged in .NET 1.1?
(I'm trying to use the BaseSerializable class in this article: http://codeproject.com/soap/soapseraialize.asp )
|
|
|
|
|
I think the answer is in your question:
ABean wrote:
(are you missing an assembly reference?)
According to the MSDN Help for System.Runtime.Serialization.Formatters.Soap.SoapFormatter Class[^] you need to reference the assembly System.Runtime.Serialization.Formatters.Soap (see the requirements section at the bottom of the page)
To add a reference to this assembly in your project right click the requirements node under the project in the solution explorer and select Add Reference... Find the reference to the above assembly and add it.
Does this help?
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
My Blog
|
|
|
|
|
I want to add textBoxes at run time into a groupbox (not on the form). How do I get points on the form and into the groupbox
And
How do I disable the right click menu got when right clicking in a TextBox.
(The cut, copy paste.. menu) .
pls help.
_____________________________________________________
Believe! Every thing has a purpose
|
|
|
|
|
To add controls to your groupbox call the Add or AddRange methods of its Controls property.
this.groupBox1.Controls.AddRange(new System.Windows.Forms.Control[] {this.textBox1});
|
|
|
|