Search Results

Search found 15 results on 1 pages for 'schlawiener'.

Page 1/1 | 1 

  • Change Windows Service Priority

    - by SchlaWiener
    I have a windows service that needs to run with High Priority. At the end of the day I want to use this script to modify the priority after service startup: Const HIGH = 256 strComputer = "." strProcess = "BntCapi2.exe" Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colProcesses = objWMIService.ExecQuery _ ("Select * from Win32_Process Where Name = '" & strProcess & "'") For Each objProcess in colProcesses objProcess.SetPriority(HIGH) Next But currently I am not able to change the priority, even with the taskmanger. The taskmananger throws an "Access Denied" error, but I am logged on as administrator and I changed the user account of the service to administrator, too. I still get the "access denied" message when trying to change the priority. Any ideas what permission I need to do that?

    Read the article

  • Web Service Exception Handling

    - by SchlaWiener
    I have a Winforms app that consumes a C# Webservice. If the WebService throws an Exception my Client app always get's a SoapException instead of the "real" Exception. Here's a demo: [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.ComponentModel.ToolboxItem(false)] public class Service1 : System.Web.Services.WebService { [WebMethod] public string HelloWorld() { throw new IndexOutOfRangeException("just a demo exception"); } } Now, on the client side, I want to be able to handle different exceptions in a different way. try { ServiceReference1.Service1SoapClient client = new ServiceReference1.Service1SoapClient(); Button1.Text = client.HelloWorld(); } catch (IndexOutOfRangeException ex) { // I know how to handle IndexOutOfRangeException // but this block is never reached } catch (MyOwnException ex) { // I know how to handle MyOwnException // but this block is never reached } catch (System.ServiceModel.FaultException ex) { // I always end in this block } But that does not work because I always get a "System.ServiceModel.FaultException" and I can only figure out the "real" exception by parsing the Exception's message property: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.IndexOutOfRangeException: just a demo\n at SoapExceptionTest.Service1.Service1.HelloWorld() in ... --- End of inner exception stack trace --- Is there a way to make this work somehow?

    Read the article

  • datagridview apply cellstyle to cells

    - by SchlaWiener
    I used this example to create a DateTime column for a DataGridView in my winforms app. http://msdn.microsoft.com/en-us/library/7tas5c80.aspx I can see the new column in the Windows Forms Designer and add it to an existing DataGridView. However, I want to be able to change the display format when I change the "DefaultCellStyle" within the designer. The designer generated code looks like this: DataGridViewCellStyle1.Format = "t" DataGridViewCellStyle1.NullValue = Nothing Me.colDate.DefaultCellStyle = DataGridViewCellStyle1 Me.colDatum.Name = "colDate" Me.colDatum.Resizable = System.Windows.Forms.DataGridViewTriState.[False] Which is fine. But since the code of the DataGridViewCalendarCell does this in the constructor: Public Sub New() Me.Style.Format = "d" End Sub The format never changes to "t" (time format). I didn't find out how to apply the format from the owning column to I use this woraround atm: Public Overrides Function GetInheritedStyle _ (ByVal inheritedCellStyle As _ System.Windows.Forms.DataGridViewCellStyle, _ ByVal rowIndex As Integer, ByVal includeColors As Boolean) _ As System.Windows.Forms.DataGridViewCellStyle If Me.OwningColumn IsNot Nothing Then Me.Style.Format = Me.OwningColumn.DefaultCellStyle.Format End If Return MyBase.GetInheritedStyle(_ inheritedCellStyle, rowIndex, includeColors) End Function However, since this is just an hack I want to know which is the "how it should" be done way to apply the default cellstyle from a DataGridViewColumn to its cells. Any suggestions?

    Read the article

  • WinForms and ShowDialog problem.

    - by SchlaWiener
    I have a borderless WinForms app. The main window creates other forms (simple dialogs where I can click yes or no) with ShowDialog(). Every created dialog is not visible in the taskbar, my app has only one taskbar entry that focuses my app (and if a dialog is open that one is focused). If I use ALT+TAB to cycle to all open windows I only see one entry, too. However, If the dialog is created while my app doesn't have the focus (for example the user starts a long running task, starts to work on something else and while being in the background, my app shows a dialog "Task done...") and I want to go back to my app, things are getting strange. If I click on the taskbar to focus my app, the main window is focused (not the dialog). I can't use the main window (because there is still an open modal dialog). Windows 7 ALT-TAB preview shows the Dialog while taskbar mouseover preview shows the main window (In normal behavior both show the dialog in front of the main window). The only way to make my app usable again is to ALT-TAB to the entry and close the modal dialog. If I use ALT-TAB only the dialog is brought to the front and the main window is still in the background Is there a way to prevent that from happening? I know what to do, but most customers think the app crashed since the main window doesn't respond.

    Read the article

  • How to use Svn Version Task to set the Version of a vb project

    - by SchlaWiener
    I have a Visual Studio 2008 Solution where the main output exe is a VB.Net Winforms exe which has several VB.Net and C# dll's linked from the same solution. The whole solution is under version control with subversion. Now I want to automagically update by generated files with the current svn revision number. For this purpose I found this neat project: http://svnversiontasks.codeplex.com/ You also need the MSBuild.Communuity.Tasks for this to work. There was a msbuild example on how to update the rev number for every single project in your solution which I use: <Import Project="$(MSBuildExtensionsPath)\SvnTools.Targets\SvnTools.Tasks.VersionManagement.Tasks" /> <Target Name="build"> <CreateItem Include="../**/AssemblyInfo.vb;../**/AssemblyInfo.cs;../**/Properties/AssemblyInfo.cs"> <Output TaskParameter="Include" ItemName="AssemblyInfoFiles" /> </CreateItem> <CreateItem Include="../**/*.vdproj;*.vdproj"> <Output TaskParameter="Include" ItemName="DeploymentProjectFiles" /> </CreateItem> <UpdateVersion AssemblyInfoFiles="@(AssemblyInfoFiles)" DeploymentProjectFiles="@(DeploymentProjectFiles)" Format="yyyy.mm.dd.rev" /> <Exec Command="&quot;$(VS90COMNTOOLS)..\IDE\devenv&quot; ..\MyApp.sln /build" /> <RevertVersionChange AssemblyInfoFiles="@(AssemblyInfoFiles)" DeploymentProjectFiles="@(DeploymentProjectFiles)" /> </Target> I modified the original file to also include the AssemblyInfo.vb file and saved it as a msbuild.proj file. However if I execute msbuild from the console I see that the C# projects are updated (I can also confirm that from the properties of the output dll but my vb project remains unchanged: Reverting version number change: ../App1\AssemblyInfo.vb Updating version number (to rev 0) for file: ../App1\AssemblyInfo.vb D:\Source\MyApp\MyAppDeploy\MyAppDeploy.csproj : warning : Version attribute not found, file not updated. Reverting version number change: ../App2\Properties\AssemblyInfo.cs Updating version number (to rev 0) for file: ../App2\Properties\AssemblyInfo.cs Successfully updated file. Maybe the task does not support VB.Net. But maybe someone has a solution for this...

    Read the article

  • SubSonic: MySqlDataReader closes connection.

    - by SchlaWiener
    I am using SubSonic 2.1 and entcountered a problem while executing a Transaction with SharedDbConnectionScope and TransactionScope. The problem is that in the obj.Save() method I get an "The connection must be valid and open" exception I tracked down the problem to this line: // Loads a SubSonic ActiveRecord object User user = new User(User.Columns.Username, "John Doe"); in this Constructor of the User class a method "LoadParam" is called which eventually does if (rdr != null) rdr.Close(); It looks like the rdr.Close() implicitly closes my connection which is fine when using the AutomaticConnection. But during a transaction it is usally not a good idea to close the connection :-) My Question is if this is by design or if it's an error in the MySqlDataReader.

    Read the article

  • Disable Painting of the VScrollbar in a System.Windows.Forms.RichTextBox

    - by SchlaWiener
    I have a custom control inherited from RichTextBox. This control has the ability to "disable" rich text editing. I achive this by just setting the Rtf property to the text property during the TextChanged event. this is how my code looks like: private bool lockTextChanged; void RichTextBox_TextChanged(object sender, EventArgs e) { // prevent StackOverflowException if (lockTextChanged) return; // remember current position int rtbstart = rtb.SelectionStart; int len = rtb.SelectionLength; // prevent painting rtb.SuspendLayout(); // set the text property to remove the entire formatting. lockTextChanged = true; rtb.Text = rtb.Text; rtb.Select(rtbstart, len); lockTextChanged = false; rtb.ResumeLayout(true); } That worked well. However in a large text with like 200 lines the controls jitters (you see the first lines of text for the wink). To prevent that from happening I filter the WM_PAINT between SuspendLayout() and ResumeLayout() private bool layoutSuspended; public new void SuspendLayout() { layoutSuspended = true; base.SuspendLayout(); } public new void ResumeLayout() { layoutSuspended = false; base.ResumeLayout(); } public new void ResumeLayout(bool performLayout) { layoutSuspended = false; base.ResumeLayout(performLayout); } private const int WM_PAINT = 0x000F; protected override void WndProc(ref System.Windows.Forms.Message m) { if (!(m.Msg == WM_PAINT && layoutSuspended)) base.WndProc(ref m); } that did the trick, the RichTextBox isn't jittering anymoe. That's what I wanted to achive, except one thing: The scrollbar is still jittering everytime I type text to my control. Now my question: Does anyone have a clue for me how to prevent the scrollbar from redrawing during Suspend/Resume Layout?

    Read the article

  • How can I save a Outlook Message from Clipboard to a file?

    - by SchlaWiener
    If I select an Outlook message from my Inbox and copy it to the clipboard I can paste it as an *.msg file to the Desktop. Now I want to implement the same feature to my application. The Clipboard object contains the following elements: RenPrivateSourceFolder RenPrivateMessages RenPrivateItem FileGroupDescriptor FileGroupDescriptorW FileDrop FileNameW FileName FileContents Object Descriptor System.String UnicodeText Text FileGroupDescriptor contains a MemoryStream with the filename (Subject.msg) but I don't know how to create a copy from the outlook message from the Clipboard data, since none of the elements seem to contain the message itself. Any Suggestions?

    Read the article

  • Is there a way to optimize this update query?

    - by SchlaWiener
    I have a master table called "parent" and a related table called "childs" Now I run a query against the master table to update some values with the sum from the child table like this. UPDATE master m SET quantity1 = (SELECT SUM(quantity1) FROM childs c WHERE c.master_id = m.id), quantity2 = (SELECT SUM(quantity2) FROM childs c WHERE c.master_id = m.id), count = (SELECT COUNT(*) FROM childs c WHERE c.master_id = m.id) WHERE master_id = 666; Which works as expected but is not a good style because I basically make multiple SELECT querys on the same result. Is there a way to optimize that? (Making a query first and storing the values is not an option. I tried this: UPDATE master m SET (quantity1, quantity2, count) = ( SELECT SUM(quantity1), SUM(quantity2), COUNT(*) FROM childs c WHERE c.master_id = m.id ) WHERE master_id = 666; but that doesn't work.

    Read the article

  • How do I detect if a System.Windows.Forms.Label with AutoEllipsis is actually displaying ellipsis?

    - by SchlaWiener
    I have a Windows Forms Application where I display some client data in a Label. I have set label.AutoEllipsis = true. If the text is longer than the label, it looks like this: Some Text Some longe... // label.Text is actually "Some longer Text" // Full text is displayed in a tooltip which is what I want. But now I want to know if the label makes use of the AutoEllipsis feature at runtime. How do I achive that?

    Read the article

  • Windows.Forms RichTextBox Control - Avoid inserting large data.

    - by SchlaWiener
    I have a Windows Form with a RichTextBox on it. The content of the RichTextBox is written to a database field that ist limited to 64k data. For my purpose that is way more than enough text to store. I have set the MaxLength property to avoid insertng more data than allowed. rtcControl.MaxLength = 65536 Howevery, that only restricts the amount of characters that so is allowed to put in the text. But with the formatting overhead from the Rtf I can type more text than I should be allowed to. It even get's worse if I insert a large image, which dosn't increase the TextLength at all but the Rtf Length grows quite a lot. At the moment I check the Length of the richttextboxes' Rtf property in the FormClosing event and display a message to the user if it's to large. However that is just a workaround because I want to disallow putting more data than allowed into the control (like in a textbox if you exceed the MaxLength property nothing is inserted into the control and you hear the default beep(). Any ideas how to achive this? I already tried: using a custom control which extends the richtextbox and shadows th Rtf property to intercept the insertation. But it seems it isn't executed if I add text. Even the TextChanged Event does not fire if I type smth. in the control.

    Read the article

  • Howto write a class where a property can be accessed without naming it.

    - by SchlaWiener
    I have a (dump) question regarding VB/C# I often use third party classes where I can access a child object with only specifying the id or key. Example: Instead of writing: DataRow row = GetAPopulatedDataRowSomeWhere(); Object result = row.Items[1]; // DataRow has no Items property Object result = row.Items["colName"]; // Also not possible I use this code to access the members: DataRow row = GetAPopulatedDataRowSomeWhere(); Object result = row[1]; Object result = row["colName"]; Can someone tell me how a class has to look like to support this syntax? My own class has a Dictionary that I want to access this way. MyClass["key"]; // <- that's what I want MyClass.SubItems["key"]; // <- that's how I use it now

    Read the article

  • How to find out where a thread lock happend?

    - by SchlaWiener
    One of our company's Windows Forms application had a strange problem for several month. The app worked very reliable for most of our customers but on some PC's (mostly with a wireless lan connection) the app sometimes just didn't respond anymore. (You click on the UI and windows ask you to wait or kill the app). I wasn't able to track down the problem for a long time but now I figured out what happend. The app had this line of code // don't blame me for this. Wasn't my code :D Control.CheckForIllegalCrossThreadCalls = false and used some background threads to modify the controls. No I found a way to reproduce the application stopping responding bug on my dev machine and tracked it down to a line where I actually used Invoke() to run a task in the main thread. Me.Invoke(MyDelegate, arg1, arg2) Obviously there was a thread lock somewhere. After removing the Control.CheckForIllegalCrossThreadCalls = false statement and refactoring the whole programm to use Invoke() if modifying a control from a background thread, the problem is (hopefully) gone. However, I am wondering if there is a way to find such bugs without debugging every line of code (Even if I break into debugger after the app stops responding I can't tell what happend last, because the IDE didn't jump to the Invoke() statement) In other words: If my apps hangs how can I figure out which line of code has been executed last? Maybe even on the customers PC. I know VS2010 offers some backwards debugging feature, maybe that would be a solution, but currently I am using VS2008.

    Read the article

  • DataGridView update datasource directly after changed Checkbox value

    - by SchlaWiener
    I have a System.Windows.Forms DataGridView that is bound to a List<MyObject>. The class MyObject contains a boolean property that is bound to DataGridViewCheckboxCell within the DataGridView. public class MyObject { public decimal DefaultValue {get; set; } public bool HasCustomValue {get;set; } public decimal CustomValue {get;set; } public decimal CurrentValue { get { return HasCustomValue ? CustomValue : DefaultValue; } } If I change the value of HasCustomValue another (readonly) property CurrentValue changes it's value, too. That is done by implementing the INotifyPropertyChanged event (I left that part in the source example for simplicity) If I changed HasCustomValue from outside the DataGridView, the column bound to CurrentValue gets updated immediately. Howevery, If the users enables/disables the checkbox, HasCustomValue is not changed in the underlying datasource unless he leaves the column by clicking with the mouse or pressing the TAB key. Is there a way to force the grid to update the datasource directly after changing a checkbox value? If I bind a Control Property I have the ability to set the DataSourceUpdateMode to Windows.Forms.DataSourceUpdateMode.OnPropertyChanged but I haven't found anything like that in a DataGridView

    Read the article

  • Get result from mysql orderd by IN clause

    - by SchlaWiener
    I have the following query SELECT * FROM invoice WHERE invoice_id IN (13, 15, 9, 27) My result is: invoice_id | invoice_number | ... ------------------------------------ 9 | 201006003 | 13 | 201006020 | 15 | 201006022 | 27 | 201006035 | which is the result set I want except that is ordered by the invoice_id (which is an autoincrement value). Now I want the result in the order I specified in my query (13, 15, ...). Is there a way to achive that? The background is that I have a DataTable bound to a DataGridView. The user can filter and sort the result but if he want's to print the result I don't use the DataTable for printing because it only contains the most important columns and instead I pull the whole records from the database and pass it to my printing control. I also tried to extend the existing DataTable with the missing results but that seems to slower than using the IN (...) query.

    Read the article

1