.net

Why does my .NET Windows service not start automatically sometimes?

Hi all, I have modified a working Windows service that had always been starting beforehand. After adding the System.Management reference it now sometimes will not start automatically. I get the following error: Service cannot be started. System.Runtime.InteropServices.COMException (0x80010002): Call was canceled by the message...

Getting a NullReferenceException Error when invoking a Select File Dialog Box

Hey everyone This is a real newbie question. I have simple app that selects a picture and display's that picture in a PictureBox. I decided to mess with the Opacity Attribute so I added a timer and created this cool effect where the Main Form's Opacity is increased by 20% every 400 miliseconds. The problem is that now when I click t...

Can I serialize Anonymous Types as xml?

I understood that anonymous types are marked private by the compiler and the properties are read-only. Is there a way to serialize them to xml (without deserialize) ? It works with JSON, how can I do it with XML? ...

Polymorphic Numerics on .Net and In C#

It's a real shame that in .Net there is no polymorphism for numbers, i.e. no INumeric interface that unifies the different kinds of numerical types such as bool, byte, uint, int, etc. In the extreme one would like a complete package of abstract algebra types. Joe Duffy has an article about the issue: http://www.bluebytesoftware.com/blo...

Converting sql query to EF query- nested query in from

Hey guys Just wondering how the following sql query would look in linq for Entity Framework... SELECT KPI.* FROM KeyPerformanceIndicator KPI INNER JOIN ( SELECT SPP.SportProgramPlanId FROM SportProgramPlan PSPP INNER JOIN SportProgramPlan ASPP ON (PSPP.SportProgramPlanId = @Sport...

exception with Linq to SQL using sdf file

Hi, I've set up a project with an SDF local database file and am trying to access it using an LINQ To SQL (".dbml") file. I have used the connection string provided by the sdf file and can instanciate the object with out a problem: thisDataContext = new MyDataContext(GetConnectionString()); However, whenever i try to access any inform...

.NET Hashtable - "Same" key, different hashes

Is it possible for two .net strings to have different hashes? I have a Hashtable with amongst others the key "path". When I loop through the elements in the table to print it, i can see that the key exists. When trying to looking it up however, there is no matching element. Debugging suggests that the string I'm looking for has a differ...

Splitcontainer, Make a fixed panel

I have a splitcontainer with horizontal orientation. I want a fixed height for panel2 only during form resize, and let splitter resize panel2 Now I'm doing it this way, but I'm not satisfy because user notice that the panel resize Private Sub Form1_ResizeBegin(ByVal sender As Object, ByVal e As System.EventArgs) _ Handles Me.ResizeBe...

Can I get parameter names/values procedurally from the currently executing function?

I would like to do something like this: public MyFunction(int integerParameter, string stringParameter){ //Do this: LogParameters(); //Instead of this: //Log.Debug("integerParameter: " + integerParameter + // ", stringParameter: " + stringParameter); } public LogParameters(){ //Look up 1 level in the ...

Does the .NET CLR Really Optimize for the Current Processor

When I read about the performance of JITted languages like C# or Java, authors usually say that they should/could theoretically outperform many native-compiled applications. The theory being that native applications are usually just compiled for a processor family (like x86), so the compiler cannot make certain optimizations as they may...

How do you pass .net objects values around in F#?

I am currently learning F# and functional programming in general (from a C# background) and I have a question about using .net CLR objects during my processing. The best way to describe my problem will be to give an example: let xml = new XmlDocument() |> fun doc -> doc.Load("report.xml"); doc let xsl = new XslCompiledTra...

Future of Linq to Sql and Entity Framework

I work on a project and want to use an ORM. What should I use: Linq to Sql or Entity Framework? Linq to Sql provides more opportunities, as I see, for example support for enumeration types. However, also it is said that, Linq to Sql was for playing and learning for Linq and future strategy of Microsoft lies on Entity Framework. So which ...

(New Object()).Method() in VB.net

Apparently this does not work. WHY ??????? I don't want to do all this just to call my function: Dim x as new Object() x.Method() WHY do I have to do this in 2 lines when I can in one. This is really pissing me off. ...

Thread Sleep and Windows Services

I'm working on a Windows Service that's having some issues with Thread.Sleep() so I figured I would try to use a timer instead as this question recommends: http://stackoverflow.com/questions/998142/using-thread-sleep-in-a-windows-service Thing is it's not entirely clear to me how one might implement this. I believe this is the way but ...

CSV Parser in one routine/function?

I know there are several libraries of code out there that can parse CSV files according to the standard, but, for various reasons, I need one simple routine (not an entire library) that parses a CSV into a DataTable or array. Does such an animal exist or is it extinct? (Preferably C# but i can translate vb.net too) ...

What is the right approach to checksumming UDP packets

I'm building UDP server application in C#. I've come across a packet checksum problem. As you probably know, each packet should carry some simple way of telling receiver if packet data is intact. Now, UDP already has 2-byte checksum as part of header, which is optional, at least in IPv4 world. Alternative method is to have custom check...

Active Directory Programming help needed

Hello Friends, I want to make Windows Service in .NET which has to run on Windows Server 2003, 2008. The main functionalities i need are: As soon as a network user logs in, Display his: User name in Active Directory Domain Ip Address from where he connected I do not want to install or run any program/script on the client machine. ...

FormCollection in VB.NET

Hi, I want to detect if a window form is open and if it is then I would like to bring it in front rather than opening it again. I know I need a form collection for this but I want to know if there is a built in form collection that holds all the forms in VB.NET or I need to implement my own. Thank you. ...

Using .NET C#, I need to create a simple program that responds whenever it picks up any sound from the microphone input.

I am trying to create a program that will sit and wait until it picks up on any sound (i.e. a doorbell), and in response, triggers an event function that I can use to run some code. My exact goal is to have it run wmplayer playing a sound of a dog barking whenever it picks up something as loud as a doorbell from the microphone input. ...

Setting Cookie Port

I'm trying to set the port on a cookie in ASP.NET (code below), but I'm getting a very unusual error at runtime (below the code). Any thoughts? target.Cookie = new Cookie { Comment = "Test Comment", CommentUri = new System.Uri("http://www.tempuri.org"), Discard = false, Domain = "tempuri.com", Expired = false, Ex...