Search Results

Search found 4334 results on 174 pages for 'sender'.

Page 138/174 | < Previous Page | 134 135 136 137 138 139 140 141 142 143 144 145  | Next Page >

  • XmlDocument.Load() throws XmlSchemaValidationException

    - by Praetorian
    Hi, I'm trying to validate an XML document against a schema (which is embedded in my program as a resource). I got everything to work, so I tried to test for errors by adding a second sibling node in the XML at a location where the schema specifies maxOccurs="1". The problem is that my ValidationEventHandler is never getting called, also XmlDocument.Load() is throwing an XmlSchemaValidationException exception when I'd expected XmlDocument.Validate() to do that. This is the code I have: private void ValidateUserData( string xmlPath ) { var resInfo = Application.GetResourceStream( new Uri( @"MySchema.xsd", UriKind.Relative ) ); var schema = XmlSchema.Read( resInfo.Stream, SchemaValidationCallBack ); XmlSchemaSet schemaSet = new XmlSchemaSet(); schemaSet.Add( schema ); schemaSet.ValidationEventHandler += SchemaValidationCallBack; XmlReaderSettings settings = new XmlReaderSettings(); settings.Schemas = schemaSet; settings.ValidationType = ValidationType.Schema; XmlDocument doc = new XmlDocument(); using( XmlReader reader = XmlReader.Create( xmlPath, settings ) ) { doc.Load( reader ); // <-- This line throws an exception if XML is ill-formed reader.Close(); } doc.Validate( SchemaValidationCallBack );// <-- This is never reached } private void SchemaValidationCallBack( object sender, ValidationEventArgs e ) { Console.WriteLine( "SchemaValidationCallBack: " + e.Message ); } How do I get the callback to be called so I can handle validation errors? Thanks for your help!

    Read the article

  • Application.ProcessMessages hangs???

    - by X-Ray
    my single threaded delphi 2009 app (not quite yet complete) has started to have a problem with Application.ProcessMessages hanging. my app has a TTimer object that fires every 100 ms to poll an external device. i use Application.ProcessMessages to update the screen when something changes so the app is still responsive. one of these was in a grid OnMouseDown event. in there, it had an Application.ProcessMessages that essentially hung. removing that was no problem except that i soon discovered another Application.ProcessMessages that was also blocking. i think what may be happening to me is that the TTimer is--in the app mode i'm currently debugging--probably taking too long to complete. i have prevented the TTimer.OnTimer event hander from re-entering the same code (see below): procedure TfrmMeas.tmrCheckTimer(Sender: TObject); begin if m_CheckTimerBusy then exit; m_CheckTimerBusy:=true; try PollForAndShowMeasurements; finally m_CheckTimerBusy:=false; end; end; what places would it be a bad practice to call Application.ProcessMessages? OnPaint routines springs to mind as something that wouldn't make sense. any general recommendations? i am surprised to see this kind of problem arise at this point in the development!

    Read the article

  • (500) Internal Server Error with C# and Web Dev 2008 Express

    - by user32848
    The code below is generic, found in a variety of places, including a book I have. I have used it as a base for a working program in VS 2005. Now I've resurrected it with my current Visual Web Developer 2008 Express Edition and I seem to have problems connecting it to my default development server (I don't have IIS on my XP). The error is: (500) Internal Server Error. Is this saying what I thought it did (above) or something else, and how do I solve this problem? using System; using System.Collections; using System.Collections.Generic; using System.Configuration; using System.IO; using System.Net; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Text.RegularExpressions; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string strResult = ""; string url = "http://weather.unisys.com"; WebResponse objResponse; WebRequest objRequest; try { objRequest = System.Net.HttpWebRequest.Create(url); } catch { objRequest = System.Net.HttpWebRequest.Create("http://"+ url); } objResponse = objRequest.GetResponse(); using (StreamReader sr = new StreamReader(objResponse.GetResponseStream())) { strResult = sr.ReadToEnd(); sr.Close(); } } }

    Read the article

  • How to Create a Simple Dictation Pad in Delphi2009+Vista

    - by XBasic3000
    the code are not so complecated.. private { Private declarations } SpSharedRecoContext1 : TSpSharedRecoContext; fMyGrammar : ISpeechRecoGrammar; procedure SpSharedRecoContext1Recognition(ASender: TObject; StreamNumber: Integer; StreamPosition: OleVariant; RecognitionType: SpeechRecognitionType; const Result: ISpeechRecoResult); procedure SpSharedRecoContext1Hypothesis(ASender: TObject; StreamNumber: Integer; StreamPosition: OleVariant; const Result: ISpeechRecoResult); procedure TForm1.FormCreate(Sender: TObject); begin SpSharedRecoContext1 := TSpSharedRecoContext.Create(self); SpSharedRecoContext1.OnHypothesis := SpSharedRecoContext1Hypothesis; SpSharedRecoContext1.OnRecognition :=SpSharedRecoContext1Recognition; fMyGrammar := SpSharedRecoContext1.CreateGrammar(0); fMyGrammar.DictationSetState(SGDSActive); end; procedure TForm1.SpSharedRecoContext1Recognition(ASender: TObject; StreamNumber: Integer; StreamPosition: OleVariant; RecognitionType: SpeechRecognitionType; const Result: ISpeechRecoResult); begin Memo1.Text := Result.PhraseInfo.GetText(0,-1,true); end; procedure TForm1.SpSharedRecoContext1Hypothesis(ASender: TObject; StreamNumber: Integer; StreamPosition: OleVariant; const Result: ISpeechRecoResult); begin Memo1.Text := Result.PhraseInfo.GetText(0,-1,true); end; My Problem, was the vista-OS voice command will intercept on my program. if i say "START", instead of writing start on memo1 it press the start menu on my desktop. or what ever command like START CANCEL EDIT DELETE SELECT etc. please help..... sorry for my english

    Read the article

  • Calculate the retrieved rows in database Visual C#

    - by Tanya Lertwichaiworawit
    I am new in Visual C# and would want to know how to calculate the retrieved data from a database. Using the above GUI, when "Calculate" is click, the program will display the number of students in textBox1, and the average GPA of all students in textBox2. Here is my database table "Students": I was able to display the number of students but I'm still confused to how I can calculate the average GPA Here's my code: private void button1_Click(object sender, EventArgs e) { string connection = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Database1.accdb"; OleDbConnection connect = new OleDbConnection(connection); string sql = "SELECT * FROM Students"; connect.Open(); OleDbCommand command = new OleDbCommand(sql, connect); DataSet data = new DataSet(); OleDbDataAdapter adapter = new OleDbDataAdapter(command); adapter.Fill(data, "Students"); textBox1.Text = data.Tables["Students"].Rows.Count.ToString(); double gpa; for (int i = 0; i < data.Tables["Students"].Rows.Count; i++) { gpa = Convert.ToDouble(data.Tables["Students"].Rows[i][2]); } connect.Close(); }

    Read the article

  • Issue while saving image using savefiledialog

    - by user1097772
    I'm using savefiledialog to save an image. Canvas is picturebox and the loaded image is bitmap. When I try to save it the file is created but somehow corrupted. Cause when I try againt load the image or show in different viewer it doesn't work - I mean the saved file is corrupted. There is an method for saving image. private void saveFileDialog1_FileOk(object sender, CancelEventArgs e) { System.IO.FileStream fs = (System.IO.FileStream)saveFileDialog1.OpenFile(); try { switch (saveFileDialog1.FilterIndex) { case 1: canvas.Image.Save(saveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Bmp); break; case 2: canvas.Image.Save(saveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Jpeg); break; case 3: canvas.Image.Save(saveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Png); break; case 4: canvas.Image.Save(saveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Tiff); break; } } catch (Exception ex) { System.Console.WriteLine("Exception " + ex); } I should also mention the property Filter. saveFileDialog1.Filter has value: bmp (*.bmp)|*.bmp|jpeg (*.jpeg)|*.jpeg|png (*.png)|*.png|tiff (*.tiff)|*.tiff

    Read the article

  • google chrome extension update text after response callback

    - by Jerome
    I am writing a Google Chrome extension. I have reached the stage where I can pass messages back and forth readily but I am running into trouble with using the response callback. My background page opens a message page and then the message page requests more information from background. When the message page receives the response I want to replace some of the standard text on the message page with custom text based on the response. Here is the code: chrome.extension.sendRequest({cmd: "sendKeyWords"}, function(response) { keyWordList=response.keyWordsFound; var keyWords=""; for (var i = 0; i FIRST QUESTION: This all seems to work fine but the text on the page doesn't change. I am almost certainly because the callback completes after the page is finished loading and the rest of the code finishes before the callback completes, too. How do I update the page with the new text? Can I listen for the callback to complete or something like that? SECOND QUESTION: The procedure I am pursuing first opens the message page and then the message page requests the keyword list from background. Since I always want the keyword list, it makes more sense to just send it when I create the tab. Can I do that? Here is the code from background that opens the message page: //when request from detail page to open message page chrome.extension.onRequest.addListener(function(request, sender, sendResponse) { if(request.cmd == "openMessage") { console.log("Received Request to Open Message, Profile Score: "+request.keyWordsFound.length); keyWordList=request.keyWordsFound; chrome.tabs.create({url: request.url}, function(tab){ msgTabId=tab.id; //needed to determine if message tab has later been closed chrome.tabs.executeScript(tab.id, {file: "message.js"}); }); console.log("Opening Message"); } });

    Read the article

  • .net design pattern question

    - by user359562
    Hi. I am trying to understand design pattern problems. I am trying to modify the code like this in winforms and trying to see if any design pattern suits my requirement. Please suggest which is the best design pattern in this scenario. This is very basic code containing 2 tab pages which might have different controls can be added dynamically and read out different files on click of particular tab. To elaborate more... I have written this code to learn and understand design pattern. This is just a scenario where user click on a particular tab which will show dynamic controls generated. public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void tabControl1_SelectedIndexChanged(object sender, EventArgs e) { if (tabControl1.SelectedTab.Name.Equals("tabPage1")) { GeneratedynamicControlsForTab1(); } else if (tabControl1.SelectedTab.Name.Equals("tabPage2")) { GeneratedynamicControlsForTab2(); } } private void GeneratedynamicControlsForTab1() { Label label1 = new Label(); label1.Text = "Label1"; tabPage1.Controls.Add(label1); ReadCSVFile(); } private void GeneratedynamicControlsForTab2() { tabPage1.Controls.Clear(); Label label2 = new Label(); label2.Text = "Label2"; tabPage2.Controls.Add(label2); ReadTextFile(); } private void ReadCSVFile() { } private void ReadTextFile() { } }

    Read the article

  • Windows Azure: Creating a subdirectories inside the blob

    - by veda
    I wanted to create some subdirectories inside my blob. But it is not working out well Here is my code protected void ButUpload_click(object sender, EventArgs e) { // store upladed file as a blob storage if (uplFileUpload.HasFile) { name = uplFileUpload.FileName; // get refernce to the cloud blob container CloudBlobContainer blobContainer = cloudBlobClient.GetContainerReference("documents"); if (textbox.Text != "") { name = textbox.Text + "/" + name; } // set the name for the uploading files string UploadDocName = name; // get the blob reference and set the metadata properties CloudBlockBlob blob = blobContainer.GetBlockBlobReference(UploadDocName); blob.Metadata["FILETYPE"] = "text"; blob.Properties.ContentType = uplFileUpload.PostedFile.ContentType; // upload the blob to the storage blob.UploadFromStream(uplFileUpload.FileContent); } } What I did is that, If I have to create a sub directory, I will enter the name of the sub directory in the textbox. for example, if I need to create a file named "test.txt" inside the sub directory "files" Then, my textbox.text = files and uplFileUpload.FileName = test.txt Now I will concatenate them and upload to the blob.. But it is not working well.. I am getting just https://test.core.windows.net/documents/files/ I am not getting the entire thing I was expecting https://test.core.windows.net/documents/files/test.txt What am I doing wrong... How to create sub directories inside the blob.

    Read the article

  • Object reference not set to an instance of an object

    - by MBTHQ
    Can anyone help with the following code? I'm trying to get data from the database colum to the datagridview... I'm getting error over here "Dim sql_1 As String = "SELECT * FROM item where item_id = '" + DataGridView_stockout.CurrentCell.Value.ToString() + "'"" Private Sub DataGridView_stockout_CellMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DataGridView_stockout.CellMouseClick Dim i As Integer = Stock_checkDataSet1.Tables(0).Rows.Count > 0 Dim thiscur_stok As New System.Data.SqlClient.SqlConnection("Data Source=MBTHQ\SQLEXPRESS;Initial Catalog=stock_check;Integrated Security=True") ' Sql Query Dim sql_1 As String = "SELECT * FROM item where item_id = '" + DataGridView_stockout.CurrentCell.Value.ToString() + "'" ' Create Data Adapter Dim da_1 As New SqlDataAdapter(sql_1, thiscur_stok) ' Fill Dataset and Get Data Table da_1.Fill(Stock_checkDataSet1, "item") Dim dt_1 As DataTable = Stock_checkDataSet1.Tables("item") If i >= DataGridView_stockout.Rows.Count Then 'MessageBox.Show("Sorry, DataGridView_stockout doesn't any row at index " & i.ToString()) Exit Sub End If If 1 >= Stock_checkDataSet1.Tables.Count Then 'MessageBox.Show("Sorry, Stock_checkDataSet1 doesn't any table at index 1") Exit Sub End If If i >= Stock_checkDataSet1.Tables(1).Rows.Count Then 'MessageBox.Show("Sorry, Stock_checkDataSet1.Tables(1) doesn't any row at index " & i.ToString()) Exit Sub End If If Not Stock_checkDataSet1.Tables(1).Columns.Contains("os") Then 'MessageBox.Show("Sorry, Stock_checkDataSet1.Tables(1) doesn't any column named 'os'") Exit Sub End If 'DataGridView_stockout.Item("cs_stockout", i).Value = Stock_checkDataSet1.Tables(0).Rows(i).Item("os") Dim ab As String = Stock_checkDataSet1.Tables(0).Rows(i)(0).ToString() End Sub I keep on getting the error saying "Object reference not set to an instance of an object" I dont know where I'm going wrong. Help really appreciated!!

    Read the article

  • How to get the coordinates of an image mouse click in the event handler?

    - by Edward Tanguay
    In the following WPF app, I have an Image in a ContentControl. When the user clicks on the image, how can I get the x/y coordinates of where the mouse clicked on the image? XAML: <Window x:Class="TestClick828374.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300"> <StackPanel Margin="10"> <ContentControl Content="{Binding TheImage}" MouseDown="ContentControl_MouseDown"/> </StackPanel> </Window> Code-Behind: using System; using System.Windows; using System.Windows.Controls; using System.Windows.Media; using System.Windows.Media.Imaging; using System.ComponentModel; namespace TestClick828374 { public partial class Window1 : Window, INotifyPropertyChanged { #region ViewModelProperty: TheImage private Image _theImage; public Image TheImage { get { return _theImage; } set { _theImage = value; OnPropertyChanged("TheImage"); } } #endregion public Window1() { InitializeComponent(); DataContext = this; TheImage = new Image(); TheImage.Source = new BitmapImage(new Uri(@"c:\test\rectangle.png")); TheImage.Stretch = Stretch.None; TheImage.HorizontalAlignment = HorizontalAlignment.Left; } #region INotifiedProperty Block public event PropertyChangedEventHandler PropertyChanged; protected void OnPropertyChanged(string propertyName) { PropertyChangedEventHandler handler = PropertyChanged; if (handler != null) { handler(this, new PropertyChangedEventArgs(propertyName)); } } #endregion private void ContentControl_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { //how to get the coordinates of the mouse click here on the image? } } }

    Read the article

  • Test MVC using moq

    - by Raminder
    I am new to moq and I was trying to test a controller (MVC) behaviour that when the view raises a certain event, controller calls a certain function on model, here are the classes - public class Model { public void CalculateAverage() { ... } ... } public class View { public event EventHandler CalculateAverage; private void RaiseCalculateAverage() { if (CalculateAverage != null) { CalculateAverage(this, EventArgs.Empty); } } ... } public class Controller { private Model model; private View view; public Controller(Model model, View view) { this.model = model this.view = view; view.CalculaeAverage += view_CalculateAverage; } priavate void view_CalculateAverage(object sender, EventArgs args) { model.CalculateAverage(); } } and the test - [Test] public void ModelCalculateAverageCalled() { Mock<Model> modelMock = new Mock<Model>(); Mock<View> viewMock = new Mock<View>(); Controller controller = new Controller(modelMock.Object, viewMock.Object); viewMock.Raise(x => x.CalculateAverage += null, new EventArgs.Empty); modelMock.Verify(x => x.CalculateAverage()); //never comes here, test fails in above line and exits Assert.True(true); } The issue is that the test is failing in the second last line with "Invocation was not performed on the mock: x = x.CalculateAverage()". Another thing I noticed is that the test terminates on this second last line and the last line is never executed. Am I doing everything correct?

    Read the article

  • wpf observableCollection

    - by Asha
    I have an ObservableCollection which is dataContext for my treeview when I try to remove an Item from ObservableCollection I will get an error that Object reference not set to an instance of an object . can you please tell me why this error is happening and what is the solution thanks EDIT 1: The code is something like : class MyClass : INotifyPropertyChanged { //my class code here } public partial class UC_myUserControl : UserControl { private ObservableCollection<MyClass> myCollection = new ObservableCollection<MyClass>(); private void UserControl_Loaded(object sender, RoutedEventArgs e) { myCollection.add(new myClass); myTreeView.DataContext = myCollection ; } private void deleteItem() { myCollection.RemoveAt(0); //after removing I get error Which I guess should be something related //to interface update but I don't know how can I solve it } } Exception Detail : System.NullReferenceException was unhandled Message="Object reference not set to an instance of an object." Source="PresentationFramework" EDIT 3: I have a style which is for my treeitem to keep the treeitems expanded <Style TargetType="TreeViewItem"> <Setter Property="IsExpanded" Value="True" /> </Style> and with commenting this part I wont get any error !!! Now I want to change my question to why having this style is causing error ?

    Read the article

  • Non-blocking TCP connection issues.

    - by Poni
    Hi! I think I'm in a problem. I have two TCP apps connected to each other which use winsock I/O completion ports to send/receive data (non-blocking sockets). Everything works just fine until there's a data transfer burst. The sender starts sending incorrect/malformed data. I allocate the buffers I'm sending on the stack, and if I understand correctly, that's a wrong to do, because these buffers should remain as I sent them until I get the "write complete" notification from IOCP. Take this for example: void some_function() { char cBuff[1024]; // filling cBuff with some data WSASend(...); // sending cBuff, non-blocking mode // filling cBuff with other data WSASend(...); // again, sending cBuff // ..... and so forth! } If I understand correctly, each of these WSASend() calls should have its own unique buffer, and that buffer can be reused only when the send completes. Correct? Now, what strategies can I implement in order to maintain a big sack of such buffers, how should I handle them etc'? And, if I am to use buffers that means I should copy the data to be sent from the source buffer to the temporary one, thus, I'd set SO_SNDBUF on each socket to zero, so the system will not re-copy what I already copied. Are you with me? Please let me know if I wasn't clear.

    Read the article

  • Android listing design problem with cursors

    - by Priyank
    Hi. I have a following situation in my android app. I have an app that fetches messages from inbox, sent items and drafts based on search keywords. I use to accomplish this by fetching cursors for each manually based on selection by user and then populating them in a custom data holder object. Filter those results based on given keywords and then manually render view with respective data. Someone suggested that I should use a custom Cursor adapter to bind view and my cursor data. So I tried doing that. Now what I am doing is this: Fetch individual cursors for inbox, sent items and drafts. Merge them into one using Merge cursor and then pass that back to my CursorAdapter implmentation. Now where or how do I filter my cursor data based on keywords; because now binding will ensure that they are directly rendered to view on list. Also, some post fetching operation like fetching sender's contact pic and all will be something that I do not want to move to adapter. If I do all this processing in adapter; it'll be heavy and ugly. How could I have designed it better such that it performs and the responsibilities are shared and distributed. Any ideas will be helpful.

    Read the article

  • VB.NET: Dialog exits when enter pressed?

    - by Camilo Martin
    Hi all; My problem seems to be quite simple, but it's not working the intuitive way. I'm designing a Windows Forms Application, and there is a dialog that should NOT exit when the enter key is pressed, instead it has to validate data first, in case enter was pressed after changing the text of a ComboBox. I've tried by telling it what to do on KeyPress event of the ComboBox if e is the Enter key: Private Sub ComboBoxSizeChoose_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ComboBoxSizeChoose.KeyPress If e.KeyChar = Convert.ToChar(Keys.Enter) Then Try TamanhoDaNovaFonte = Single.Parse(ComboBoxSizeChoose.Text) Catch ex As Exception Dim Dialogo2 As New Dialog2 Dialog2.ShowDialog() ComboBoxSizeChoose.Text = TamanhoDaNovaFonte End Try End If End Sub But no success so far. When the Enter key is pressed, even with the ComboBox on focus, the whole dialog is closed, returning to the previous form. The validation is NOT done at all, and it has to be done before exiting. In fact, I don't even want to exit on the form's enter KeyPress, the only purpose of the enter key on the whole dialog is to validate the ComboBox (but only when in focus, for the sake of an intuitive UI). I've also tried appending the validation to the KeyPress event of the whole dialog's form, if the key is Enter. NO SUCCESS! It's like my code wasn't there at all. What should I do? (Visual Studio 2008, VB.NET)

    Read the article

  • After I apply custom logic, next UI action crashes my app.

    - by DanF
    I've got an team (eveningRoster) that I'm making a button add employees to. The team is really a relationship to that night's event, but it's represented with an AC. I wanted to make sure an employee did not belong to the team before it adds, so I added a method to MyDocument to check first. It seems to work, the error logs complete, but after I've added a member, the next time I click anything, the program crashes. Any guesses why? Here's the code: -(IBAction)playsTonight:(id)sender { NSArray *selection = [fullRoster selectedObjects]; NSArray *existing = [eveningRoster arrangedObjects]; //Result will be within each loop. BOOL result; //noDuplicates will stay YES until a duplicate is found. BOOL noDuplicates = YES; //For the loop: int count; for (count = 0; count < [selection count]; count++){ result = [existing containsObject:[selection objectAtIndex:count]]; if (result == YES){ NSLog(@"Duplicate found!"); noDuplicates = NO; } } if (noDuplicates == YES){ [eveningRoster addObjects:[fullRoster selectedObjects]]; NSLog(@"selected objects added."); [eveningTable reloadData]; NSLog(@"Table reloaded."); } [selection release]; [existing release]; return; }

    Read the article

  • MyContainer derived from FrameworkElement with binding support.

    - by alex2k8
    To understand how the binding works, I implemented MyContainer derived from FrameworkElement. This container allowes to set Children and adds them into the logical tree. But the binding by ElementName does not work. What can I do with MyContainer to make it work, leaving the parent as FrameworkElement? C#: public class MyContainer : FrameworkElement { public MyContainer() { Children = new List<FrameworkElement>(); } public List<FrameworkElement> Children { get; set; } protected override IEnumerator LogicalChildren { get { return Children.GetEnumerator(); } } } XAML: <Window x:Class="WpfLogicalTree.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:WpfLogicalTree" Title="Window1" Height="300" Width="300"> <StackPanel> <local:MyContainer> <local:MyContainer.Children> <TextBlock Text="Foo" x:Name="_source" /> <TextBlock Text="{Binding Path=Text, ElementName=_source}" x:Name="_target"/> </local:MyContainer.Children> </local:MyContainer> <Button Click="Button_Click">Test</Button> </StackPanel> </Window> Window1.cs private void Button_Click(object sender, RoutedEventArgs e) { MessageBox.Show(_target.Text); }

    Read the article

  • Windows 7 Create Folder in "Program Files" failing in C# code even thought I have admin rights!

    - by Shiva
    Hi, I am unable to create a file under "program files" folder on my Windows 7 64-bit machine in VS 2008 WPF C# code. The error I get on the following code myFile = File.Create(logFile); is the following. (this is the innerException stack trace). at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options) at System.IO.File.Create(String path) at MyFirm.MyPricingApp.UI.App.InitializeLogging() in C:\Projects\MyPricingApp\App.xaml.cs:line 150 at MyFirm.MyPricingApp.UI.App.Application_Startup(Object sender, StartupEventArgs e) in C:\Projects\MyPricingApp\App.xaml.cs:line 38 at System.Windows.Application.OnStartup(StartupEventArgs e) at System.Windows.Application.<.ctor>b__0(Object unused) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler) this seems like it has something to do with UAC in Windows 7, because why else would I get this since my user is already Admin on the machine ?! Also since the WinIOError has SECURITY_ATTRIBUTES, I am thinking this has something to do with a "new way" security is handled in Windows 7. I tried to browse to the "Program Files" folder, under which the log folder and file were to be created. I can create the folder by hand, but when i try to create the file, I get the similar "Access Denied" exception.

    Read the article

  • Does not contain a definition for GetDataFromNumber But i have it defined!?!?!

    - by JB
    public void button2_Click(object sender, System.EventArgs e) { string text = textBox1.Text; Mainform = this; this.Hide(); GetSchedule myScheduleFinder = new GetSchedule(); string result = myScheduleFinder.GetDataFromNumber(text);// says there is no definition if (!string.IsNullOrEmpty(result)) { MessageBox.Show(result); } else { MessageBox.Show("Enter A Valid ID Number!"); } } says it does not contain definition for it but on my GetSchedule .cs file i have it defined public string GetDataFromNumber(string ID)//defined here { foreach (IDnumber IDCandidateMatch in IDnumbers) { if (IDCandidateMatch.ID == ID) { StringBuilder myData = new StringBuilder(); myData.AppendLine(IDCandidateMatch.Name); myData.AppendLine(": "); myData.AppendLine(IDCandidateMatch.ID); myData.AppendLine(IDCandidateMatch.year); myData.AppendLine(IDCandidateMatch.class1); myData.AppendLine(IDCandidateMatch.class2); myData.AppendLine(IDCandidateMatch.class3); myData.AppendLine(IDCandidateMatch.class4); //return myData; return myData.ToString(); } } return ""; }

    Read the article

  • How do I send the mutable string to the NSTextField properly?

    - by Merle
    So I have all this code that I have debugged and it seems to be fine. I made a mutable string and for some reason I can not get it to be displayed on my label. the debugger says "2010-04-22 22:50:26.126 Fibonacci[24836:10b] * -[NSTextField setString:]: unrecognized selector sent to instance 0x130150" What is wrong with this? When I just send the string to NSLog, it comes out fine. here's all my code, any help would be appreciated. "elementNum" is a comboBox and "display" is a Label. Thanks #import "Controller.h" @implementation Controller - (IBAction)computeNumber:(id)sender { int x = 1; int y = 1; NSMutableString *numbers = [[NSMutableString alloc] init]; [numbers setString:@"1, 1,"]; int num = [[elementNum objectValueOfSelectedItem]intValue]; int count = 1; while (count<=num) { int z = y; y+=x; x=z; [numbers appendString:[NSString stringWithFormat:@" %d,", y]]; count++; } [display setString:numbers]; NSLog(numbers); } @end `

    Read the article

  • iPhone UISlider not visible

    - by John Qualis
    I want to add a UISlider to my app programmatically without using the IB. I am adding a UISlider to my UIViewController using the code below. However I don't see the slider when the view comes up. What am I missing? I am using iPhone SDK 3.1.2. Appreciate any help. @synthesize slider; .... - (void)viewDidLoad { ... ... slider = [[UISlider alloc] initWithFrame: CGRectMake(0, 480 - 80, 300, 20)]; slider.minimumValue = 0.0; slider.maximumValue = 100.0; slider.tag = 0; slider.value = 50; slider.continuous = YES; slider.enabled = YES; [slider addTarget:selfaction:@selector(handleSlider:)forControlEvents:UIControlEventValueChanged]; self.view addSubview:slider]; In the .h file ... UISlider *slider; ... @property (nonatomic, retain) UISlider *slider; - (void) handleSlider:(id)sender;

    Read the article

  • Web service performing asynchronous call

    - by kornelijepetak
    I have a webservice method FetchNumber() that fetches a number from a database and then returns it to the caller. But just before it returns the number to the caller, it needs to send this number to another service so instantiates and runs the BackgroundWorker whose job is to send this number to another service. public class FetchingNumberService : System.Web.Services.WebService { [WebMethod] public int FetchNumber() { int value = Database.GetNumber(); AsyncUpdateNumber async = new AsyncUpdateNumber(value); return value; } } public class AsyncUpdateNumber { public AsyncUpdateNumber(int number) { sendingNumber = number; worker = new BackgroundWorker(); worker.DoWork += asynchronousCall; worker.RunWorkerAsync(); } private void asynchronousCall(object sender, DoWorkEventArgs e) { // Sending a number to a service (which is Synchronous) here } private int sendingNumber; private BackgroundWorker worker; } I don't want to block the web service (FetchNumber()) while sending this number to another service, because it can take a long time and the caller does not care about sending the number to another service. Caller expects this to return as soon as possible. FetchNumber() makes the background worker and runs it, then finishes (while worker is running in the background thread). I don't need any progress report or return value from the background worker. It's more of a fire-and-forget concept. My question is this. Since the web service object is instantiated per method call, what happens when the called method (FetchNumber() in this case) is finished, while the background worker it instatiated and ran is still running? What happens to the background thread? When does GC collect the service object? Does this prevent the background thread from executing correctly to the end? Are there any other side-effects on the background thread? Thanks for any input.

    Read the article

  • Get controls ClientID/UniqueID between DetailsView and UpdatePanel

    - by robertpnl
    Hi guys, I like to know how to get the ClientID/UniqueID of a control inside a Detailsview controls EditItemTemplate element and when DetailsViews changing to Edit mode and DetailsView is inside a AJAX UpdatePanel. Without UpdatePanel, during PostBack I can get the ClientID's control, but now with an UpdatePanel. <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:DetailsView ID="DetailsView1" runat="server" DataSourceID="SqlDataSource1" AllowPaging="true" AutoGenerateEditButton="true"> <Fields> <asp:TemplateField> <EditItemTemplate> <asp:CheckBox runat="server" ID="chkboxTest" Text="CHECKBOX" /> </EditItemTemplate> </asp:TemplateField> </Fields> </asp:DetailsView> </ContentTemplate> </asp:UpdatePanel> As you see, the EditItemTemplate contains a Checkbox control. So i'm trying to get the ClientID of this checkbox when Detailsview is changing to the Edit mode. I need this value for handling Javascript. Catching the events ChangingMode/ChangedMode doesn't work; chkbox is null: void DetailsView1_ModeChanged(object sender, EventArgs e) { if (DetailsView1.CurrentMode == DetailsViewMode.Edit) var chkbox = DetailsView1.Rows[0].FindControl("chkxboxTest"); // <== is null } Maybe i'm using the wrong event? Someone can give me a tip about this? Thanks.

    Read the article

  • Find all the child node of specific value in C#

    - by sara brown
    <main> <myself> <pid>1</pid> <name>abc</name> </myself> <myself> <pid>2</pid> <name>efg</name> </myself> </main> that is my XML file named simpan. I have two button. next and previous. What i want to do is, all the info will shows off on the TextBox when the user click the button. The searching node will be based on the pid. Next button will adding 1 value of pid (let's say pid=2) and it will search on the node that have the same value of pid=2. it also will show the name for the pid=2. (showing name=abc) Same goes to the previous button where it will reduce 1value of pid (pid=1). Does anybody knows how to do this? //-------------EDIT------------------ thanks to L.B, im trying to use his code. however i got an error. is my implementation of code correct? private void previousList_Click(object sender, EventArgs e) { pid = 14; XDocument xDoc = XDocument.Parse("C:\\Users\\HDAdmin\\Documents\\Fatty\\SliceEngine\\SliceEngine\\bin\\Debug\\simpan.xml"); var name = xDoc.Descendants("myself") .First(m => (int)m.Element("PatientID") == pid) .Value; textETA.Text = name; //////////////////// }

    Read the article

< Previous Page | 134 135 136 137 138 139 140 141 142 143 144 145  | Next Page >