.net

Why is the System.Configuration assembly not included in new projects by default?

Small pet peev. When creating new visual studio projects is there any way to include the system.configuration assembly by default? Almost all of my new projects will need access to the configuration AppSettings. I know it's not much effort to do Project > Add reference, but I imagine that this is a very very common thing for most peopl...

Get saved (non commited) entities with a criteria from session cache in NHibernate

Hello everyone, I'm trying to break the question down to something simple. I use nhibernate to get a list of entities via a criteria call. After that I'll update some entites and add one entity which I save (session.SaveOrUpdate(entity)). When I get a list with a criteria again I do get the entities that were changed (with changed valu...

Access parameter value by position?

I'm trying to develop a method to dynamically dispatch a method from my C# .NET application to a database stored procedure. I already have a method to call the stored procedure which accepts the procedure name and a Hashtable of parameters. I want to be able to call that method from any other method in my application, so I've built the...

How to display values as images in GridViewColumn?

Hi, I have a GridViewColumn which I have bound as so: <GridViewColumn Header="Validated" DisplayMemberBinding="{Binding Path=Validated, Converter={StaticResource imageConverter}}" /> The Binding Path = Validated returns an Enumerated value, the imageConverter takes that value and returns a System.Windows.Media.Imaging.BitmapImage. I ...

InvalidOperationException exception in XNA

The following line will error sometimes in my .NET XNA program. VertexBuffer v = new VertexBuffer(GraphicsDevice, typeof(VertexPositionColorTexture), 4, BufferUsage.None); The exception that is thrown is InvalidOperationException, and it tells me that: "The current vertex declaration does not include all the elements required by the...

what features or tasks in Visual Studio require administrative permissions?

There is a debate going in our department to remove local admin rights to the development workstations we use. I believe this will cause problems for the developers when trying to debug or run other tasks in Visual Studio but I can't put my finger on any one thing to support my argument. What features or tasks require Visual Studio to r...

xml serialization specify xmlelement and xmlattribute together

Given :- [XmlRoot("Book")] public class Book { [XmlAttribute] public string Title; [XmlElement] public string Publisher; [XmlElement] public string PublisherReference; } When serialized to XML will give <Book Title="My Book"> <Publisher>Some Publisher</Publisher> <PublisherReference>XYZ123</PublisherReferenc...

Converting List<Object> using a System.Type object

Let's say I have retrieved a System.Type object using reflection and want to use that type to convert a List<Object> into another List of that type. If I try: Type type = GetTypeUsingReflection(); var myNewList = listObject.ConvertAll(x => Convert.ChangeType(x, type)); I get an exception since the object does not implement the IConv...

What use is the Tag property in .net

I have noticed the Tag properties with controls. Is it okay to use this to reference my custom objects, or should I stay away from it as it would require boxing and unboxing which has been mentioned as unsafe and is not recomended. TreeNode tn = new TreeNode (); CustClass o = new CustClass() o.number = 123; tn.Tag = o; class CustClas...

Is there any alternative to Process in .NET for running commands in the command line?

In my previous question I detailed the problem I encountered. One of the solutions is to simulate a user typing the command in the prompt. I don't know how to do it in .NET, since the usual way of doing this is by using System.Diagnostics.Process which causes the error. I wonder if there is any alternative to that class? What are the ...

How to detect if a JS is packed already

Hey guys.. I am writing a Windows application in C# that minifies CSS files and packs JS files as a batch job. One hurdle for the application is, what if the user selects a JavaScript file that has already been packed? It will end up increasing the file size, defeating my purpose entirely! Is opening the file and looking for the string ...

Is there any case insensitive Unicode character encoding class ?

I am using the following code for charater encoding of unicode charater. It is giving me the different string value of MD5EncryptedString when I use the value of the DataToEncrypt as 'abc' & 'ABC' String DataToEncrypt="abc"; String MD5EncryptedString = String.Empty; MD5 md5 = new MD5CryptoServiceProvider(); Byte[] encodedBytes = A...

How to change Rectanlge Left/Top/Right/Bottom

I have two rectangles InnerRectangle and OuterRectangle. I want to verify if four corners of InnerRectangle i.e, Lett, Top, Right, Bottom are completely inside of OuterRectangle. If those are outside I want change the ones that are outside. If I change Left/Top/Right/Bottom, how much should I change the width or height? Please let me k...

What's the best way to determine that threads have stopped?

I have a Windows service that has a number of threads that all need to be stopped before the service stops. I'm using this model for stopping my threads and signalling that they have been stopped: ThreadPool.QueueUserWorkItem(new WaitCallback(delegate { Thread1Running = true; try { while (running) { ...

.Net ORM bulk deletion via predicate

Is there an ORM that will allow me to do the following? db.Delete<MyEntity>(x => ***some predicate***); We use NHibernate and I don't believe this is possible with it. ...

why WaitForExit() doesn't wait?

i am adding Custom Action into my VS2008 setup project (MSI installer). I am calling a batch file to create database and want to delete those files after. I have WaitForExit() but it will not wait. Why? ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.UseShellExecute = false; string tem...

Visual Studio 2010 Code Analysis - Run on Solution

Hello, I would like to manually run code analysis for an entire solution, not on building the project, and not using FXCop, if possible. I did enable CA on build but it really, really slowed down the build process, and we can't have that. But it seems weird to me that code analysis can only be run per project manually through the menu...

How to configure a single WCF Service to have multiple HTTP and HTTPS endpoints?

What I am trying to do is get a SINGLE WCF Service to work in the development environment which is the HTTP scheme, and, also, have the SAME service work in the production environment which is the HTTPS scheme. If I remove the two Https endpoints (those suffixed 'Https'), it works in the development enviornment; likewise, if I remove onl...

How to host a console application on Windows Server 2003?

I have to host a console program which hosts an application used by Asp.Net 4.0 and should always be running. What is the best way to host it on the server? I can run the console application from commandline but it can be closed accidently. Windows Service is not an option as we don't have the source code for the Console App. ...

Create object of parameter type

hey. Is it possible to have a method that allows the user to pass in a parameter of a certain type and have the method instantiate a new object of that type? I would like to do something like this: (I don't know if generics is the way to go, but gave it a shot) public void LoadData<T>(T, string id, string value) where T : new() ...