.net

Is it possible to update old database from dbml file ? (C#, .Net 4, Linq, SQL Server)

Hi all, I began recently a new job, a very interesting project (C#,.Net 4, Linq, VS 2010 and SQL Server). And immediately I got a very exciting challenge: I must implement either a new tool or integrate the logic when program start, or whatever, but what must happen is the following: the customers have previous application and database ...

Why do arrays in .net only implement IEnumerable and not IEnumerable<T>?

I was implementing my own ArrayList class and was left surprised when I realised that public System.Collections.Generic.IEnumerator<T> GetEnumerator() { return _array.GetEnumerator(); } didn't work. What is the reason arrays don't implement IEnumerator in .NET? Is there any work-around? Thanks ...

NHibernate lazy properties behavior?

I've been trying to get NHibernate into development for a project I'm working on at my workplace. Since I have to put a strong emphasis on performance, I've been running a proof-of-concept stress test on an existing project's table with thousands of records, all of which contain a large text column. However, when selecting a collection ...

Parallel.For(): Update variable outside of loop

I'm just looking in to the new .NET 4.0 features. With that, I'm attempting a simple calculation using Parallel.For and a normal for(x;x;x) loop. However, I'm getting different results about 50% of the time. long sum = 0; Parallel.For(1, 10000, y => { sum += y; } ); Console.WriteLine(sum.ToString()); sum = 0; for...

Changing from WPF User Control to Window?

I've been working on a commandline application, and have recently decided to add a wpf window to the application. I added this as a UserControl, however I noticed I can't call this class using ShowDialog() from my main code; I've tried changing the Base class from a UserControl to Window, however an error occurs; public partial class ...

Object changed while deserialization

I'm serializing an object and storing the serialized value in db and getting the deserialization to work fine as well after getting values from db. But problem occurs if the existing object is modified and a new property is added in the class. Then while deserializing it looks for that property in serialized text and upon not finding it...

IP address and Datagridview control

Hi , I am using a datagridview to get the IP address from user. Is there any way so that I can restrict the user to enter only valid ip address in the datagrid view cell? Its a desktop application. ...

LDAP bind error codes using ADSI in C#

I am binding to an ADAM instance from a C# client using the ADSI provider. When the bind fails I get a generic error condition back that indicates a failure. If I look at a network trace of the traffic I can see that the ADAM instance itself send extended error information back to my client indicating why this authentication has failed, ...

Restoring and passing data to an already running instance of a .NET application

The goal is to have an application that runs in the system tray and can either accept user input from its actual GUI (which isn't the actual issue) OR accept command line parameters (that would actually be done via a context menu in windows explorer). Now, while I'm aware that the command line parameters are not exactly possible once the...

How do I get LinqToSql to pass “index hints” to sql server?

As we can’t trust our customers to update the index stats etc in sql server, we have in the past had to use index hints. (As some of our customers are still on Sql Server 2000, we also can’t depend on the better query optimizer in later version of Sql Server). So how do I pass in index hints when using LinqToSql to build a query rathe...

Get identity-level token for Windows user?

I want to create a WindowsIdentity for a given user. I don't need it for impersonation, just for group membership checks. I need it to work with and without a domain (none of that S4U Kerberos delegation stuff). The constructor for WindowsIdentity that takes a username only seems to work for domain scenarios. Is there any other way I ca...

Programmatically access the CIL for a .NET type

Is there a straighforward library that I can use to access the CIL for a .NET type? Let me demonstrate what I want the fictitious CilExtractor to do: [Serializable] public class Type_For_Extract_Cil_Test { private int _field = 3; public int Method(int value) { checked { return _field + value; } } } [Test] public ...

sqlclient - connection timeout or command timeout

Hi folks, I get the following error upon running a query. * System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) * Is this a connection timeo...

Parameterized Queries /Without/ using queries.

I've got a bit of a poor situation here. I'm stuck working with commerce server, which doesn't do a whole lot of sanitization/parameterization. I'm trying to build up my queries to prevent SQL Injection, however some things like the searches / where clause on the search object need to be built up, and there's no parameterized interface....

How do I change the Date Format of a .net SOAP request?

I'm using a WSDL that expects a DateTime parameter for one of the methods. When .NET serializes my call, it creates a date parameter like this: 2010-1-1T10:00:00.00 This looks like the serializer is using a date format of "s". I need a different format, namely one with the timezone offset: 2010-1-1T10:00:00.00 -4:00 How do I specify...

c# - create invisible user control

Hey, I need to create a user control in C#.Net, which can be added to the application without being visible - just like the FolderBrowserDialog. It's a new window which I'll be using often so I think this is the right way. The window will be opened by envoking the showDialog-Method as known from the other dialog. Any Idea? Thanks and r...

How do I use macros for the command line arguments for debugging a .NET project?

In the Visual Studio Debug property page (for a .NET 4 project) I want to be able to specify macros, e.g. $(OutDir), like I can in the Build Events. But it doesn't work, the macros aren't replaced. Is it just not supported? Is there a work around? ...

If you deny assertion rights in .NET, does it have any effect?

In .NET you can deny the security permission 'Assertion' for callers higher on the stack, but would this actually work since Assert() ignores permissions lower on the stack? Since it's the end of the working day I don't presently have time to experiment. Guidance appreciated! ...

How to avoid timeouts in WCF?

I use netNamedPipeBinding, and my service methods return nothing (void), but they timeout: TimeoutException: "The open operation did not complete within the allotted timeout of 00:01:00. The time allotted to this operation may have been a portion of a longer timeout." Server stack trace: at System.ServiceModel.Channels.Cli...

Sockets with Silverlight 4

I need to implement a persistent socket connection from my in-browser Silverlight 4 app to a device on the network. I need the following: Connect to it and keep a persistent connection Send and Receive data Get some type of event or notification (or detect it) when the connection drops. Is this possible with Silverlight 4? If so,...