.net

vb.net countdown

Hi, I'm trying to make a countdown timer in my app. I already know the countdown time which is 4 minutes. I have a timer which ticks avery seconds. Now from that how can I update my textbox so that it shows the time remaining in the foirmat HHMMSS? EDIT: the problem I'm having is calculating the remaining time. What should I use? timest...

How do I combine two Member Expression Trees?

I'm trying to combine the following expressions into a single expression: item => item.sub, sub => sub.key to become item => item.sub.key. I need to do this so I can create an OrderBy method which takes the item selector separately to the key selector. This can be accomplished using one of the overloads on OrderBy and providing an ICompa...

Saving an ArrayList of custom objects to user settings

Is it possible to save an ArrayList of custom objects to the application user settings without resorting to custom serialization? For example, given a basic data class containing only public get/set properties and private backing fields: [Serializable] class SimpleClass() { ... } When I run the following in code, and then rest...

MSMQ with WCF problem

This is a though on to explain, here i go. We are creating a program where sender and receiver of the msmq is using WCF. We implemented a fault handle very similar as this: http://msdn.microsoft.com/en-us/library/ms751472.aspx in combination with http://msdn.microsoft.com/en-us/library/ms789028.aspx Everything works great. We even made...

new IntPtr(0) vs. IntPtr.Zero

Is there any difference between the two statements: IntPtr myPtr = new IntPtr(0); IntPtr myPtr2 = IntPtr.Zero; I have seen many samples that use PInvoke that prefer the first syntax if the myPtr argument is sent by ref to the called function. If I'll replace all new IntPtr(0) with IntPtr.Zero in my application, will it cause any dama...

Overlay two controls

Hi, I started to make some thing in WPF and I have a question. I think the answer might be easy and even obvious, but somehow... I have two controls on a form enclosed by a grid. I want two position the second control above the first one (it's transparent). Coming from WinForms development that isn't that hard, so it won't be in WPF. B...

Multithreading in C#: How can I pass a function name to another function to start a new thread?

I am using multithreading in my C# code as follow: Thread startThread; public void NewThread() { ThreadStart starter = delegate { foo(); }; startThread = new Thread(starter); startThread.Start(); } private void foo() { //do some work } And then in my application I call NewThread()to run the new thread. But now I am havi...

Change ownership in Vista

Hi, I want to change a file in Windows (Vista) directory but as you may know, in Vista most of files in Windows directory have full permission on TrustedInstaller group and read and execute for Users and Administrators group. My application is run as administrator but when I want to change the ownership of the file to the currently logg...

WPF textboxes are too big!

I have a WPF page with some data entry TextBoxes on it and they look much bigger than the font needs. What determines the height of the textbox? is there a way to squish them up? The textbox gets bigger and smaller according to the font size it displays (so I don't want to set the height property directly if I can help it. Thanks ...

Linq with Left Join on SubQuery containing Count

I'm having difficulty translating sql to linq syntax. I have 2 tables (Category and CategoryListing) which reference each other with CategoryID. I need to get a list of all the CategoryID in Category Table and the Count of CategoryID for all corresponding matches in the CategoryListing table. If a CategoryID is not present in Category...

Successful Visual Studio C# build does not create assembly

Hi there, I am using Visual Studio 2005, .NET 2.0 I am not really sure yet under what circumstances it happens, but here is the scenario: I have a solution with a project structure like this: A library project Foo, a library project Bar which references Foo, and a library project Quux which references Foo and Bar. Compiling fails with...

Write .NET portable code or take advantage of language specifics?

Sometimes I need to convert a piece of code or an entire project from VB.NET to C# or viceversa. Unfortunately the code conversion sometimes cannot be automatically done because of the intrisic language differences. I am referring for example to keywords like yield available in C# and not in VB.NET or viceversa XML Literals available in ...

NHibernate bulk insert or update

Hi I'm working a project where we need to process several xml files once a day and populate a Database with the information contained in those files. Each file is roughly 1Mb and contains about 1000 records; we usually need to process between 12 and 25 of these files. I've seen some information regarding bulk inserts using NHibernate b...

ASMX Web Service Expose Class

Hi all, I'm creating a basic web service in asp.net/c# using simple ASMX services. When I create a method that returns a class, this class definition is discoverable by clients of the service. I'm wondering if there is a way to expose a class to the service that isn't used directly in any of the service methods. I need my service clien...

How can I use the system.net section of my app.config in a partial trust environment?

I've a WCF application deployed using clickonce. It connects to my server using https, and everything works fine I use the default proxy when needed thanks to the following code: <configSections> <sectionGroup name="system.net" type="System.Net.Configuration.NetSectionGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyTok...

Adding proxy support to existing application...?

Hi all! I'm wondering if it's possible (and how) to build a tool to add support for proxy connection to an existing application. Let me explain. Take the CodePlex Client (cpc.exe), it's a command line utility used to connect to CodePlex TFS. I'm behind a proxy and not being able to use it. I'd like to write an application, let's say "P...

Scroll a WPF FlowDocumentScrollViewer from code?

Hi, I have a FlowDocumentScrollViewer I want to automatically scroll to the bottom when text is added. <FlowDocumentScrollViewer Name="Scroller"> <FlowDocument Foreground="White" Name="docDebug" FontFamily="Terminal"> <Paragraph Name="paragraphDebug"/> </FlowDocument> </FlowDocumentScrollViewer> In code I add Inlines to the Parag...

Can I pass parameters to String.Format without specifying numbers?

Is there a way to String.Format a message without having to specify {1}, {2}, etc? Is it possible to have some form of auto-increment? (Similar to plain old printf) ...

Large request when sending TIFF image via SOAP

We have a WebService with a method to upload images, this method accepts a byte array which is a TIFF. On the client side the TIFF is loaded with Image.FromFile(path) and then saved into a MemoryStream. Then memoryStream.ToArray() is called which results in a byte array which is used in the WebService request. Currently we have a TIFF ...

Creating a custom datagridrowview

Hi everyone, I'm trying to create a custom gridview similar to the one present in SQL Management Studio for mapping fields to another database. I tried to create a custom datagridviewrow with custom cellviews with controls inside and all I get are empty cells inside. Does anyone have a good idea how I can get this working. I've look...