spot7.org logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
  Home » C# » Page 37
C# infinitive task loop using Task<> class + cancellation
Finally, get it works. class Worker { public static int threadCount { get; set; } Task[] tasks; //ex data public static string exception; static CancellationTokenSource wtoken = new CancellationTokenSource(); CancellationToken cancellationToken = wtoken.Token; public void doWork(ParameterizedThreadStart method) { try { tasks = Enumerab

Categories : C#

get value of ddl, txtbox, calendar used in user control on main page using findcontrol in asp.net c#?
Define properties in your user control, that will return values of controls you want. For example public partial class CalendarUserControl: UserControl { // this is code-behind of your user control public string Data { get {return txtData.Text;} } public DateTime CalendarDate { get {return Calendar1.SelectedDate;} } // same approach for drop down list ddlthin

Categories : C#

Force two ActionFilter attributes to be used in conjunction with one another
You can set the order in which each attribute is executed: [QuizExists(Order = 1)] // Check that quiz exists [ActiveQuizTakerSession(Order = 2)] // Check that they have an active session for this quiz [HttpGet] Here's a good reference to help you further: Order property of ActionFilter, from lowest to greatest or vice versa?

Categories : C#

Consuming a webservice returning array in C #
I guess since there are multiple elements it is treated as array. Try this: WS_FUNCSPONTO.TESTEARRAY[] qwert = new WS_FUNCSPONTO.TESTEARRAY[10]; qwert = Recebe_Cadastro.PEGAINFORM("00"); Instead of getting the response in a single element, receive it in an array.

Categories : C#

Rx with external states
You could use an instance of Subject<bool> as a state carrier. Given: Subject<bool> isUpdating = new Subject<bool>(); You will use it in something like this: var flaggedObservables = mergedObservables .CombineLatest(isUpdating, (obs, flag) => new {obs, IsUpdating = flag}); flaggedObservables .Where(data => !data.IsUpdating) .Select(data => data.obs)

Categories : C#

Windows Phone 8.1 - Bluetooth Low Energy and Authentication
I get an error when I have another app that is connected to the device. Try it like this: public async static Task<GattCommunicationStatus> WriteByte(string paramDeviceID, Guid paramService, byte paramValue) { string debug; var Services = await Windows.Devices.Enumeration.DeviceInformation.FindAllAsync(GattDeviceService.GetDeviceSelectorFromUuid([UUID HERE]), null); GattDeviceSe

Categories : C#

Datagrid binding with LINQ results? WPF
Where do you populate the gridview? Maybe this work ... public void DisplayMessage() { using ( Entities ctx = new Entities()) { var query = from e in ctx.EMPLOYEES select new { e.EMPLOYEE_ID,e.FIRST_NAME, e.LAST_NAME, e.EMAIL, e.PHONE_NUMBER, e.SALARY, e.DEPARTMENT_ID}; var results = query.ToList(); gridview.DataSource = results

Categories : C#

Find an specific element in a MongoDB document from C#
Below aggregation query may solve your problem but I don't know how to write this in C# db.collectioName.aggregate({"$unwind":"$Values"}, {"$unwind":"$Values.Parameters"}, {"$match":{"Values.Parameters.Type":"Type A"}}, {"$group":{"_id":"$Values"}})

Categories : C#

C# Code Contracts userMessage Parameter
Code Contracts (assertions, pre and post conditions, and invariants) are there to detect out-of-band operating conditions for which your code isn't designed to handle. They shouldn't be used as the first point of validation, and as a result, Contracts should not be concerned with contextualized user messages. Upstream validation in the presentation / service tiers should have already identified an

Categories : C#

How to rebind datasource to a winform DataGridView Combobox column?
Try to clear the value of accounts cell before rebind it, like this: private void companyCombobox_SelectedValueChanged(object sender, EventArgs e) { try { var currentCell = recipientsDataGrid.CurrentCellAddress; if (currentCell.X == 3) { var sendingCB = sender as DataGridViewComboBoxEditingControl; int companyId = sendingCB.SelectedValue.ToI

Categories : C#

XmlDocument to DataSet only returning 1 Row
The following example works for me: Lists list = new Lists(); //SharePoint Lists SOAP service //Perform request XmlNode result = list.GetListCollection(); //Process result var ds = new DataSet("ListsResults"); using (var reader = new StringReader(result.OuterXml)) { ds.ReadXml(reader, XmlReadMode.Auto); } //print List Titles foreach (DataRow row in ds.Tables[0].Rows) { Console.WriteL

Categories : C#

Managed Bootstrapper initializing progress indicator
Assuming you're using a custom managed bootstrapper application, there's not a way to show a progress bar during the extracting phase. However, you can show a static splash screen. To do this, you'll need to add a bitmap (.bmp) file to your bootstrapper project with a Content build action and Copy to Output Folder set to one of the copy options. Then, in your bundle.wxs file, include a SplashSc

Categories : C#

Issue with serverside filtering datetime kendo ui
I found a solution to this problem. I added a function to the data of the ajax call. There, I iterate over the filters and fetch the one that contains the date. I change its value so I can use it in my controller. Either you can use : kendo.toString(new Date(filters[m].value), "dd.MM.yyyy") Or: //this is in the *data: function(){}* of the ajax call var newout = reformDate(filters[m].value.

Categories : C#

MVC 5 not validating StringLength attribute properly
You want [Required, StringLength(6, MinimumLength = 6)] Constructor of StringLength takes in the maximum length only, so as you currently have it it checks that string is not longer than 6 characters, and therefore string of length 1 passes validation successfully.

Categories : C#

Get concrete property that implements type
If you are trying to get type that implements IBar you should get it's value and take the type: var type = instance.GetType().GetProperty("Bar").GetValue(instance,null).GetType()

Categories : C#

Call a C# .net .dll script using PHP
Option 1: Use the DLL You can call the function using PHP's COM class. You'll need to be running PHP on Windows, which I assume you are if you're using a C# DLL. Steps: Register the DLL using the command regasm yourdllname.dll in Command Prompt or the Run dialog. You have one RegAsm.exe for each version of .NET installed on your computer, so make sure to execute the one for the version of .NE

Categories : C#

Custom Validation Attribute reading from a form field
Here is code public class IsUnique : ValidationAttribute{ public override ValidationResult IsValid(object value, ValidationContext vContext) { PropertyInfo property = validationContext.ObjectType.GetProperty("Codeno"); if (property == null) return new ValidationResult(string.Format("Property '{0}' is undefined","Codeno")); var fie

Categories : C#

Error in Saving of Regarding Attribute (Lead_PhoneCall Activity) from CRM Portal (2011)?
Passing regardingobject as EntityReference is wrong.You should pass lead as EntityReference Phone.Attributes["regardingobjectid"] = new EntityReference("lead", regardingobjectid); Also Check that where lead id is coming from

Categories : C#

Get a list from an HttpContext.request object
If you do it like this you only get a char-array back from the request. You need to deserialize the content of request.Form.Get("itemList") into a List of your items, then you can loop through them. Something like this: var list = JsonConvert.DeserializeObject<List<Item>>(request.Form.Get("itemList")); You are also creating a list of type Item first, but trying to add objects of typ

Categories : C#

Can [DllImport()] handle static c libraries
DllImport works by referencing the entry as defined in the module's (.DLL) exports table. .LIB files are not modules nor do they have an exports table as per .DLLs. From MSDN: The DllImportAttribute attribute provides the information needed to call a function exported from an unmanaged DLL. As a minimum requirement, you must supply the name of the DLL containing the entry point. - Tell me mo

Categories : C#

Razor Hidden multiple properties
You can wrap all properties, that should be hidden in one object e.g.: public class SomeViewModel { public HiddenModel Hide{get; set;} ... // other properties } public class HiddenModel { public int Prop1 {get; set;} public string Prop2 {get; set;} } and then in your view: @model SomeViewModel @using(Html.BeginForm()) { @Html.TextBoxFor(m => m.prop1) @Html.Hidd

Categories : C#

c# how to get files name into a specific folder which have a specific patter
Try this: foreach (string file in Directory.EnumerateFiles(folderPath, "*CustsExport*.xml")) { } Or your can use regex: Regex reg = new Regex(@".*CustsExport.*.xml",RegexOptions.IgnoreCase); var files = Directory.GetFiles(yourPath, "*.xml") .Where(path => reg.IsMatch(path)) .ToList();

Categories : C#

Routing to a hard-coded Controller
It's because you specified: Controller = "EnvironmentTargetsView" in the second code block. If you add that to the first code block it'll work and still have a hard coded value. You could also just add something like: [Route("/api/EnvironmentTargetsView/{id}/{userGuid}] public void Get(int id, guid userGuid) { } To your controller methods.

Categories : C#

Remove all commas from a string in C# 3
Try this instead a = a.Replace("," , ""); Edit Your code is correct as far as using Replace() function goes. What you are missing is that Replace() does not modify the orignal string, it returns a new (updated) string which you should save.

Categories : C#

default property when Com interface type is IDispatch
No, default properties are very much a notion that can only apply to IDispatch derived interfaces. The late binding you use in the Debug.Print statement cannot work on IUnknown interfaces, the coclass that implements the interface doesn't have the machinery required to call a function selected by a number. Review the IDispatch::Invoke() method, that's the one that gets the job done. Using the d

Categories : C#

Why Random().Next(min, max) always generate same minimum value in ASP.NET MVC app
I think u are calling this from a multi-threaded environment? Random is not thread safe. Here are a number of ways to implement a thread safe random. http://blogs.msdn.com/b/pfxteam/archive/2009/02/19/9434171.aspx Hope this helps EDIT: Also creating a new random for each random number is bad practice.

Categories : C#

Sending dynamic form parameters to WebApi?
You can retrieve form values using a FormDataCollection. public void PostForm(FormDataCollection formdata) { foreach (KeyValuePair<string, string> formEntry in formdata) { string key = formEntry.Key; string value = formEntry.Value; } }

Categories : C#

IComparer classes for custom class
I just grabbed a compare that I use that works.. here is the gist of it... using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace MyNameSpace { public class MyComparer: IComparer<int> { public int Compare(int x, int y) { // x is greater move it up if (x > y) { return 1;

Categories : C#

Resend a message stored in error queue with RabbitMQ
You can use ServiceInsight and ServicePulse to do that. HTH

Categories : C#

Revit API building: How to put drop down list in a dialog box?
You can't add a dropdown list to a TaskDialog. TaskDialog is a class provided by the Revit API, so there are only certain aspects of it that can be customized by the user. Check the Revit API documentation to see what these are. If you need to construct a dialog box that has a dropdown list, you will need to create a custom form yourself. To accomplish what you are trying to do, you should look

Categories : C#

HTTP Error 404.0 - Not Found in MVC 5
just Write these lines of code in global.asax file of your application. protected void Application_EndRequest() { if (Context.Response.StatusCode == 404) { if ((!Request.RawUrl.Contains("style")) && (!Request.RawUrl.Contains("images"))) { Response.Clear(); if (Response.StatusCode == 404) {

Categories : C#

How to encrypt jpeg file correctly using xor operation
This problem is similar to the issues with the ECB mode of block ciphers. What happens here is that any repetition of data in your original file also results in repetition in the ciphertext. For example, if your bits are "00000..." over a long stretch, then the encrypted version will just be your key repeated over the same stretch. The pattern of repetition is preserved. (Obviously it is not a g

Categories : C#

Kendo Data Picker format Doesnot Work
If you are using Kendo API Reference in your ASP.NET Mvc. Refer below Code Script: $("#datepicker").kendoDatePicker({ format: "yyyy/MM/dd", // Provide your custom format here culture: "en-GB" // Provide your current Culture }); If it is Razor Tag or Server Tag. Server Tag: <%= Html.Kendo().DatePicker() .Name("monthpicker") .Format("MMMM yyyy")

Categories : C#

Validation not worked on kendoUI multiselect
You need to validate the Value not a list object. You may need to make below changes in your model: public class DeviceTechnologyModel { public int Id { get; set; } [Required(ErrorMessage = "*")] [Display(Name = "Device Technology")] public string Name { get; set; } [Required(ErrorMessage = "*")] [Display(Name = "Alias")] public string Ali

Categories : C#

Rectangle around selected ListView item
Here is a very basic version for an owner-drawn ListView. Set the OwnerDraw property to true and code the DrawItem event, maybe like this: private void listView1_DrawItem(object sender, DrawListViewItemEventArgs e) { e.DrawBackground(); e.DrawText(); if (e.Item.Selected) { Rectangle R = e.Bounds; R.Inflate(-1, -1); using (Pen pen = new Pen(Color.Red, 1.5

Categories : C#

GetShortPathNameW cannot find file specified
You explicitly call the Unicode version GetShortPathNameW, but do not specify the correct parameters for calling the Unicode version. Firstly, rename the method to GetShortPathName. That is enough to get it to start working, without any other changes. Your parameters are still "ANSI" strings, but that's okay, since you're calling the "ANSI" implementation. Secondly, you can add CharSet = CharSet

Categories : C#

Multibinding with convertback does not work when one converted value in UnsetValue
According to MSDN: UnsetValue is a sentinel value that is used for scenarios where the WPF property system is unable to determine a requested DependencyProperty value. UnsetValue is used rather than null, because null could be a valid property value, as well as a valid (and frequently used) DefaultValue. In fact you can't set a DependencyProperty to UnsetValue, you can just compare with it.

Categories : C#

Update Query with INNER JOIN between tables?
You have got the format of an update query with a join in it slightly wrong. Try this instead UPDATE p SET Mail_Status = 'Sent' FROM tbl_plan p INNER JOIN tbl_Assignment a ON a.Plan_ID = p.Plan_ID WHERE (DATEDIFF(dd, { fn NOW() }, Date) = 2) AND (Mail_Status IS NULL)

Categories : C#

Is it possible to create a 6400 byte integer?
You can allocate an int[] and pass that to the function. This is a hack but I don't see why it should not be safe. var array = new int[6400 / sizeof(int)]; GetDevice(..., ref array[0]); The array is pinned by the CLR for the duration of the call. Note, that ref is a so called managed pointer to the CLR. It is marshaled by passing it as a pointer and pinning the object it points to. An int[] wo

Categories : C#


Recently Add
Process MainWindowTitle not displaying for all running processes
SendGrid Tutorial resulting in Bad Request
Dropdown list from table in ASP NET MVC
Newtonsoft.JSON Serialization Array, Object, or Null
Using LINQ to select a byte array
How to stop scripting?
C# access to object property after json decode
How to kill instance of Word/Excel File in C#
Datatypes for MemoryStream.Capacity vs MemoryStream.Length
How to remove a selected row from a table when using KnockoutJS
SqlCommand returns null even tho there is data in the database
Replacing words in a body of text from array
C# dropping milliseconds from Java SOAP call
C# Deserialize list in JSON
Deserialize xml by linq, default with many elements
How to Access Grid View from hub section Data Template Windows phone 8.1 in C#
Input dialogue popup on mouse click
WPF: Binding to MainWindow Property SOLVED
Why is setting a field many times slower than getting a field?
Change multiple materials in one GameObject in Unity3D
.NET MVC error client side with custom validation attribute
Windows Search Service - text saved in ansi (codepage 1251) format - search for non-english symbols gives no result
String.Split - Omit empty array elements OR below a certain length
RequiredFieldValidator does not validate when ValidationGroup applied
Which WCF's extension point should be used for setting context for each operation?
Determine var type depending on ternary (?) Operator on int array
Resolving Windows phone 8.1 Compilation Error: GetENumerator
Specific Ordering of a List of Objects using LINQ
'string' does not contain a definition for 'Fill' and no extension method 'Fill' accepting a first argument of type 'string' could be found
how can ı pass data from serverside to clientside
© Copyright 2017 spot7.org Publishing Limited. All rights reserved.