I'm writting a VB.Net app that interacts with a CAN bus in order to control some motors that are on it. With the CAN bus I can turn on and off each motor, in normal and reverse mode, and read their current consumption. I have implemented two checkbox
When using entity framework, is it bad practice to inject the repository into a controller? For example if I have a service: public class DogService { IMyDbContext _myDbContext; public DogService(IMyDbContext myDbContext) { _myDbContext = myDbContext
I am converting datatable into xml. DataSet dataSet1 = new DataSet("Products"); products.TableName = "Product"; dataSet1.Tables.Add(products); dataSet1.WriteXml(directory + "//matrix.xml"); The code is working fine. I just wa
I have a bunch of users, with a given start and end time, e.g.: { Name = "Peter", StartTime = "10:30", EndTime = "11:00" }, { Name = "Dana", StartTime = "11:00", EndTime = "12:30" }, { Name = &qu
Here is an example of what I am looking to do. public class A { public virtual void DoSomething(string a) { // perform something } } public class B : A { public Override void DoSomething(string a, string b) { // perform something slightly different u
I often use library functions like File.Exists to check for a file's existence before opening it or doing some other action. While I have had good luck with this in practice over the years, I wonder if it is a poorly thought-out pattern. Any IO call
Our application has the notion of a PermissionAttribute. This attribute is defined in a base layer of our application and our commands and queries are decorated with that attribute. Since this attribute is defined in base layer we can't (and don't wa
We all know that VB's Nothing is similar, but not equivalent, to C#'s null. (If you are not aware of that, have a look at this answer first.) Just out of curiosity, I'd like to know the following: Is there a VB.NET expression that always yields null?
Look at the following (pseudo) pattern: public abstract class Animal { public abstract AnimalType { get; } public abstract override string ToString() { return String.Format("{0}={1}", AnimalType, this.ToString()); ^ // does this even work? } } w
Is it possible to add a character to the assembly version? ex 10.1.1.1a ?No. Assembly versions (specified by AssemblyVersionAttribute) follow the System.Version system, which is strictly four numbers. However, you can use AssemblyInformationalVersion
On Windows 8 using Visual Studio 2012 RC on a german system, I get all my Exceptions localized to german, which effectively means I can't google anything useful for them. To solve this, I already used the following to change my IDE to english languag
Using the Newtonsoft.Json library, imagine I have got public class Test { public Object Obj { get; set; } } Now, attempting to serialize this like so var json = JsonConvert.SerializeObject(new Test(){ Obj = new Uri(@"http://www.google.com") });
To improve application error handling I would like to log exceptions stack traces and variables values of each stack level. I've searched for Reflection but couldn't find anything. How can I see the variables?Without using additional tools (such as c
I am migrating an application from Silverlight to Windows 8 and I wanted to take advantage of the System.Theading.Tasks API. I have a number of classes that have a Start() method and fire off a Completed event when they are done. Would anyone know ho
Is there an equivalent to the continue statement in ForEach method? List<string> lst = GetIdList(); lst.ForEach(id => { try { var article = GetArticle(id); if (article.author.contains("Twain")) { //want to jump out of the foreach now //
As part of installing my windows service I have coded an alternative to installutil and the command line: IDictionary state = new Hashtable(); using (AssemblyInstaller inst = new AssemblyInstaller(typeof(MyServiceClass).Assembly, args)) { IDictionary
What is the recommended approach to take with Nhibernate + Repository pattern? There are so many different articles and opinions around that I am not sure what path to take. Take this lengthy article, for example. It gives an example of Query objects
in .NET, when I add two SqlDecimals, like so: SqlDecimal s1 = new SqlDecimal(1); SqlDecimal s2 = new SqlDecimal(1); SqlDecimal s3 = s1 + s2; then s3 has precision 2, whereas both s1 and s2 have precision 1. This seems odd, especially as the documenta
I am working with Windows Forms, and many times have bumped into (as I understood it) the necessity to write wrapping functions around properties of the UI components, so that they (the properties) could be set from another thread by invoking their w
I made a win form and give some checkboxes that show the courses avilable for the student and by checing the checkbox he will able to tell that which courses he want to do but i want to restirct him when he check the three courses and if he try to ch
I am a newly graduated programmer. I have done many web pages and services with Php. I took a project as a freelancer. My employer want the web site to be coded mainly with Php. He took another employee as a iphone developer. iphone developer guy wan
Is there 64 bit version of AzMan? We have an app that uses Microsoft.Interop.Security.AzRoles.dll.Is there a 64 version of this ?I'm not sure about Windows 7 as I don't have a box to check but as far as Server 2008 R2 goes, the answer you're looking
This question already has an answer here: What is a NullReferenceException, and how do I fix it? 33 answers Edit: The line of code that gives the exception is "foreach (Column column in table.Columns) " and that's because the Table table object
On a Windows PC in Japan, this line of C# throws a format exception: double d = double.Parse("NaN"); This line executes fine on my PC in the U.S. Don't know where to begin troubleshooting this one. Any thoughts? Thanks in advance, JimI see what
We're writing an SDK for a CAD program and have run into a slight disagreement regarding a specific type of function (not just disagreement between different people, also disagreement between my two brain-halves). Imagine there's a lot of classes for
Why in ASP.NET MVC is it when I use a: return this.RedirectToAction("Index", "Page", new { pageKey = "test/ho/hum"}) or using the MVCContrib extension: return this.RedirectToAction<PageController>(c => c.Index("
I have a Windows.Forms component which has a "mySize" property that returns a Size struct. My intention was to have this property calculate the returned mySize automatically based on the size of the component, unless mySize has been explicity se
My WinForms app uses the mouse wheel, subscribing to the Control.MouseWheel event. How can I get it to work with scrolling methods from other input devices, in particular "finger along the edge" scrolling on the (Synaptics) trackpad on my T61? I
In the MVC folder structure, where should general class files reside? For example, I have a class that determines the right DataContext to use, so I'm not reinventing the wheel in each of my controllers. Should it live in the Controllers folder even
Is there a list somewhere on common Attributes which are used in objects like Serializable? Thanks Edit ~ The reason I asked is that I came across an StoredProcedure attribute in ntiers ORMS.Yes, look msdn has you covered please look here. EDIT: This