.net

Create a combo command line / Windows service app

What's the best way in C# to set up a utility app that can be run from the command line and produce some output (or write to a file), but that could be run as a Windows service as well to do its job in the background (e.g. monitoring a directory, or whatever). I would like to write the code once and be able to either call it interactive...

InterpolationMode.High

I am trying to figure out the difference between High and HighQualityBicubic InterpolationMode in .Net (System.Drawing.Drawing2D.InterpolationMode.High). Does High mean that it will pick the best algorithm based on the image and what you are doing with it? Is it just an alias for HighQualityBicubic? Something else? According to the MS...

Handling states and countries (or provinces): best way to implement

In my career I have seen literally dozens of ways that people choose to handle implementing state and country data (as in NY or USA). I've seen enumerations, multi-dimensional arrays, data driven classes from XML docs or databases, and good old-fashioned strings. So, I'm wondering, what do people consider the "best way" to handle this ...

.NET System.OutOfMemoryException on String.Split() of 120 MB CSV file

I am using C# to read a ~120 MB plain-text CSV file. Initially I did the parsing by reading it line-by-line, but recently determined that reading the entire file contents into memory first was multiple times faster. The parsing is already quite slow because the CSV has commas embedded inside quotes, which means I have to use a regex spli...

Windows Mobile- only keeping one form open. Best design question

So I would consider myself a .Net and ASP.NET pro but I am a bit new to Windows Mobile (I am targeting .net 3.5 CF and Windows Mobile 6). I am creating a data driven application that will have 3-4 tables. I have created a form for each table that allows the user to search through the table. Each form inheretes from the Main form so th...

.NET WPF MissingMethodException when launching new thread

I have a WPF application with a form that, when started, invokes a custom method in a new thread. Private Sub TestStep1_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded Dim oThread As New Thread(AddressOf DisplayNextPicture) oThread.Start() End Sub Private Sub DisplayNextPicture() ...

flex and .net 2.0 web service, how to allow access from other domains?

I created a proyect in flex builder with application server type set to none when I debugg, I can acces the web service from my local machine thats on a site http://mysite.com/ws/ws.aspx?wsdl when I upload the flex app to mysite.com/myapp.html it works great but when I upload it to myapp.mysite.com/myapp.html it wont access the web se...

winforms: How to send email using default email client?

I want to send an email from a .net windows forms application using the system's default email client (thunderbird, outlook, etc.). I'd like to preset the subject and body text -- I think there's a way to do this by sending something like this to windows explorer: "mailto:[email protected]?subject=mysubject&body=mymessage". Do you hav...

How to TOP, ORDER BY and DISTINCT in the same query with Linq-To-Sql?

How to translate the following query to Linq? SELECT DISTINCT TOP 10 A.*,A.X+A.Y AS SUMXY FROM TABLE_A AS A INNER JOIN TABLE_B AS B ON A.ID = B.AID ORDER BY SUMXY I don't want to split in two queries. ...

How do I insert a bit of XML into an XDocument using Visual Basic?

I'm trying to create a sitemap in an ASP.NET MVC project. This code in my Node controller... Function Sitemap() As ContentResult Dim db As New EfrDotOrgEntities Dim Nodes = db.Node.ToList Dim RequestUrl As Uri = Url.RequestContext.HttpContext.Request.Url Dim AbsoluteRoot As String = String.Format("{0}://{1}", RequestUrl...

Learning Python on Windows for TDD

I'm interested in learning python to have access to a more agile language for writing tests in my .NET projects. Is IronPython mature enough for these purposes yet? I'm content with writing tests in C#, but find dynamic languages like ruby and python very attractive. Would it be better to forgo IronPython while learning, and stick to t...

Assembly.LoadFrom - using Evidence overload to verify strong name signature

Is it possible to use the Assembly.LoadFrom overload with the Evidence parameter to ensure the assembly is strongly named? I want to be able to specify the assembly name, culture, version, and public key token. If any of this information does not match the assembly should fail to load. ...

Refactoring with Lambda's and Delegates

I've just installed VS2008 and have run into a problem that I'm sure can be solved with either lambda's or delegates (or a combination!). private string ReadData(TcpClient s, string terminator) { // Reads a byte steam into a string builder until either data is unavailable or the terminator has not been reached va...

reading CDATA with linq to xml

Hello Everyone, I have the following xml file and cannot seem to figure out how to get the value in the elements (which are buried in a CDATA). I am trying to use linq to xml for this. If someone knows how you would convert this into a "Product" object (assume we have a product object that has properties with the same names as the ele...

Search for whole word with Linq to SQL

Hi, I'm using VB.NET and Linq to SQL to do search query. I'm using the Contains method of Linq to look up the input keyword. It's like this note.note_content.Contains(InputKeyWord). The problem is that If I search for the "cord" then "according" will also come up. I want the result to be matched with keyword only. How do I do to sear...

.Net/Mono Singleton (Service/Server?) in C# - detect if my .net app is already running and pass command-line args to it.

I'd like to create a simple singleton commandline application (a service?) in C# that when it was run, it checked to see if it was already running, and if so, it passed the command-line args to the already running instance and closed itself. Now in the already running instance it would receive the command-line args through an event like ...

Passing a parameter using RelayCommand defined in the ViewModel (from Josh Smith example)

I would like to pass a parameter defined in the XAML (View) of my application to the ViewModel class by using the RelayCommand. I followed Josh Smith's excellent article on MVVM and have implemented the following. XAML Code <Button Command="{Binding Path=ACommandWithAParameter}" CommandParameter="Orange" ...

Can a WinForm execute a console program? If so, how?

Duplicate: http://stackoverflow.com/questions/240171/launching-a-application-exe-from-c/240189#240189 Hi folks, i have a free command line tool called FW Tools. Works great. Here is a sample line i enter in the console window :- ogr2ogr -f "ESRI Shapefile" -a_srs "EPSG:26986" -t_srs "EPSG:4326" towns_geodetic.shp TOWNSSURVEY_POLY....

How exception handling mechanishm really works in .net?

I wonder, How exception handling mechanishm actualy works in .net? Just want to know, what happens in runtime internally? ...

How to uniquify resultset from NHibernate

Hi I have this multi-criteria, which works very well, except that I'm getting multiple of the same entities in the collections. I know this is by design, and I know you should be able to use a ResultTransformer to avoid it or filtering through a hashed set after quering. My query looks like this: IMultiCriteria criteria = session.Crea...