.net

Active directory and LDAP libraries

I am trying to authenticate users to active directory with the Novell.Directory.Ldap libraries found in Mono. I know there is better ways than below, but given that I'm confined to Mono, these are the only supported routines as best I can see. Using the .NET libraries, I can authenticate a user with their samAccountName. using (Direc...

Can anyone help me to code Reverse algo function for CRC64 in C#?

I am working on CRC64 Reversing algorithm on C# but unable to code it. If anyone can help me out, it will be nice of him. I am desperate to complete the coding. ...

What is a meaningful format to save formatted text in the database?

I have an existing application that has some parts of formatted text-blocks (standard formats such as bold, italic, unordered list, …) saved in the database. Currently these text-blocks are saved in a custom xml format. The editor is created with a WPF-RichtTextBox. Since I have to make the editor more user-friendly and extend the appli...

Selecting dynamic types using Linq to SQL

I would like to select from a table using linq to sql without knowing what that table is until runtime, something like Type t = Type.GetType(myString); var results = from o in context.t select o; Obviously this doesn't work, but I was wondering if there was a way to do this. ...

hosting powershell like cli in asp.net mvc to perform maintaince

I need CLI for our asp.net mvc application to perform maintenance tasks and some status tasks. I think powershell is designed to provide CLI. But i do not know anything about it other than name. How can i host powershell in asp.net mvc running in iis to provide CLI for custom tasks? ...

How to turn byte[] into sbyte* in C#?

I have a function that want to receive sbyte* buffer how to create such in C# from scratch and from existing byte[]? ...

when using System.Text.UnicodeEncoding.Unicode.GetString(byte[]) reverse encoding to byte array fails intermittently

Can someone tell me why the following code intermittently throws an exception ? I am running Vista Ultimate 32 bit and VS2010 .NET4 byte[] saltBytes = new byte[32]; RNGCryptoServiceProvider.Create().GetBytes(saltBytes); string salt = System.Text.UnicodeEncoding.Unicode.GetString(saltBytes); byte[] saltB...

Attached entity does not get update with new values when SaveChanges is called

Is there anything wrong with this code? My entity is not getting updated. public ActionResult UpdateNota(string notas) { if (Request.IsAjaxRequest()) { RegistroEntities registroEntities = new RegistroEntities(); Nota nota = JsonConvert.DeserializeObject<Nota>(notas); registroEntities.AttachTo("Notas",nota...

bind expression problem

I want to show a collection of images in list view. I have an image table in a MySQL database, the fields are photoId, PhotoName, ... I want to bind the image control Url in the item template of the list view on the physical path (stored in config file) + photoName in the DB. ImageUrl ='<%# ConfigurationManager.AppSettings.GetValues("...

How do you control the output format of a date when writing a CSV file with FileHelpers?

I'm using the FileHelpers 2.0 library to write a CSV file using the ClassBuilder class to generate a record type. My data contains dates and so I create a field of type DateTime, but when the file is generated the date values come out in the format ddmmyyyy rather than dd/mm/yyyy e.g. 28042000 instead of 28/04/2000. I've set the DateFo...

.NET thread safety

List.Add is an instance method. That means it's not guaranteed to be thread-safe. What does this mean? Possibility 1. That if two threads invoke .Add on different instances, there could be an unexpected result depending on the phase of the moon? Possibility 2. That if two threads invoke .Add on the same instance, there could be an unex...

Is this a bug in the Code Contracts rewriter?

I am experimenting with .NET Code Contracts. The following code runs just fine when runtime contract checking is turned off, but fails when runtime contract checking is turned on: using System.Collections.Generic; using System.Diagnostics.Contracts; namespace ConsoleApplication1 { public class Item<T> where T : class { } public...

Should empty "if" statement in C# lead to an error or warning?

Let me start from a real life example: Customer: Alex, just noticed something strange in the RemovalProcessor at line 138: if (Session.Handler.ExecutePrefetchTasks()==null); Session.ExecuteDelayedQueries(); Should the semicolumn behind the 'if' be there? Me: Oops... I'll send this to our guys to check, but mos...

Filter the "Includes" table on Entity Framework query

This is for Entity Framework for .NET 3.5: I have the need to query a table and include a collection of the "many" table of a one-to-many relationship. I'm trying to filter that collection as part of the query - I'm pretty new to Entity Framework, and I'm having trouble figuring it out. Simplified example: Author has Books, and Book h...

How do I send email to a dropfolder in asp.net?

I have two questions: 1) How do I send an email in C#, but have it end up in a drop folder to be sent from there rather than being sent straight out by SMTP? 2) For a production machine, do I use IIS to process the dropfolder, or should I purchase a 3rd party product for this? Thanks! ...

Font size discrepancy in .NET GDI+?

I am wracking my brains in trying to understand the discrepancy between the font sizes users select or specify (for example, using a FontDialog) and the em-size reported by the Font class in .NET. For example: using (FontDialog dlg = new FontDialog()) { if (dlg.ShowDialog() == DialogResult.OK) { Console.WriteLine("Selected ...

C# : How to capture events asynchronously and return a value from a function synchronously

This is a C# question I want to do a synchronous call for asynchronous event call backs. See comment in code for the req class User { EventHandler Service1Started() { "Looks like service 1 started as I got event from server class" ; } EventHandler Service2Started() { "Looks like service 2 started as I got...

What is the difference between C++ memory management and .NET memory management ?

What is the difference between C++ memory management and .NET memory management ? ...

C# Async Ping: How to avoid an out of memory exception ?

Question: I want to search the subnet for all computers in it. So I send a ping to all IP addresses in the subnet. The problem is it works fine if I only scan 192.168.0.". But if I scan 192.168..*", then I get an "Out of memory" exception. Why ? Do I have to limit the threads, or is the problem the memory consumed by new ping which do...

Why each class in .Net derives from System.Object? what are the benefits?

Why each class in .Net derives from System.Object? what are the benefits? ...