.net

C#: Set ComboBox Height

Hi guys, I'm trying to set the Height of a ComboBox in C#.NET CF / WinCE6. So far I managed to do it by using the MessageWindow.SendMessage() with CB_SETITEMHEIGHT. The issue is the ComboBox gets to its initial Height when being clicked. Is there a workaround for this ? LE: How would this affect performance, considering the ComboBox m...

What is the best way to attach static methods to classes rather than to instances of a class?

If I have a method for calculating the greatest common divisor of two integers as: public static int GCD(int a, int b) { return b == 0 ? a : GCD(b, a % b); } What would be the best way to attach that to the System.Math class? Here are the three ways I have come up with: public static int GCD(this int a, int b) { return b == ...

Binding the position and size of a UserControl inside a Canvas in WPF

Hi. We need to dynamically create (i.e. during runtime, via code-behind) UserControls and position them on a Canvas. We want to bind the position (Canvas.Left and Canvas.Top) and width of those sizable (!) and draggable (!) UserControls to a ObservableCollection<>. That measn when the user drags or resizes the control, the datasource get...

Custom Web User Control Repository for dynamic loading

Hi everyone, I need to build a application that dynamically load custom web user control. Those user controls will be builded by other users and included into a project. In the other hand, in another project, these controls will be consumed and dynamically loaded into the pages of this project. This is for easily customize forms and st...

How to find out field maximum length in Entity Framework in .NET 4?

According to this question, there's no built-in way in EF v1 to figure out the length of a field. Is there a built-in way to do so in the Entity Framework that ships with .NET 4, if so - how? ...

How do I force full post-back from a button within an UpdatePanel?

Any help will be appreciaded. ...

In .net, how do I choose between a Decimal and a Double

We were discussing this the other day at work and I wish there was a Stackoverflow question I would point people at so here goes.) What is the difference between a Double and a Decimal? When (in what cases) should you always use a Double? When (in what cases) should you always use a Decimal? What’s the driving factors to consider in ca...

Whats wrong with my triple DES wrapper??

it seems that my code adds 6 bytes to the result file after encrypt decrypt is called.. i tries it on a mkv file.. please help here is my code class TripleDESCryptoService : IEncryptor, IDecryptor { public void Encrypt(string inputFileName, string outputFileName, string key) { EncryptFile(inputFileName, outputFileName, ...

Using .NET, how and why to use the memcached?

I hear much talk about memcached, but when briefly studied on it, I couldn't understand what advantages I can take instead of using the good old Dictionary<string, object> to cache my data in my applications. Can someone explain it to me? ...

Put a filter on DataView by time

How to filter DataView/DataTable by time? I have a table with datetime column inside and I need to filter by the time that is inside that datetime value. In native SQL it's not so hard but in ADO.NET Expressions it makes a dificulity for me. ...

How to get a majority color in an image?

I want to retrieve the majority color in a background image in .NET. Is it possible? ...

ModalPopupExtender + ASP.NET AJAX: Can't page grid

I'm trying to page and sort my datagrid wich is inside a modalpopupextender but I can't page it in any way, already tried with , put the updatepanel inside, outside, in the middle (loL) and it does NOT work. modal popup does not get closed but the grid just dissapear. Code: Protected Sub Page_Load(ByVal sender As Object, ByVal e As Sy...

WCF net.tcp windows service - call duration and calls outstanding increases over time

I have a windows service which uses the ServiceHost class to host a WCF Service using the net.tcp binding. I have done some tweaking to the config to throttle sessions as well as number of connections, but it seems that every once in a while my "Calls outstanding" and "Call duration" shoot up and stay up in perfmon. It seems to me I ha...

How to force a TextChanged event on a WPF TextBox and mantain the focus?

I am creating a numeric TextBox in WPF, with two buttons to increase and decrease the value. I have create two RoutedCommand to manage the behiavor and they are working well. There is only one problem that I would like to solve. I would like that the control notifies all object binded to its TextProperty when an increase or decrease com...

Optimal storage of data structure for fast lookup and persistence

Scenario I have the following methods: public void AddItemSecurity(int itemId, int[] userIds) public int[] GetValidItemIds(int userId) Initially I'm thinking storage on the form: itemId -> userId, userId, userId and userId -> itemId, itemId, itemId AddItemSecurity is based on how I get data from a third party API, GetValidItemI...

WCF - Dynamically Change WebResponseFormat

Is there a way to dynamically change the WebResponseFormat on a method given a parameter passed by the client? I default my WebResponseFormat to XML, but I want to give the client the opportunity to specify a format as JSON or XML and if none is specified, default to XML. Currently I am doing the following: [WebGet(UriTemplate = "objec...

How can I log and retrieve error messages from a client-side desktop app?

Update: The service-based answers below are most likely the way to go, I am also curious to see if there are any out-the-box solutions anyone has tried in the field. Our system uses a client-server architecture, and with more clients using it I'm thinking of better ways to log client application errors, and get them sent to us. Curr...

How to parse the multipart data in a restful service...

I have written a restful web service in c# and .net using the Restful Starter Kit that receives a mime multipart form via a stream. The multipart form contains a small xml fragment and a small file binary. I have read the stream in, and I have also written some code to parse the data to obtain the XML and the file binary. However, I f...

Creating a 64bit build in Visual studio

I have an old .net 2.0 windows app I need to deploy on a windows 7 machine and its not going too well. I want to build a native 64 bit version rather than a 32bit capable of running on a 64bit environment. I'm working with Visual studio 2005 My question is what settings do I need to set within each project of my solution, (both the wind...

Can't add reference from Silverlight app to WCF-service that is hosted by ASP.NET

A "Silverlight-enabled WCF service" was added into existing ASP.NET web-application. On attempt to add reference from the Silverlight Application to the service the following error was received: Object reference not set to an instance of an object. How can I add reference? Thanks. ...