.net

dynamic multiple insert

Hi I have a form that allows users to insert "items" in a database. A field asks how many items they want to insert. Identical data (apart from their ID) is inserted in the database the number of times they chose. I've found different ways to insert multiple items but not when this is dynamically done. I'm using .net 3.5 and SQLServer 2...

Can I use Entity Framework for this?

Hi, I am working on a application which I want to expose to external world using ODATA. Let me first give you idea of that application. In that application I need to create a library that will allow the users to perform CRUD operations on the database. For this client has provided XSD , from which we need to generate the classes. Using...

C# Interface implementation: doing the right thing

Hi guys! I've got a hypothetical Reseller who can supply some Services; all Services are same: they threat some IRequest data, plus some IExtraData, and provide an IResponse. Please read this code (working on C# 2.0): public interface IResellerService<in TIn, in TInExtra, out TOut, in TOutExtra> where TIn : IRequest where ...

Is there any new interface that has been introduce with dotnet framework 4.0?

Curious to know if any has been because googling didnot helped much. Thanks ...

Unchecking wrong item in CheckedListBox

I'm trying to make an option, to remove all unchecked items in a checked listbox. Everything is going fine, but when I get 2 or more items with the same name, it goes wrong. For example: I got 3 items in the listbox with the same name, with the first one checked. Now I run the event, but now the last 2 are removed, and the first one is ...

In LINQ, does orderby() execute the comparing function only once or execute it whenever needed?

I found a method to shuffle an array on the internet. Random rand = new Random(); shuffledArray = myArray.OrderBy(x => rand.Next()).ToArray(); However, I am a little concerned about the correctness of this method. If OrderBy executes x => rand.Next() many times for the same item, the results may conflict and result in weird things (po...

How to apply colour formatting to a Richtextbox *as the user types* (VB.Net)

Hi. I have a RichTextBox with an OnChanged event. The OnChanged event should look at each line in the RichTextBox and if the line is of prime length colour it red, otherwise colour it black. How do I do this? I think it is possible to select from index a to index b and set selection colour, but I think this will lose my cursor position. ...

If a class is blueprint for objects, what about static class?

Reading C# Step by Step, the author mentiones the class is just blueprint for objects and itself is useless. Well, how then comes static classes can work alone? I do understand the concept that static classes cannot be instantiated and exist as one unique instance with its static members. But that ruins, a bit, the metaphor of classes...

Object reference not set to an instance of an object error ( error description included )

I am trying to initialize an application that runs in IIS 7 and I cannot start it because I receive the following error: Object reference not set to an instance of an object error eInitWizard.frmMain.CreateVirtualDirectories() eInitWizard.frmMain.DoObjective() eInitWizard.frmMain.wpResume_CloseFromNext(Object sender, PageEventArgs e) ...

WinForms: there is no disk in the drive. please insert a disk into drive.

I have a WinForms application. It's written to disk. I run the application from disk and eject the disk from CD. Then I take the exception: there is no disk in the drive. please insert a disk into drive. How can I catch this exception and correctly close my application? ...

detecting activity in the visual studio editor

I would like to know if there is a programmatically hook into the visual studio editor, so that I can determine whether or not someone is typing in the editor. Thanks! ...

using external config file for a .NET windows service

Hi, I have an app.config file for a windows service which includes database connection strings and appsettings. when I install the windows service, it gets installed in "C:\program files\" folder and the settings are copied to a file called ".exe.config" in the same folder, which makes it difficult to change the settings after it is depl...

call javascript from windows service... possible??

This is a task I have and I am a little unsure about the way to go about achieving this. So I thought the best approach would be to ask other professionals for their thoughts. Basically, I will be storing a load of transactions/triggers for numerous affiliates in a database. Then using a widows service I am going to go through this data...

SecurityException when accessing SPFarm PropertyBag from WCF service hosted in SharePoint

I've hosted an WCF service in SharePoint 2010 (basicHttpBinding) using this tutorial. The assembly is deployed to the GAC and contains the WCF service and a timerjob. Both call the same method. The timerjob works successful. But when I call the method of the WCF service, I get an exception, that it can't write a property in the SPFarm P...

Should I use 'Integrated Security=True' in a production environment?

Is it a bad practice to use Integrated Security=True on a production server in ASP.NET? ...

cpu usage of a thread

how to get the cpu usage of a thread in .net in c# ...

The requested database 'abc' is not defined in configuration.

Hi there, I create a new console application with using C# and then added my dll to my project's references. My dll has a DB class which has static properties. public class DB { public static Database db = DatabaseFactory.CreateDatabase("ConnectionStringName"); } When DB class's properties call, it throw an exception that i...

.NET 4 Task Class Tutorial

Hello there, .NET 4 have an Class - Task. It's pretty interesting and I would like to start using it. For example I would like to create very simple Task based files downloader, with cancel possibility on every download. Can anyone introduce me with sample code of doing that ? I would like to have an list of running tasks and would li...

What has improved in .NET 4.0 Threadpooling?

I am reading a C# 4.0 book which gives the following default values for the maximum thread limit for the threadpool. 1023 in Framework 4.0 in a 32-bit environment 32768 in Framework 4.0 in a 64-bit environment 250 per core in Framework 3.5 25 per core in Framework 2.0 Can anyone tell me what might might have prompted such a vast incr...

UIP Application Block in .NET 4

Hi guys, I am involved in migrating a legacy application built in .NET 1.1 to .NET 4. Is UIP (User Interface Process) still available in the latest released of EnLib 5? If no, what are my options? Regards, Karan Misra ...