w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
  Home » C# » Page 5
How to get values from XML?
This should give you all node11 values. It is assuming that you want ALL node11 values var OrganizationCodes = XDocument.Parse(serviceXML) .Descendants("node11") .Select(x => x.Value);

Categories : C#

WPF validation (BindingGroup).item[0] return null
Because (value as BindingGroup).Items[0] is of the type 'DataRowView', it has nothing to do with your tblTesting class. You can get the value of the first cell that corresponds to the NO property. var dataRowView = (value as BindingGroup).Items[0] as DataRowView; int no = Convert.ToInt32(dataRowView.Row[0]); if (no > 10) //do the rest...

Categories : C#

Entity Framework 6 could not create a foreign key
Taken from the vanilla instructions, is there a reason why you can't use the .PrimaryKey(t => t.Id) as part of the main CreateTable method?

Categories : C#

Suggest a way in threading that always fixed number of threads must be used in computing?
Within a static counter, you might be able to get the number of current threads. Every time you call start a task there is the possibility to use the Task.ContinueWith (http://msdn.microsoft.com/en-us/library/dd270696.aspx) to notify that it's over and you can start another one. This way there is going to be always 8 tasks running.

Categories : C#

MSOCAF Verification - Move P/Invokes to NativeMethods class
The real problem appears to be error 4. It states an incompatibility between: OfficeOpenXml.Utils.CompoundDocument.ILockBytes and OfficeOpenXml.Utils.ILockBytes So clearly one of these types was used to declare CreateILockBytesOnHGlobal, and a different type was used to declare the variable that you pass when calling CreateILockBytesOnHGlobal. You need to decide which of these two types to

Categories : C#

Column layout of RDLC Report
Your requirement calls for Matrix report. The idea is that your date values will be placed in the header of dynamic columns and projects into row headers. Here is the explanation.

Categories : C#

Programmatically format a cell as a checkbox
This is an example using cell B9 It is implemented using Double-click rather than Single-click Enter the following event macro in the worksheet code area: Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) Dim B9 As Range Set B9 = Range("B9") If Intersect(B9, Target) Is Nothing Then Exit Sub B9.Font.Name = "Marlett" Cancel = True If B9.Valu

Categories : C#

Swipe gestures in Windows Phone 8.1
OnManipulationCompleted is probably a method provided by your base class its signature does not match. I suspect that you need to change the name to avoid a conflict such as: mainGrid.ManipulationCompleted += MainGridManipulationCompleted; public void MainGridManipulationCompleted(object sender, ManipulationCompletedEventArgs e) { var velocities = e.Velocities; }

Categories : C#

How to ignore "ease of access" settings on Windows Phone?
It's a common bug in apps that they ignore the high contrast settings and hardcode their own colours. So yes: you can do this by doing the wrong thing and hardcoding your settings instead of using the system resources. You can override most system brushes in your app resources in app.xaml and you can hardcode colours in your Xaml and control styles. That said, please use this for good not evil.

Categories : C#

itextsharp, issue with PDFtable constructor
The class you need is PdfPTable, not PdfTable (mind the extra P). Please let me know if you have found a tutorial where it says: PdfTable table = new PdfTable(5); I will personally contact the author trying to convince him to stop publishing non sense ;-) PdfTable used to be a class in a very old version of iTextSharp (a version that should no longer be used). It was an internal helper class f

Categories : C#

