.net

Question: Serializing and deserializing, the significants and when to use it

I am reading a book that is talking about serializing and deserializing files or sending data via web services. My question is.. Is it mandatory to use serialization when using web services. Also when saving files locally using serialization, what is the significants of doing so ? I know that it saves the data into binary data. Is this ...

Setting a date/time to a date time picker in .net 1.1

Hey Everyone, I have a datetime picker in one of our apps. When loading up the win form I need the date time picker to default to the Wednesday following todays date. Any idea how to do this? We are using .Net 1.1 for this app. Thanks, Mike ...

.NET Interop IntPtr vs. ref

Probably a noob question but interop isn't one of my strong points yet. Aside from limiting the number of overloads is there any reason I should declare my DllImports like: [DllImport("user32.dll")] public static extern int SendMessage(IntPtr hWnd, int msg, int wParam, IntPtr lParam); And use them like this: IntPtr lParam = Marshal...

How to pass a MySQL database function as a query parameter from c#

Let me explain a little. Image you have the flowing MySQL table: CREATE TABLE test ( value DATETIME ); Currently I am doing something like this: command.CommandText = "UPDATE test SET value = ?value"; command.Parameters.AddWithValue("?value", DateTime.Now); But the clients date/time settings are unreliable so I would like the ti...

How to provide a StreamingContext to the BinaryFormatter when using .NET remoting

I am trying to provide the StreamingContext to the client-side formatter when using .NET remoting. I have set up remoting using the config file, e.g. . Is there a way to provide the Context property for the formatter in the configuration file? ...

Custom Formatter for .NET Remoting

I would like to use a custom formatter for .NET remoting. In order to accomplish this, my understanding is that I have to implement something akin to the BinaryClientFormatterSink class (used for BinaryFormatter), but for my custom formatter. For example, if my formatter was FastBinaryFormatter, I would likely implement FastBinaryClientF...

.NET screen objects touch detection

How would one go about detecting if two images on the screen (form) were touching each other in C#? I have a little game where I have to find out if two objects (images of objects) are touching each other. Is there a simple way to implement this? ...

Adding null to a List<bool?> cast as an IList throwing an exception.

Using .NET 3.5 and C# 3.0, IList list = new List<bool?>(); list.Add(null); This throws an ArgumentException, which just feels wrong. List<bool?> list = new List<bool?>(); list.Add(null); Works perfectly. Is this a bug in Microsoft's code, then? An example of how to produce this kind of error in a real-life situation: new JavaScr...

What is the advantage of using DataContractAttribute over SerializableAttribute?

I have found that my WCF services work normally when the data types involved doesn't have the [DataContract], but the [Serializable] instead. But all the WCF tutorials shows the first one instead of the latter. Why? ...

Most efficient way to select records in one database based on result set from totally different database

I have 2 totally separate databases - one MSSQL and one Pervasive. Due to the way our product data is stored in the Pervasive database, you cannot easily run a query to get a products's information and features to display on our website. So, using a DTS package I take the product data from Pervasive and process it so it is one MSSQL t...

Sending/Recieving/Interepreting Dynamic Email

Hey guys here's a good question.. I wanted to write a program that can receives an email, interprets what the message is, then performs a calculation, then responds based on the email received. For example... The mail server receives an email that has "option 1" in the body...then somehow the mail server asks the program what it should...

Microsoft Outlook View Control

I am playing with the Microsoft Outlook View control, trying to understand its capabilities, but I'm not getting very far. It shows up at design time, but at runtime it just gives an "E_CLASSNOTREG" exception. How do I find out what class it is complaining about? I just created a winform project, added the control to the toolbox, and dr...

How can i make params `out` in C#?

I find myself in the situation requiring this public static void Fill(this SomeClass c, params out object[] p) and calling it as c.Fill(out i, out i2, out sz, out i3, out sz2); However i get the error error CS1611: The params parameter cannot be declared as ref or out How can i pass in variable length arguments and make them write...

Is it possible to clone an IEnumerable<T> instance, saving a copy of the iteration state?

I'd like to create a copy of an IEnumerator<T> so that I can restart the enumeration process from a particular location in the collection. Clearly, there is no benefit to doing so for collections that implement IList, since we can remember the index of interest. Is there a clever way to accomplish this task using a combination of yield...

authorization error when accessing an aspx page

Hello everyone, I am using SharePoint Server 2007 Enterprise with Windows Server 2003 R2 Enterprise. I am developing using VSTS 2008 + C# + .Net 3.5 + IIS 6.0. I have put a simple aspx page into layout folder (the code is very simple, just redirect to another page, and I write inline script code in asp.net), here is my code, and I met ...

.net c sharp Console Application : timeout

I am creating a console application using Enterprise Library my code is something like this DataSet ds = db.ExecuteDataSet(command); this actually calling a SP which take 10-15 minutes to complete , so my come throws a time-out error. Any idea how to overcome this. ...

Can I use precompile symbol to determine which code fragment would be compiled when I switching target framework in Visual Studio.

We can switch to different .NET Framework target in Visual Studio after 2008. I have a project, and I want to build 2 different target Frameworks assembly of it. If my target Framework is 2.0, I want it to build some code, and when I switch to another target Framework, I want it to build another code fragment to use some new functions. ...

Sending Emails C#

Dear all, I am writing a application which need to open a new mail dialog, upon clicking on a button on it. Application users uses different mail clients like MS Outlook, Thunder Bird, etc... Application should open a new mail dialog filled with information passed by my application, like TO, BCC, Subject and Body sometimes with attachm...

.NET - How to Get the current VPN Windows Identity

Hello, I have a console application that calls a WCF service on a remote domain. The WCF service is uses Windows credential type for the transport and message credential types. The WCF service is configured to negotiate for the user's credentials. My question is how can I obtain the identity object that the WCF service uses on the cl...

C++/CLI: Native Reference vs Tracking Reference

What is the difference between the following two functions? ref class SomeClass; void swap(SomeClass^& a, SomeClass^& b){ SomeClass^ c = a; a = b; b = c; } void swap2(SomeClass^% a, SomeClass^% b){ SomeClass^ c = a; a = b; b = c; } ...