.net

install a service on a remote computer from a MSBuild script

I have this task that creates a service: Target Name="InstallService" DependsOnTargets="CopyFiles" Exec Command="sc \ \remotecomputer create "ServiceHost" binPath= "E:\ServiceHost.exe" DisplayName= "ServiceHost"" WorkingDirectory="c:\" ContinueOnError="false" /Target The problem is that when I run this script it doesn't know the \ \re...

"Cannot open user default database" error with "User Instance=True"

I have a desktop application that uses Sql user instancing. This is my connection string: "Data Source=.\SqlExpress; AttachDbFilename=C:\path\file.mdf; Integrated Security=True; User Instance=True; Connect Timeout=100;" My application creates this DB, downloads a load of data into it from a web service and then does a lot of actions w...

ASP.NET Web Service vs. WCF Service

Scenario: I have an existing https ASP.NET site to which I'm going to be adding some new remote services. The services provide calculations that need to be callable both via AJAX methods on the site, and via a .NET desktop application. I had been using ASP.NET WebServices (marked with the ScriptService attribute) to accomplish this. I...

What is the best way to store a date without a year in SQL database?

I am building an app that has a daily quote that should be stored in the database. Each quote is assigned with a day of the year, including one for Feb 29th. Since the quote only cares about the day not the year should I still use smalldatetime type? Please let me know your opinions, thanks!! ...

Partial mapping in Entity Framework 4

Hi guys, I want to be able to do the following: I have a model and inside there I do have an entity. This entity has the following structure: public class Client { public int Id { get; set; } public string Name { get; set; } public string Description { get; set; } } What I want now, is to just get the client name bas...

C# method to scale values?

Hello, I have a value range from 0 to 255. There is a method that returns an array with a min and max values within this range, i.e: 13, 15, 20, 27, 50 ... 240 where 13 is the min and 240 is the max I need to scale these values so that 13 becomes 0 and 240 becomes 255 and scale all the other values between them proportionally. Is ther...

How to run sql from a .net application against sqlserver and get output like with SQL Management Studio?

I'd like my app to run sql files and receive the results output as if the sql was run from SQL Management Studio with results to text. i.e. nicely formatted recordsets, printed messages, rows affected, errors, running multiple batches separated by GO statements, etc. Any suggestions how to do this without building it from scratch on top ...

Thread vs ThreadPool - .Net 2.0

Hello I'm not able to understand the difference between Thread vs ThreadPool. Consider i've to manipulate 50,000 records using threads. In case of threads i need to either predefine no of threads or no of records per threads. Either of them has to be constant. In case of threadpool we dont need to set any of them theoretically. But pr...

Using the Rijndael Object in VB.NET

I'm trying out the Rijndael to generate an encrypted license string to use for our new software, so we know that our customers are using the same amount of apps that they paid for. I'm doing two things: Getting the users computer name. Adding a random number between 100 and 1000000000 I then combine the two, and use that as the lice...

Pass WPF UserControl reference to another UserControl

I've created two UserControls, a ValidationManager and a ValidationOutput. On a given form there is one ValidationManager and several ValidationOutput controls, one for each control that is validated. The ValidationManager is given a list of validation errors when the form is submitted, I want each ValidationOutput control to look at thi...

Why does FileInfo.OpenWrite() throw exceptions if called straight after FileInfo.Create()?

I have taken an example straight out of the MSDN. I want to create a file and write to it straight away. I was hoping to use FileInfo objects. So I create a new FileInfo object, call the Create and then open a FileStream. When I try to open the FileStream I get an exception telling me that another process is using the file. (Yes me). I...

Using other log4net logging levels than the usual ones

Hi, I've realised that there is more levels than all, debug, info, warn, error and fatal, they are listed in the log4net.Core.Level class. But how can I use them? I mean, in the ILog interface you have methods to use the usual ones, but what if you want to use "Fine" or "Emergency", etc? Cheers. ...

How to desubscribe an event

If I have registered an event as following List.Changed += new ChangedEventHandler(ListChanged); what should be the best way of de registering it in destructor List.Changed -= new ChangedEventHandler(ListChanged); or List.Changed -=ListChanged; ...

Microsoft Bing Translator. I need help

Hello, Is there anyone who has already tried to use the Microsoft Bing translator web service. if yes, could you please help me. I was not able to find useful information in google ...

How to know who kills my threads

I got a thread that is just banishing.. i'd like to know who is killing my thread and why. It occurs to me my thread is being killed by the OS, but i'd like to confirm this and if possible to know why it's killing it. As for the thread, i can assert it has at least 40 min of execution before dying, but it suddenly dies around 5 min...

testing for one item in dictionary<k,v>

Hey All, I'm using VS 2005 fx2.0. If I know my Dictionary contains only 1 item how do I get to it? Thanks, rod ...

Installing .net 4 project on target server - Error System.BadImageFormatException

I have installed the .net 4 framework on one of my servers. When I run an installation project created in Visual Studio - get the following error: Error 1001 Exception occurred while initializing the installation. System.BadImageFormatException: Could not load file or assembly or one of its dependencies. This assembly is bu...

Regex for Searching for Text Not Preceded By a Specific String

Hi, I am working on a web site with several other developers and we have had problems where people commit JavaScript code with AJAX calls that use URL's relative to the site root. An example would be /Home/Index which will not work if the site is hosted in a virtual directory. To get round the problem we use a $.url() method to convert...

Advice on designing and building distributed application to track vehicles

I'm working on application for tracking vehicles. There will be about 10k or more vehicles. Each will be sending ~250bytes in each minute. Data contains gps location and everything from CAN Bus (every data that we can read from vehicle computer and dashboard). Data are sent by GSM/GPRS (using UDP protocol). Estimated rows with this data ...

Resharper and Custom Live Template Not Working

Working with Unity, I thought it would be a good idea to create some LiveTemplates to help out with creating configuration entries. For example, I want to create some typeAlias elements in a file called "unity.config": <typeAlias alias="QueryService" type="type,QueryAssembly"/> So, I created a live template...