.net

XmlTextWriter serialization problem

I'm trying to create a piece of xml. I've created the dataclasses with xsd.exe. The root class is MESSAGE. So after creating a MESSAGE and filling all its properties, I serialize it like this: serializer = new XmlSerializer(typeof(Xsd.MESSAGE)); StringWriter sw = new StringWriter(); serializer.Serialize(sw, response); string xml = sw.T...

Workflow for Polling Application?

I am currently working on a new application (.Net 3.5/Win2008 Server environment) that does a nightly poll of a database table to find records that need processing. Very simple process overall. Previously, I have used a Windows Service "Shell" app to do the timer/sleep/poll process. My question is more of: Since I have the opportunity t...

C# List<> Order with 3 properties .Net 2.0

Hi, Say I have a Person class with Name, Age, Level properties. I know how to order by one of the properties, with PersonList.Sort(delegate(Person p1, Person p2) { return p1.Name.CompareTo(p2.Name); }); But how can I order by Name, Age and Level. An equivalente of the sql sentence : ORDER BY Name, Age, ...

.net web service using SSL. wcf ?

Hi, I was asked to set up a .NET web service to expose a few methods for querying a database, which isn't a difficult task, but they said they wanted it secured using SSL since it is not internal. How does one use SSL with a web service? And is this something to use WCF for, or should I stick with a .net 2.0 web service? Thanks in ad...

CryptAPI native Interop with .NET Code

Hi, I have managed to encrypt data in native code using the Crypto API and decrypt this in .NET (C#) code, using RC2 algorithm and SHA for creating a key. This is the native code (Delphi in this case): // Get handle to CSP If Not CryptAcquireContext(hCryptProv, nil, nil, PROV_RSA_FULL, 0) Then If Not CryptAcquireContext(hCryptProv...

Creating a trouble shooting web page with a series of ?s in asp.net. Directed Graph

I've been working on my first web page which will be used as a trouble shooting guide based on a series of questions. The questions are determined by the answer of the previous question, so it turns into a "choose your own adventure". Luckily I was given a decision flow chart showing all the possible paths, but it looks like the Tokyo ...

How Create a .NET HttpWebRequest class from a Socket's recieved byte[]'s

Hi all, I have a socket that is receiving HTTP requests. So I have a raw http request in byte[] form from my socket. I have to study this request - BUT Instead of reinventing the wheel - can I 'cast' this byte array into a System.Net.HttpWebRequest or something similar? Thanks! ----- UPDATE --------- So anyway I couldn't find the ...

Batch SQL inserts in .NET

Is using the .NET DataAdapter's batch insert features any more efficient, as far as DB round-trips, compared to using DbCommand.ExecuteNonQuery() in a loop? Coming from the Java world, I was hoping to find something similar to it's batch abilities where multiple SQL commands are sent to the database and executed in one operation. When ...

How to stop a Windows Forms Button being clicked twice

I've got a Windows Forms Button on a Form which submits a web request. I want to be able to disable the button when it is first clicked and then re-enable it when I get a response. I don't have much control over the code that is being called and how it is being called so all I can play around with are Button events or I can create my own...

Code Examples - the logic layer and service

Hello, I am looking for sample projects/ project templates. which show an N-Teir application (perferably in C# but do not mind Java). so far i have found the following: S#arp Architecture - which i think is awesome DotFactory Patterens in Action - I have the .Net 2.0 copy, exellent, but it only shows crud do you know any samples whi...

.NET remote/work from home contract resources...that pay well.

I currently work on contract/consulting on site for various local subcontracting firms. I've been making a effort to grow into my own company and one of the things I'd like to start doing is working form my own office at home. I've located sites like www.odesk.com www.elance.com but dear Lord they don't pay well. A quick perusal of th...

To new() or to Clear(), that is the question.

At my current workplace, I run across a lot of code that looks similar to the following example: private void GetWidgets(ref List<Widget> widgets){ if(widgets == null){ widgets = new List<Widget>(); } else{ widgets.Clear(); } ... code to fill widget list } and public class Widgets{ private List <Widget> widget...

How can I add a probingPath at runtime (and not through app.config)?

I need to add an assembly probing path at runtime, not through the element in app.config. Is there a way to do this? The reason is so that my XOML-only workflow that resides in it's own folder can know where to find it's related DLLs (i.e. containing custom Activities). Currently I am getting fusion errors because the CLR is probing t...

Is there any benefit to using char instead of string for single-character values?

For .NET fields and properties that by definition only contain a single character, is there any benefit to defining them as char instead of string? Or is that an incorrect use of the char data type? I'm thinking of a field that can hold an M or F for sex, or a middle initial, or an indicator stored in the database as a Y or N. I typical...

SQL Reporting Service Report Image Error

For a quick temporary solution I made an image of a form that the users wanted to have programatically filled out. I then embedded that image in a report and filled the page with the image. I then put the fields on top of the image to fill out the areas in the form that needs filling. I realize this may not be the best solution, but it w...

Best practice for adding controls at run-time

When adding controls to a form at runtime, you can do either of the following: Button btn = new Button(); //... this.Controls.Add(btn); or Button x = new Button(); //... btn.Parent = this; I had assumed that they were the same, and it was just down to personal preference which way to do it, but someone at work mentioned that the se...

.Net - Remove dots from the path

How can I convert "c:\foo\..\bar" into "c:\bar"? ...

Limitations to recording changes in a bound dataGridView to a dataTable

Hello, I was under the impression that upon binding a dataGridView object to a dataTable that any changes the user makes in the dataGridView are then recorded in the dataTable. These changes include switches in column order, sorting, and the addition and deletion of rows. However, this does not seem to be the case. I am finding that ...

Is it possible to intercept WIN32 Exceptions for 3rd party applications?

Is it possible to intercept WIN32 exceptions for 3rd party applications? I have a particularly bad behaving 3rd party application for which I'm try to intercept unhandled exceptions so I can know that I need to kill the process but I'm finding it hard to find anything about this subject that seems to fit what I need. Any help would be...

Referencing a 3rd Party class library within a SQL Clr Class

I am creating a SQL CLR assembly that needs to use a Third Party assembly inside it. The trouble is I cannot reference this assembly as only ones already deployed to SQL or other SQL project references are allowed. Is it possible to use 3rd party assemblies in a SQL CLR assembly and if so how? Thanks in advance. ...