C# Using XML to create a Windows Form

I am working on a Windows Desktop application that will store a number of documents, there will initially be 4 different types of documents, each as a windows form, each with some common details (document ID, client ID etc), and then different fields based on the document type. I plan on using XML to specify the fields for each form. So my question is, what is the easiest way to take an XML document and render form fields based on its content? Should I just be parsing the XML and creating form

C# How can I serialize wpf user control with xaml and code behind

I want to serialize wpf user control xaml and codebehind. XamlWriter.Save() only serialize's xaml so what can I do in this situation? My situtation is I have a usercontrol which include custom methods, subscribed events (ex: button click) When I deserialize usercontrol (for create usercontrol at runtime) I want to run that events and methods. Sorry my english isn't very good.

C# How to create the following user interface?

A customer has asked for a user interface which combines a number of different elements. It's basically a list. Selecting an entry in the list causes a dialog to expand in-place: Item 1 Item 2 Item 3 After selecting Item 2 Item 1 ------------------------------------ | Item 2 | | text box button | | button | | | | text box button | ------------------------------------ Item

Database connection in c#.net VS2010

I'm trying to connect to my database in .net using dataset. My code is for a workbook creator. The method takes the questions form the DB and put them in list. When I'm running the code I get the next error: System.ArgumentException was unhandled by user code Message=Format of the initialization string does not conform to specification starting at index 103. Source=System.Data StackTrace: at System.Data.Common.DbConnectionOptions.GetKeyValuePair(String connectionString, Int32 curre

C# Elegant Solution for Initializing One Class (but not another)

I have an app that supports two data access layers: db4o and RavenDB. The logic classes make calls like this to get a concrete data class: return DataAccessFactory.GetDataInterface<IApplicationData>().GetAll(); Here is the method in DataAccessFactory that returns the correct ApplicationData (db4o or RavenDB) concrete class: public static T GetDataInterface<T>() where T : class { T theObject = // Code here to get the object. Not relevant to this question. // Begin HACK

Track progress when uploading file to Rackspace Cloud Files in C#

I am using https://github.com/rackspace/csharp-cloudfiles to bulid a command-line tool to upload files to Rackspace Cloud Files. The thing is that I don't know how to track upload progress (there doesn't seem to be any kind of event or something). Here's the code: // Create credentials, client and connection var creds = new UserCredentials(username, apiKey); CF_Client client = new CF_Client(); Connection conn = new CF_Connection(creds, client); conn.Authenticate(); // Get container and uploa

Xamarin Studio runs into exception when opening ASP.NET C# project

All, I'm new to ASP.NET programming, and am trying to do some examples to get started. I'm doing this in Xamarin 4.0.8(build 2). When I try and open up the Default.aspx file (generated when the project is created), I encounter the following exception warning: System.Exception: System.Web assembly name not found for framework .NETFramework,Version=v4.5 at MonoDevelop.AspNet.WebTypeContext.GetSystemWebDom(TargetRuntime runtime, TargetFramework targetFramework) at MonoDevelop.AspNet.WebTypeConte

Directory Not Found Exception C#

I am creating the file list of both source & target directory in target location, the requirement is based on the difference of these two files copy only the files that are new from last iteration. For 1st iteration copy works, next iteration creates a blank diff [Difference] file is created, to handle this I have added if condition where I check length of file and copy them again. But the if condition is not working as per behavior, with length zero it goes to else statement and throws out

Navigating from a BasicPage to a BasicPage in c# metro application

Hi I am working on a metro app as a school assignment but I am having problems navigating from a basicPage to another basicPage. I keep getting a Value cannot be null error. This is my Code in the button: this.Frame.Navigate(typeof(BasicPage1), null);. Can anyone help me? immediate response would be much appreciated

C# Oracle connection string without a DSN

I currently connect to an Oracle database in C#. NET2.0 using the following database connection string: Dsn=myDSNs;uid=me;pwd=mypassword What I'd really like to do is connect using a connection string that doesn't need a DSN (to save me configuring ~100 machines). I've tried many variations of the following: Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=myService))); uid=me; pwd=mypassword; But keep getting the following except

C# Umbraco: The type or namespace library does not exist

I've been sent a web site developed using Umbraco 4.7 which I've managed to open in VS 2012 Express for Web. When I build the solution, I get an error message The type or namespace name 'library' does not exist in the namespace 'Clientname.umbraco' (are you missing an assembly reference?) I'm new to Umbraco but was told I had everything I needed to build the project. In the Solution Explorer, in the References folder there is a listing for 'umbraco' and when I open the reference in the Obj

C# How to set values for SSIS parameters

I am trying to execute a SSIS package through managed code and I would like to set the value of parameters in the package: PackageInfo ssisPackage = ssisServer.Catalogs["SSISDB"].Folders["SWIS5_PersonImport"].Projects["SWIS5_PersonImport"].Packages["EducatorsUploader.dtsx"]; ssisPackage.Parameters["FlatFile_Path"].Set(ParameterInfo.ParameterValueType.Literal, parameter.FilePath); The code above shows how I have tried and it does not work, I have found documentation from previews versions wher

C# WMI call fails from .NET code, but not C++

From C# (.NET 4.0), we're making a WMI call like this: var connectOptions = new ConnectionOptions { Authority = "ntlmdomain:" + paramValues.Domain, Username = paramValues.UserName, Password = paramValues.Password }; var scopeString = @"\\" + paramValues.Server + @"\root\cimv2"; var scope = new ManagementScope(scopeString, connectOptions); scope.Connect(); var queryString = String.Format("SELECT * FROM Win32_NTLogEvent WHERE LogFile = 'Security' AND TimeGenerated > '{0:yyyyMMddH

C# The text File is not load in a TextBox

Here is my Code : protected void Button4_Click(object sender, EventArgs e) { if (FileUpload1.HasFile) { string filename = Path.GetFileName(FileUpload1.PostedFile.FileName); string tempfolder = Server.MapPath("~/SampleFiles/" + filename); FileUpload1.SaveAs(tempfolder); TextBox3.Text = filename; Label6.Text = "File Uploaded succesfully"; } else { Label6.Text = "Error in Uploading"; } } but this code gives only a file

C# Store list of pairs in one table EF

I used the following class: public class Point { [Required] public double X { get; set; } [Required] public double Y { get; set; } } And the Model containing: public List<Point> Vertices { get; set; } But EF tries to create a separate table based on this message : EntityType 'Point' has no key defined. Define the key for this EntityType. I'll have large number of points for related model and I think it's not optimal solution to have a separate table. Is there a

C# Winform app with loaded DB connection

I have a question regarding problem i am solving. I am editing an old Winform app; currently the only part I need does not take input from the user(automated program). However the form contains database connection settings that program uses. Currently the program needs the user to press a button to start the process (code is associated with the button). Do i need to convert whole app to Console App or is there an easier way to automate this process without messing with the database connection s

C# Bing maps WPF multitouchdemo

I have created a simple WPF application that has a Bing Map. The problem is when I try to run my program on PC with touch input it becomes really unstable: when you try to scale or translate the map it lags hard. By the way, the same application runs normally on a desktop where you can use only your mouse to navigate. And also, when you open Bing Maps in browser on this touch device everything is okay so the problem is in the code and not related with hardware, I think. I did some positive step

C# Generating multiple dlls from one project

I found this article and works great, but there is one problem that I couldn't solve. My project references to another project just beside and some cs files are using some the members from that dll. When I try building it is complaining that it doesn't have reference to that dll. How can I add reference to Csc task? Could anyone help me on that? Help appreciated!

C# PrintDialog not modal

I'm using System.Windows.Control.PrintDialog in my .NET-3.5 wpf app. Unfortunately, the print dialog will not be modal even though I'm using ShowDialog. There doesn't seem to be any way for my to set the owner to be my app either. Ideas?

C# How to read QRcode from Windows Phone 7 Emulator

I am developing a simple QRcode Reader/Generator app. Now I Can generate a QR code, and tested from WP7 emulator. But I can not test QR code reader. So that I decided to hard code the image for scanning. Now my problem is, I don't know where to load the hard coded QR image to QR Code Reader. My QR Code Reader Code is: private PhotoCamera _phoneCamera; private IBarcodeReader _barcodeReader; private DispatcherTimer _scanTimer; private WriteableBitmap _previewBuffer; public

C# Live search control

I would like to develop a "live" search control which displays the results in a popup menu when entering letters in a textbox. The data comes from a web service and a database on the LAN. My first thought was something like that (executing in a thread): while (true) { start: if (searchTermChanged) { clearData(); showPopup(); //get and add data from Webservice if (searchTermChanged) goto start //get and add data from database (query 1)

C# Warn on assign to parameter in Visual Studio

C# allows this. How do I get Visual Studio to warn me when I do this? BTW, Resharper doesn't warn about this either. Stackoverflow Question about this in Eclipse Another Question about this in Eclipse I need to do this now because: We run nightly code analysis that picks this up as an issue and my team agrees that it is a real issue. EDIT: I've started work on a ReSharper™ plugin to do this.

C# Entity Framework 6 Relationship

Hi, I'm having trouble mapping the POCO objects to the existing database where I have a base class that contains an ID property that is inherited by all model classes. The base class itself is ignored in the context's OnModelCreating method and the problem starts when I try to specify the relationship between User and Session. The tables are as follows: ==================== User ==================== ID | Name | Password ==================== ==================== Session ====================

C# linq query group by fail to group all rows with similar keys

this is my query: rows.GroupBy(row => new TaxGroupObject { EnvelopeID = row.Field<int>("EnvelopeID"), PolicyNumber = row.Field<string>("PolicyNumber"), TZ = row.Field<string>("TZ") }) .Select(row => { int i; if (row.Key.EnvelopeID == 5713 && row.Key.PolicyNumber == "50002617" && row.Key.TZ ==

C# Compare and Contrast IValidatableObject vs IValidator for MVC model validation

My understanding : AFAIK, both IValidatableObject and IValidator interfaces validates the Model and helps displaying validation errors. The validate() method of IValidatableObject() returns an IEnumerable so that we can do multiple validations and display the validation results using the yield return pattern. Whereas the Validate() method of IValidator has a void return type and basically it sets the IsValid property and the ErrorMessage property. I guess we can do multiple validations here as w

C# WPF - MenuItem icon shows partially

I want to create a simple MenuItem with Icon, without Header. Icon height and width must be equal to the menu item's dimensions. Icon size - 48x48. My XAML: <Menu> <Menu.ItemsPanel> <ItemsPanelTemplate> <DockPanel HorizontalAlignment="Left" /> </ItemsPanelTemplate> </Menu.ItemsPanel> <MenuItem Width="48"> <MenuItem.Icon> <Image Source="../Images/sync-48.

C# Using Lists that give permissions

I'm trying to write this code for my project but it doesn't seem to work. As you can see from the code, the last else statement won't work. I have a class Admin and it has 3 properties, Username, Password, and Permitted. I created a List with default values and granted some usernames permission while granting some no permission. From the else statement, I'm trying to match if the Permitted value is true then that user has permission, and vice versa, however even if the user has no permission is

C# Html.ListBoxFor with multiline items

is it possible to make ASP.NET Html.ListBoxFor to work with multiline items ? Because right now i have a list of strings, some strings are very long, so they do not fit into list box, and are cut, i.e, instead of "qwertyuiop" i see only "qwer". The width of the list box cannot be changed, that's how it must be. Can i make it to show a single item/string over multiple lines(i tried inserting new line symbol, html line break symbol into string, doesn't work) ? Or do i have to use some other html e

How to add row to specific rank, DataViewGrid, C#

I have DataViewGrid with three columns. | ID | NAME | DATE | DATE is type of DateTime. I want to add rows so that they are ordered by date. How? Example: 1 JACOB 27.5.2015 23:15.10 6 PETER 27.5.2015 23.16.10 9 PETER 27.5.2015 23.16.41 Data are addet by method: public void add(int id, String name, DateTime dateTime)

how to round up a double value to nearest integer in c#

I am developing a windows forms application.I need to do some conversions and round up the values.I need to round up the double value to nearest integer.For example 1.4 should be 1 and 1.6 should be 2 after applying round up.Please refer my code below. double d = 51386933935386.5; uint x = (uint)Math.Round(d, 0, MidpointRounding.AwayFromZero); After round up I need the value value = 51386933935386.But I am getting some different value.

C# Converting a bidimensional array of floats to bools

Let's say I have a bidimensional array of floats float [,] myfloats = new float[10, 10] FillWithValues(myfloats); How can I convert this bidimensional float array, to a bidimensional bool array, using a random evaluating method? I was hoping something like this: bool[,] mybools; mybools = myfloats.Select(myfloat => Evaluate(myfloat)); but that does not work...

C# Using automapper to map a child property to same model

The problem I have a domain model that has a revisioning system build in to it. In concept it looks like this: Model -> ModelDetails The Model holds all the relations to other objects and has an ICollection of the ModelDetails. It also has a details property that shows the latest version. Until now I've mapped everything by manual coding to the viewmodels. Those are basically a combination of the Model and the ModelDetails (details property) object. The problem lies in defining that the m

C# Exception: Only an absolute URI can be used as a base address

I saw a similar problem on the site, but I checked my base address and did not notice any problems. When start debugging my project, i got this exception:Only an absolute URI can be used as a base address. My Host Application private ServiceHost _presenterServiceHost; public void Start() { if(_presenterServiceHost !=null) _presenterServiceHost.Close(); _presenterServiceHost=new ServiceHost(typeof(Business.FXCTSPipeConnectionsProvider)); _pre

C# how do i decipher 4 byte data split them accordingly and assign them to a meaningful variable?

I have 4 byte data stream, I know at what bite I wanted to split them and assign them to a different variable. keeping in mind the data I receive is in hex format. let's say, P_settings 4bytes p_timeout [6:0] p_s_detected[7] p_o_timeout [14:8] p_o_timeout_set [15] override_l_lvl [23:16] l_b_lvl [31:24] above P_settings is 4 bytes and I wanted to split them byte into bits like p_timeout

C# One Drive Error in Sign In with GraphServiceClient

I am trying to Sign In with GraphServiceClient, but during the attempt, I have this error message: OneDrive reported the following error: The browser based authentication dialog failed to complete. Reason: The server or proxy was not found. Error en Sign In The code I got from the sample is this: public static GraphServiceClient GetAuthenticatedClient(){ if (graphClient == null) { // Create Microsoft Graph client. try { graphClient = new GraphServiceCl

C# OOP Pattern - using abstract with reflection a lot. Is this a bad pattern I'm falling into?

Lately I've been using this sort of pattern a lot: abstract class myBaseClass { //some common methods/properties/etc that all inheritors would share //some abstract methods/properties/etc that inheritors must implement protected abstract bool DoIHandleThisSortOfRequest(...); public static myBaseClass GetHandler() { // some reflection to enumerate through classes // that inherit from myBaseClass, and use // something like DoIHandleThisSortOfRequest()

C# How to tell a ASPX uppercase converter to ignore certain parts of string for conversion?

I am trying to fill in an online form for printing out business cards. The online form is ASPX. I am using their service and I do not have control over the backend. One of the text fields is being force converted to uppercase in the preview (whats seen on the preview will be finally printed). I am presuming there is a string.toupper or text-transform that is being used to force convert string to uppercase. Is there a way to pass a string that someone tells the converter to ignore certain parts

C# Iterate Through MenuStrips

I find answers for iterating through menustrip items but no luck for iterating through menuStrips (let's say I have a few contextMenuStrip in a Form). foreach(Control c in this.Controls) { if(c is ContextMenuStrip) { // This doesn't work. I figured out contextmenustrips are not // holding in this.Controls } }

C# How to refresh Listview MVVM

ViewModel: public DataView List { get { return _list; } set { _list = value; NotifyOfPropertyChange("List"); } } <...> DataTable dt = new DataTable(); using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["X"].ConnectionString)) { SqlDataAdapter adapter = new SqlDataAdapter(); adapter.SelectCommand = new SqlCommand("Select * from Employees", connection);

C#: How to convert decimal to string without converting to exponential representation

For instance, I have an object array with some values. It can be decimal, double ,int or strings. object[] oo = {0.000278121, 0.000078125m, "Hello",1}; For instance when converting this values to string, the second value becomes 7.8125E-05. But first value stays as in array. So how to differentiate parsing logic for that types, and parse all decimal values in the same format? Full code: object[] oo = {0.000278121, 0.000078125,"Hello",1}; string[] ss = oo.Select(x => x.ToString()).ToArray();

C# How to make a pattern using regex like below?

I would like to make a pattern. For example, my input is string str = "15-16-00-014716 AND15- [ ] (5) Description of 16-00-014715"; Expected output is 15-16-00-014716 AND15-16-00-014715 I tried below regex: Regex.Replace(YourString, @"\s+\[.*(?=\b\d+)",""); But the output is like 15-16-00-014716 AND15-0-014715

C# Unable to fix monobehaviour scripts problem in Unity

I was just getting started with Unity and using it's Standard Assets library. I used its rollerball object, but both its Ball and BallUserControl scripts gave me the following error: No Monobehaviour scripts in the file, or the names do not match the file name. I didn't change any scripts, and I have no other objects or scripts in my environment. The class names match the file names. I am sure I am missing something obvious (being so new). What are some possible errors? I am running the

C# Is there a way to Serialize Json that contains a field that contains more json as a string to XML

I receive Json-data from an external source. I need to convert the Json messages to XML. This is relatively simple using the NewtonSoft library: var placeHolder = $"{{\"Data\": {jsonContent} }} "; var xmlNode = JsonConvert.DeserializeXmlNode(placeHolder, "Root").OuterXml; var doc = new XmlDocument(); doc.LoadXml(xmlNode); There is one little odd thing about the Json that I receive that breaks this entire process. The Json looks like this: [ { "Type":

Customize JSON key name in C# SerializeObject

I have a C# class with the name _Numeric as Numeric values are not allowed.I would like to serialize this to a JSON but replace _Numeric to Numeric in JSON Keys. How can I write some custom JSON using System; using System.Text.Json; using System.Text.Json.Serialization; using System.Web.Script.Serialization; class TestNumeric { public InnerNumeric innerNumeric; public string name; public TestNumeric() { name = "Test Name"; innerNumeric = new InnerN

C# How to map info from the relationship table from the many-to-many relatonship table into entity model class using AutoMapper

How can I map information from the relationship table from a many-to-many relationship and map one or more of its properties to the entity from one of the table used in that query using AutoMapper. For example, I have following 3 tables: Part ==== PartId Description 1 Part1 2 Part2 3 Part3 Object ====== ObjectId Description 1 Obj1 2 Obj2 Objects_Parts ============= ObjectId PartId IsRequired 1 1 True 1 2 2 1 True

Custom AWS X-Ray Tracing in C# Lambdas

I recently tried to use AWS X-Ray in NodeJS and C# Lambdas. My informational objects go through these both types of Lambdas, so I would like to build an entire lifecycle represented as a trace for the objects. Accordingly, in order to achieve this, I need to connect the current segment to the parent traceId. I like the option to turn off the Active Tracing flag for NodeJS Lambdas and implemented a custom tracing logic, which works well: const segment = new Segment(segmentName); const traceHeader

  1    2   3   4   5   6  ... 下一页 最后一页 共 5866 页