How to reverse a string that contains Hebrew letters and numbers?
public static string Reverse(string t) { char[] charArray = t.ToCharArray(); string a = ""; int last = 0; for (int i = 0; i <= charArray.Length-1; i++) { if (!IsHebrew(charArray[i])) { List<char> temp = new List<char>(); for (; last < i; last++) {

Categories : C#

How to insert single value in single cell to CSV file?
The code is working fine because the result is: TobRod Porosity,Batch code,Nu.,PAD,G.Po,L.PoD Col1 Row 2,Col2 Row 2,Col3 Row 2 Can you confirm this? Here is how it is displayed on my PC: If you see all the values in a single cell on your machine, this means that there is a problem identifying the correct separator. In order to fix this, add this line: sep=, at the beginning of your CSV con

Categories : C#

select every x elements of a list in c#
Use Skip and Taks int count = 0; while(count < originalList.Count / 5) { var list = originalList.Skip(count * 5).Take(5); //now you have 5 elements in list, and with them you can operate. //please be aware to check if list has 5 elements. count++; }

Categories : C#

parallel execution using selenium and c# in VSTS integrating with MTM
You can only have a single instance of a browser based Coded UI test. In order to run multiple tests, you will need to have multiple test agents and then send tests to each agent from the Test Controller.

Categories : C#

unable to read data from the transport connection the connection was closed
I suggest that you get the html/texts first to your local machine before you load it to your agility pack. you can use HttpWebRequest it has timeout property if you really need to adjust it. look on this >> How can I download HTML source in C#

Categories : C#

How to access data in ObservableCollection from ViewModel?
I advise you to read through the Data Binding Overview page on MSDN first... you need to learn about data binding. A typical set up would look like this: Your view model: public ObservableCollection<User> Users { get { return users; } set { users = value; NotifyPropertyChanged("Users"); } } public User SelectedUser { get { return user; } set { user = value; NotifyPropertyC

Categories : C#

Datepicker and allowing multiple input formats
Throwing exceptions each step costs a lot performance. Get rid of try{} catch{}, the for loop and use the very user-friendly TryParseExact. It will accept your 'checks' array variable. if(DateTime.TryParseExact(value as string, checks, CultureInfo.InvariantCulture, DateTimeStyles.None, out dt)) { // success }

Categories : C#

Extension for IEnumerable
One possible kick-it-in-the-teeth solution is to force it back to an object before casting to an Enum: public static String Humanize<T>(this IEnumerable<T> source) where T : struct, IConvertible { return String.Join(", ", source.Cast<T>().Select(x => ((Enum)((object)x)).Attribute<DescriptionAttribute>().Description)); } This worked for me and printed the descripti

Categories : C#

Mapping platform specific interoperable types
INT_PTR and LONG_PTR are the same size as a pointer. So, they will be 32 bits wide in 32 bit targets, and 64 bits wide in 64 bit targets. It is simply wrong in C# to use either int or long since they have fixed sizes. The correct translation for both INT_PTR and LONG_PTR to C# is as IntPtr. Similarly, for the unsigned variants, use UIntPtr.

Categories : C#

Microsoft.Office.Interop.Outlook temporarily change email body
It sounds like you want to preseve the original message body of the source item that is replied to in the replied/forwarded message that is sent out. To do so you'd need to store the original MailItem.HTMLBody property value in a custom property within the outgoing message. You can do that by adding a UserProperty to the MailItem.UserProperties collection. However, there is a limit to the size

Categories : C#

Support for both reference types and value types
I think if you remove the cast to T on this line var obj = HttpContext.Current.Cache[key]; you should be fine. public static class CacheHelper<T> { public static T Get(string key, Func<T> function) { var obj = HttpContext.Current.Cache[key]; if (obj == null) { obj = function.Invoke(); HttpContext.Current.Cache.Add(key, obj, null, Dat

Categories : C#

How to get Tfs WorkItem AssignedTo email address using IdentityManagementService while having same DisplayName value for multiple WorkItems?
If you catch "MultipleIdentitiesFoundException" exception , the variable gives you an option to select the unique identity. catch(MultipleIdentitiesFoundException ex){var workItemIdentity = ex.MatchingIdentities[0].UniqueName;} This is just a workaround. its little difficult which one would be valid identity at that moment. But this generally happens if the same use has email address in two di

Categories : C#

log4net writes to wrong logfile after external dll call
What is certainly happening is that the library you are calling triggers a reconfiguration on the main log4net repository. This configuration may be loaded from another configuration file than the one you defined, or programmatically. You have some options: if you have the code for the assembly, use the RepositoryAttribute to specify a custom repository for all loggers in the assembly. This way

Categories : C#

.net MVC identity ... getting data enter by a specific user
As Muecke suggests in the comments, you are currently returning an IQueriable instead of IEnumerable. So adding ToList() should solve this problem. You may also want to add a return View(empList.ToList()) In addition, you may want to return the results sorted, by adding an order by to your query, or add it here: return View(empList.SortBy(o=>o.Name).ToList()) Note also that it's confus

Categories : C#

static class self reference
For the first part of your question, it sounds like you just want static fields or properties, e.g. public class Foo { // A field... public static readonly Foo MyFunkyFooField = new Foo(...); // A property - which could return a field, or create a new instance // each time. public static Foo MyFunkyFooProperty { get { return ...; } } } For the second part, using a string li

Categories : C#

Nested for loop in View in MVC
var SubGrpDisplayDocs = (from m in dtGrpDisplays.AsEnumerable() select m).ToList(); var DtDownloads = (from m in DtDownloads.AsEnumerable() select m).ToList(); ViewBag.Data = from m in SubGrpDisplayDocs join n in DtDownloads on m.GroupID equals n.GroupID

Categories : C#

Back button to previous partialview
First Way: I think the best way to do that with browser Back button is to use history.pushState How to implement it depends on your situation on View. Some links about pushState: http://rosspenman.com/pushstate-jquery/ https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Manipulating_the_browser_history Second Way: If you don't want to use browsers Back buttom you can use js: function

Categories : C#

Optimise and speed up very slow Linq / SQL code
from p in data.Products where p.Deleted == false join s in data.ProductStocks on p.ProductID equals s.ProductID group s by p into g select new { g } What is the schema of the Products and ProductStocks tables? What indexes do you have? start by reading How to analyse SQL Server performance. Some things stand out immediate: y

Categories : C#

How to install application in custom folder using wix installer,other than Program Files folder
I found this tip on kentie.net - Wix Tips & Tricks. Tips said to use the WINDOWSVOLUME id. TARGETDIR and the system partition When trying to install to a subdirectory of the system drive root (e.g. 'C:application'), it might sense to assume that in something like <Directory Id="TARGETDIR" Name="SourceDir"> <Directory Id="INSTALLLOCATION" Name="SetupProject1">

Categories : C#

name WebRequestMethods does not exist in current context and FTPWebResopnce could not be found
Please consider referencing System Assembly and add System.Mail namespace in your code. EDIT:- The .NET Compact framework doesn't support System.Net.Mail or System.Web.Mail. You should probably look for extensions.

Categories : C#

C# red cross in datagridview
In YourForm.Designer.cs look for string gridView = new DataGridView() and replace it with gridView = new SafeDataGridView() private SafeDataGridView portos_online; portos_online = new SafeDataGridView(); I hope this will solve your problem. Have a nice day!

Categories : C#

BinaryFormatter deserialize multiple objects from a stream
So I had built a second project to test if my Server even recive data and used a packet sniffer on localhost to confirm it. The class I now use to recive did nothing else. Only that it has a while loop that deserialize the stream over and over again. This solved my problem. It seems like the BinaryFormatter is albe to seek for the objects in the stream and deserialize every object without knowing

Categories : C#

CodeFirst mapping relationship between entities
You can use Fluent API protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Entity<Person>() .HasRequired(a => a.Title); }

Categories : C#

How to cache the image of the control?
This will help: Bitmap getControlSurface(Control ctl) { bitmap = new Bitmap(ctl.Width, ctl.Height); using (Graphics g = Graphics.FromImage(bitmap)) { Point pScreen = PointToScreen(ctl.Location); g.CopyFromScreen(pScreen, Point.Empty, ctl.Size); } return bitmap; } If you know when the surface has been refreshed you can use it like this: if ( pictureBox1.Ima

Categories : C#

How to dynamic url mapping in asp.net with c#?
This solution is pretty intense, but a valid one nevertheless. We had the same issue in my work some years ago (before we moved to ASP.NET MVC, which I strongly recommend). First, we made a a new ASP.NET Module (and registered it on IIS or the Web.config). This module would receive the incoming client's requests. We built our own HttpModule and made it work along a configuration file, where we

Categories : C#

MVC 5 request domain url
This is what I use in my solution var currentURL = Request.Url.Scheme + System.Uri.SchemeDelimiter + Request.Url.Host ; This will return http://www.domain.com There may be a way to do this better, but this works for me. Thanks Alan

Categories : C#

Is there any way to track User logins without simplemembership in mvc3 application?
Assuming you have a login facility already, you can simply extend your business logic to implement a new InsertHistory method and call this in the same controller function that handles the POST when logging in.

Categories : C#

Get Parameters of sqlcommand to string
cmdMarineResort.Parameters is a SqlParameterCollection. You can iterate through it using a foreach statement: foreach(SqlParameter Para in cmdMarineResort.Parameters) { Console.WriteLine((string)Para.Value); //value of the parameter as an object }

Categories : C#

setting the DataContex correctly
You can do directly in the code-behind of your control (in the default constructor) public VehicleSelectionBlock() { InitializeComponent(); this.DataContext = new MyUserContlorViewModel (); } You can also do that in XAML (http://msdn.microsoft.com/en-us/library/ms746695(v=vs.110).aspx) declaration, as you wish.

Categories : C#




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.