.net

How to stop a service within the OnStart method?

I'm writing a windows service in .net 2.0. What should I do within the OnStart method if for some reason I don't want it to start? Can I simply call the Stop() method of the base class (ServiceBase)? I've tried that and am getting some funny memory access exceptions. Is it required to start a separate thread to call the Stop() method? ...

2-way encryption from int into a short string

Hi guys. I'm building a tiny webapplication in which our customers can update some details about their company. The customers currently don't have a login/password and we don't want to validate their registration, so we want to give them a automaticly generated password/key to login to the website. Our plan to encrypt their customerId ...

Convert string to integer

I need help in my code. I would like to write only numbers/integer in my textbox and would like to display that in my listbox. Could someone please check my code below. This seems to give an error. int yourInteger; string newItem; newItem = textBox1.Text.Trim(); if ( newItem == Convert.ToInt32(textBox1.Text)) { ...

Using Matlab & Simulink models in .NET

Hi, I am creating a quite complex digital filter in Simulink. For testing I generate a .txt file i .NET application and use this file as a source in Simulink model. Does anyone know whether it is possible to generate a Simulink model, define input and output and then connect it with .NET application? ...

How to generate double value from TimeSpan

Hi, I have to calculate the relative time which is TimeSpan relativeTime = currentTime.Subtract(startTime); Next I would like to convert relativeTime to double value which should be consisted of seconds and milliseconds (seconds.milliseconds). Does anyone know what is the best way to generate such double value from time difference? ...

How do i extract data from an DotNetOpenID AX attribute?

Hi folks, Andrew Arnott has a post here about how to extract the attribute exchange extension data, from an OpenId proivder. Here's a snippet of the code :- var fetch = openid.Response.GetExtension<FetchResponse>(); if (fetch != null) { IList<string> emailAddresses = fetch.GetAttribute (Well...

Multiple SQL Transactional Commands Across Different Database Connections

I am using the .NET 2.0/3.5 framework for my application. I need to run several SQL commands across multiple connections and each connection is on a different server (Oracle, SQL Server). I need to make sure these commands are transactional. For example: I need to perform an INSERT in a table on both Oracle and SQL Server databases, t...

What next step should I take to fix MissingMethodException while debugging?

I'm calling some VB.NET code in one assembly from C# code in another assembly. The code builds fine, but I'm getting MissingMethodException when I make the call. Usually, according to the Stack Overflow and Google search results for MethodMissingException I've read, it's due to a mismatch between the DLLs you're building against and th...

Convert Func<T, string>[] into Func<T, string[]> ?

Consider this class: public class Column<T> { public string Header { get; set; } public Func<T, string> ValueExpression { get; set; } } used like this: var columns = new List<Column<Employee>> { new Column<Employee> {Header = "Employee Id", ValueExpression = e => e.EmployeeID.ToString()}, ...

VB -- How does the "Using" statement translate from C# to VB?

For example: BitmapImage bitmap = new BitmapImage(); byte[] buffer = GetHugeByteArray(); // from some external source using (MemoryStream stream = new MemoryStream(buffer, false)) { bitmap.BeginInit(); bitmap.CacheOption = BitmapCacheOption.OnLoad; bitmap.StreamSource = stream; bitmap.EndInit(); bitmap.Freeze(); } ...

Enter time in .NET app

Is there a control to enter the time (i.e. 9:00am) in .NET? ...

How can I modify a given xpath string to only have nodes that exist in a specific xml document

I build a xpath string based on all filled-out fields in a form submitted by a user. In my xml document, not all form fields necessarily exist as nodes. When I try to do doc.SelectNodes(xpath); I get an exception System.Xml.XPath.XPathException that my xpath has an invalid token. How can I modify the xpath string to only include tho...

DefaultAppPool and Classic .NET pool on IIS7

I have moved a web application with Atlas implementation from IIS6 to IIS7. There are sections in this application that have Ajax implementation. Due to constraints the Atlas was not converted to Ajax. The parts were Ajax is implemented, the application works fine, but client side events fired using Atlas throw an 'UnKnown error'. I ch...

.Net List to a SOAP Array and back to a .Net List

Within a Web Service CarService, - I have a class called Car. - Car has a bunch of properties i.e. Car.Color. - CarService has a method called GetCars(). - Within GetCar, I have a loop that appends a List of, you guessed it.. Cars. Dim carList As New List(Of Car) Do While rdr.Read() If rdr.GetValue(1).ToString().Length > 0...

Is it possible to view the contents of a satellite assembly?

I have what I think are some satellite assemblies in an application produced by a company that no-longer exists. I'd like to confirm that they are what I think (the naming is correct but...) and see what is inside them. ...

How can I convince my admins to upgrade from ASP.NET 2.0 to 3.5?

I am trying to convince my web server admins to upgrade our version of the .NET framework from 2.0 to 3.5. I was wondering what are the best reasons to upgrade, from a server admin prospective. Obviously, there are the over arching ideas of keeping up to date, security, and so forth. I am looking for some hard and fast reasons that will...

Resources for Programming a 'Watchdog' for a complex system

I have to write a service to monitor a complex system. I searched Google for some articles, but didn't find exactly what I was looking for. Does anyone have any good resources for writing a service to monitor a complex system? ...

Which piece of code is more performant?

Hi folks, I have some code i'm revewing, which is used to convert some text into an MD5 Hash. Works great. It's used to create an MD5Hhash for a gravatar avatar. Here it is :- static MD5CryptoServiceProvider md5CryptoServiceProvider = null; public static string ToMD5Hash(this string value) { //creating only when needed if (md5...

Why is IO.Directory.CreateDirectory succeeding when it shouldn't?

I'm running Visual Studio 2008 on a Vista Ultimate box. When I create a brand new console application and run the following code via the debugger, I get an expected result -- an UnauthorizedAccessException is thrown and the directory is not created. Sub Main() Dim path = "C:\Windows\zzzz" Try IO.Directory.CreateDirect...

Garbage Collection does not reduce current memory usage - in release mode. Why?

I built a quick program that needed to loop through an enormous log file (a couple of million records) and find various bits and pieces from inside. Because the volume of data was so huge, I have been curious to watch my Windows Task Manager performance tab and see how much CPU and memory is being used. After the program successfully ge...