|
Following from the responses I got yesterday, here and elsewhere, I have now managed to create an EventLog by using the System.Diagnostics.EventLogInstaller class in my Windows Service. I have overridden the Install method to write out a method to the EventLog saying that the service is being installed. This works.
However, when I attempt to call SourceExists while the service is running it throws a SecurityException that says "Requested registry access is not allowed". (The service is running in a restricted account, and I would prefer not to use impersonation because that would open up extra security holes that I'd rather not deal with)
If I try again, but without the check for SourceExists I get the same exception when I use WriteEntry().
Any help would be appreciated.
Cheers,
Andy.
|
|
|
|
|
Your going to have to give the account the rights it needs. Either through impersonation or by increasing the rights of the account the service runs under.
How is this user account being restricted? Group Policy? Are there any other services/users using this account?
RageInTheMachine9532
"...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
At the moment the account is based on a standard user. We want to restrict it as much as possible for security so it should only be able to run the service, access two directories and their subdirectoris where it gets and puts files, access to SQL Server and it must be able to write to the EventLog. The account will be used for nothing else. Essentially, it exists to do one job and one job only.
I cannot believe that it requires SYSTEM privileges to write to a custom log. I could understand if the situation was: creating a custom log and telling it that only users of a specific account or role are permitted to write to it.
|
|
|
|
|
It doesn't require SYSTEM priv's. Is this user account a member of any of the local User's groups?. The 'User' group is probably the minimum it needs to do this. If the user is not a member of any groups, I could see this problem occuring. but, of course, I can't test it where I'm at right now...
RageInTheMachine9532
"...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hello,
I'm trying to delete a node in my Xml-file like this:
xml.Load(filePath);
string pad = "//exceptions[@company='RLS']";
XmlNode delete = xml.SelectSingleNode(pad);
xml.DocumentElement.RemoveChild(delete);
but then i get a mistake like "The node to be removed is not a child of this node."
What can i do to delete the node?
The xml-file looks like this
<pack version="1.0">
<com>
<main>
<tests>
<test name="programs">independent</test>
</tests>
</main>
<exceptions company="RLS">
<tests>
<extest name="settings">independent</extest>
</tests>
</exceptions>
</com>
</pack>
|
|
|
|
|
Try the following:
<br />
doc.Load(filePath);<br />
string pad = "//exceptions[@company='RLS']";<br />
XmlNode node = doc.SelectSingleNode(pad);<br />
node.ParentNode.RemoveChild(node);<br />
Good luck.
[Modified Version]
<br />
doc.Load(filePath);<br />
string pad = "//exceptions[@company='RLS']";<br />
XmlNode node = doc.SelectSingleNode(pad);<br />
if(node!=null)<br />
{<br />
XmlNode parent = node.ParentNode;<br />
if(parent!=null) parent.RemoveChild(node);<br />
}<br />
My articles and software tools
|
|
|
|
|
|
using sql2000 reporting services?
|
|
|
|
|
If it's in the toolbox for the report designer, yes. You should read the documentation. If Reporting Services allows you to use ASP.NET web controls, then you could add the ASP.NET CheckBox web control.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I have a panel, on the panel I have a lot of buttons.
The buttons has Images on them.
I want to create a button with "myButton.BackColor = Color.Transparent;" over the other buttons.
The problem is that I get transparency all the way back to the panel, if a button is between it doesn't show in the transparent button.
Anyone knows how I can solve this?
Thanks
Thomas
|
|
|
|
|
|
Not shore what you meen. Should I let the transparent button be an image of the rectangel it has?
The thing is that all the buttons on the panel is movable and resizeable.
I've created my own button class FCButton(derived from System.Windows.Forms.Button) with some extra functions ++. The transparent button shall have all of the functions as FCButton.
The transparent button shall be placed on other buttons, but still be a control of the panel, as the other buttons.
So is this somehow possible, I realy don't want to change all of the coding I've done.
Thanks
Thomas
|
|
|
|
|
You could mask the button using the PaintEventArgs.Graphics property and using the Graphics.Clip property to set a Region that will clip the actual image. There is several classes in the System.Drawing and child namespaces that can help create the Region for that image (which you should cache until the image changes). This ensures that the rest of the button is not visible at all - just the image. This is the technique that many application use, though many today that target Windows 2000 and newer use layered windows (which the transparency does), but that only works on Windows 2000 and newer.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Drawing Vertical Text.
The article below is taken from the .NET Framework SDK Documentation
[C#]
string text = "Vertical text";
FontFamily fontFamily = new FontFamily("Lucida Console");
Font font = new Font(fontFamily, 14, FontStyle.Regular, GraphicsUnit.Point);
PointF pointF = new PointF(40, 10);
StringFormat stringFormat = new StringFormat();
SolidBrush solidBrush = new SolidBrush(Color.FromArgb(255, 0, 0, 255));
stringFormat.FormatFlags = StringFormatFlags.DirectionVertical;
e.Graphics.DrawString(text, font, solidBrush, pointF, stringFormat);
The attached illustration shows the vertical text, with the word "Vertical" at the top, ant the word "text" below.
How does one code to have the words appesr in the reverse direction, "Vertical" at the bottom, "test" at th top.
Regards,
Fred.
Fred S. Parker
Email: fred@fsparker.com.au
|
|
|
|
|
You need to apply a transform or two to your Graphics object. You could use Graphics.RotateTransform to rotate your text, but you'll need to also use Graphics.TranslateTransform to translate the coordinates since the text is rotated on an axis (the beginning of the string). Unfortunately, I'm not too good with matrices when it comes to graphics, but those are the two methods you should look into in the .NET Framework SDK.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
You can use ScaleTransform to do horizontal or vertical flip.
To draw vertical text going the other way (vertically) do:
g.TranslateTransform(0, y*2+height)
g.ScaleTransform(1, -1)
you need the translate because scale will flip your text to negative values, so you're moving it by y*2 (one y would move it to 0), plus height of the object. y is the y coordinate of the text and height is the height. If you don't know the height, you'd have to use MesageString method.
If you have any other drawing code after the text, you have to either reset the transoformation or best way is to remember it and then set it back:
Matrix saveM = g.Transform;
g.TranslateTransform(0, y*2+height)
g.ScaleTransform(1, -1)
g.DrawString(...)
g.Transform = saveM;
If you use rotate, then your text will be flipped in both y and x, and depending on your needs you might want it or not.
|
|
|
|
|
Is there something like a MessageBox, that don't have MessageBoxButtons but is showing for 3-4 sec. before it closes
Thanks
Thomas
|
|
|
|
|
No.
You can probably customize a form to behave like that, though
"if you vote me down, I shall become more powerful than you can possibly imagine" - Michael P. Butler.
|
|
|
|
|
You might look around and see if anyone
has done a C# SplashScreen Control.
I'm new to C# but in Delphi the usual
scheme for a roll-your-own splash
screen is just to dynamically create
a Panel with a bunch of labels to
display your text.
Then use a timer to destroy it after
so many seconds.
|
|
|
|
|
Do you know what is faster? Use CodeCompiler.CompileAssemblyFromDom or CompileAssemblyFromCode ?
Thanx
Wizard_01
|
|
|
|
|
I don't have a specific answer, but...
The DOM doesn't support all the different syntax constructs (there are some interesting blog entries about this if you search Google), and setting up the DOM is a royal PITA--if you have source code, why set up all the DOM classes? In fact, I've found it easier to generate source code than work with the DOM. So, I think you have to take into account the overall performance issue.
Marc
Microsoft MVP, Visual C#
MyXaml
MyXaml Blog
|
|
|
|
|
I am making a custom Textbox control. What I did is I put a windows textbox under a usercontrol, so may base class is windows usercontrol. What I want is the event and properties of windows textbox which is under the usercontrol to show up as my base properties and events because what is happening is when I use my custom control the usercontrol properties and events are showing up so i cant access the event of my textbox and set properties on it. And is it also possible to hide the events and properties of usercontrol and instead the properties and event of textbox will show up when using this custom control?
Thank you very much.
|
|
|
|
|
Why do you want to put this into an UserControl?
It would be much easier to simply extend the TextBox class.
|
|
|
|
|
I did this because I like to create a custom control that is all-in-one, meaning I will be adding my custom dropdown box, add a date dropdown, add some buttons to it and anything that I can think of. My problem is if I compile my control then use it on VB.NET environment I can't access the event of my textbox becuase all event that is showing are usercontrol event(unless I make my own custom event which render the usercontrol event useless but still showing in my control's event). So what I want is when I run my VB project using my custom control then I press a key on my custom control what I want is the keypress event of the control to fire up. So is there any way to expose the events of the textbox instead of the event of the user control without making custom event just to send all the events of the textbox to the user? And is there anyway to hide some events in the usercontrol?
Thanks.
|
|
|
|
|
Yeah, I thought you do something like this. Just wanted to be sure
To expose events of your TextBox without making custom events, you could subscribe your Control to the TextBox events and inside the event handler raise the appropiate event of your Control. If you want to expose some specific TextBox events you will have to declare custom events.
<br />
class Custom : UserControl<br />
{<br />
TextBox textBox1;<br />
<br />
public Custom()<br />
{<br />
textBox1 = new TextBox();<br />
textBox.TextChanged += new System.EventHandler(Custom_TextChanged);<br />
}<br />
<br />
void Custom_TextChanged(object sender, System.EventArgs e)<br />
{<br />
this.OnTextChanged(EventArgs.Empty);<br />
}<br />
}<br />
To hide some events of your UserControl you have the redeclare them with a stricter access modifier like private or protected.
<br />
private new event System.EventHandler SizeChanged;<br />
Hope this helps!
|
|
|
|