.net

How can I know if an SQLexception was thrown because of foreign key violation?

I want to tell the user that a record was not deleted because it has child data, but how can I be sure that the exception was thrown because of a foreign key violation? I see that there a sqlexception class that is used for all sql exception. ...

Simple caching mechanism in ASP.NET

I had asked a question on how to implement real time updates in ASP.NET and received a very explanatory and a helpful answer from "jdk" at: http://stackoverflow.com/questions/2347771/how-to-implement-real-time-updates-in-asp-net I understand that memcached or .net caching application block can be used as the caching layer. Currently, I...

How do I paint the treeview node +/- buttons outside a treeview?

Similar to the ButtonRenderer class, I want to be able to paint the +/- buttons used in TreeViewNodes completely separately to any instance of a TreeView. There doesn't seem to be a ControlPaint method that does it, and drawing a Button doesn't look right. Where can I get the drawing code for a treeview node from? ...

C# - Replace Every UpperCase Letter with Underscore and the Letter

How do replace Every UpperCase Letter with Underscore and the Letter in C#? note: unless the character is already proceeded by a underscore. UPDATE: For example, MikeJones would be turned into Mike_Jones But Mike_Jones would not be turned into Mike__Jones Is Regex the best approach? Where do I start with this one? ...

FileSystemWatcher.Changed fires immediately when Excel 2007 opens XLS file in compatibility mode

We use a FileSystemWatcher to monitor documents opened from our Document Management system, and if the user saves the document, we ask if they would also like them updated in our system. We have a problem with XLS files in Excel 2007 (have not verified that the problem does not exist in 2003, but it only seems to be files that open in c...

How to set the base path in IIS 7 hosting a WCF application?

I've been fighting my way through the process of migrating a (previously self-hosted) WCF application to IIS7 (I've never used IIS before and I realise that this is a very simplistic question but I failed to google/SO the answer so far). My service is hosted at http://xxx.xxx.xxx.xxx/SampleWebsite/Service.svc but when I access it with ?...

Entity Framework Vote of No Confidence - relevant in .NET 4?

Hi, I'm deciding on an ORM for a big project and was determined to go for ADO.NET Entity Framework, specifically its new version that ships with .NET 4. During my search for information on EF I stumbled upon ADO .NET Entity Framework Vote of No Confidence which I'm not sure how to take. The Vote of No Confidence was written sometime in...

Know of any open source projects written in C#, that don’t use any other .Net related technologies ( such as WinForms,WCF, WPF etc )?

Do you know of any open source code that would go beyond the basic exercises (aka demonstrations of how particular C# construct works), thus a C# code that would have some real world value? I did read similar threads ( http://stackoverflow.com/questions/1391909/as-a-net-beginner-what-should-i-learn-and-where-can-i-find-open-source-pr...

Error: "Cannot simultaneously fetch multiple bags" when calling Configuration.BuildSessionFactory();

We are getting this error after upgrading to NHibernate 2.1. [QueryException: Cannot simultaneously fetch multiple bags.] NHibernate.Loader.BasicLoader.PostInstantiate() +418 NHibernate.Loader.Entity.EntityLoader..ctor(IOuterJoinLoadable persister, String[] uniqueKey, IType uniqueKeyType, Int32 batchSize, LockMode lockMode, ISessi...

How to authenticate a user with Active Directory from a client using Integrated Windows Security?

In our client/server application, a user can log in using a username/password. The server then authenticate the user from its local user database or from the active directory if the user is not found in the local database. For this scenario everythings is secure. But we want to implement an "Integrated Security" mode on the client to us...

Reorganizing development environment for single developer/small shop

I have been developing for my company for approximately three years. We serve up a web portal using Microsoft .NET and MS SQL Server on DotNetNuke. I am going to leave my job full time at the end of April. I am leaving on good terms, and I really care about this company and the state of the web project. Because I haven't worked in ...

Default encoding type for wsHttp binding

My understanding was that the default encoding for wsHttp binding is text. However, when I use Fiddler to see the SOAP message, a part of it looks like this: <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecu...

How can I access the next value in a collection inside a foreach loop in C#?

I'm working in C# and with a sorted List<T> of structs. I'm trying to iterate through the List and for each iteration I'd like to access the next member of the list. Is there a way to do this? Pseudocode example: foreach (Member member in List) { Compare(member, member.next); } ...

DateTime to javascript date

Hello, From another answer on Stackoverflow is a conversion from Javascript date to .net DateTime: long msSinceEpoch = 1260402952906; // Value from Date.getTime() in JavaScript return new DateTime(1970, 1, 1) + new TimeSpan(msSinceEpoch * 10000); But how to do the reverse? DateTime to Javascript Date ? Thanks, AJ ...

Atom Publishing Protocol Client (C#)

I was wondering if there is a validating client for Atom Publishing Protocol (APP) that is implemented in .NET. We are currently looking at Joe Gregorio's APP Test Client but need an implementation in .NET. ...

WinForm - WPF integration; Piece by Piece

I have a medium sized WinForm App (1 Form that hosts 40 user controls) that we use in house. I want to migrate over to WPF but I cannot do a Mass ReRelease. My idea was, for now, to recreate the App 1 User Control at a time in WPF and have that hosted in the existing WinForm App. I would make them look nearly identical, at this poin...

How to refactor logging in C#?

In my services all exposed methods have: try { // the method core is written here } catch(Exception ex) { Log.Append(ex); } It's boring and ugly to repeat it over and over again. Is there any way to avoid that? Is there a better way to keep the service working even if exceptions occur and keep sending the exception details to ...

Process.Start(url) with anchor in the url

Hi I am trying to use Process.Start to launch a local html file in the default browser. An example url is as follows: "file:///C:/Documentation/HelpContent/default_CSH.htm#SectionA/Topic1.htm" Problem is, the "#SectionA/Topic1.htm" bit gets stripped off for some reason, so that this information isn't passed to the browser. It does ...

.NET Reactor - How to Protect 64-bit Assemblies

I have build 64-bit (x64) versions of some assemblies and am trying to obfuscate them with .NET Reactor, which claims to have 64-bit support. However, even if I disable all protection and locking options .NET Reactor is always producing 32-bit assemblies! Does anyone know how to get .NET Reactor to produce 64-bit assemblies? ...

401 Unauthorized Error with Web Service

I must be missing something very basic. Here is the scenario We have a ASP.NET 2.0 WebService (Server 2003) with the following settings: SSL Integrated Security Anom. Access DISABLED Running under NETWORK SERVICE Exposed (i.e. can access from public internet) Service returns data from database using application username/password, does...