.net

Entity Framework "Code Smells" Question

I'm a fan of Ef and want to use it but I'm not necessarily a fan of how associations work per-se. If I have a simple lookup table containing maybe 3 rows in it and would typically be treated as an enum in code, I don't like that I effectively have to do this to assign a value using the associating in EF: myEntity.MyLookup = db.MyLookups...

Clean up unused Dataset, BindingSource & TableAdapter objects

I have inherited a Winforms project that has several forms with a great deal of Dataset, BindingSource & TableAdapter objects. I am sure that not all of these are required/used. Is there a way to determine which of these objects are not used by a control (IE dropdown, textbox etc...)? I am using VS2008 ...

Code cannot search AD

I have a problem with C# accessing AD objects. The goal of the code is to retrieve a users's groups. We have 2 domains involved - the domain where the application and many users reside, plus a trusted domain that also contains users so the code must be able to get groups from both domains. I am using a DirectorySearcher object and filt...

Overloads vs generic arguments

I have a question. In the framework, that was largely written before the generics came, you often see a function with lots of overloads to do something with different types. a) Parse(int data) Parse(long data) Parse(string data) ..etc That seems to be to be ok as it helps keeping code small for each method and so. On the other hand, ...

Deciding if I should split a table

I am building a multi language site I have a descriptions table that hold the description of each product and a column that indicate the language. So it contain a row for each language description Now my concern is that I have various different types of products in the system and reading the description of any product will have to go t...

Printing time to binary file in C# .net

Hello, I got this next problem. I have a binary file, which I write to it vital data of the system. One of the fields is time, which I use DateTime.Now.ToString("HHmmssffffff), in format of microseconds. This data (in a string) I convert (to ToCahrArray) (and checked it in debugging in it is fine), it consists of time valid till the mic...

How do I tell which tab you are moving from/to in a .NET tab control?

I need to determine which tab the user is coming from, and going to, when they switch tabs, and possibly cancel the switch. I have tried the Deselecting, Deselected, Selecting, Selected events, and all of them show the e.TabPageIndex to be the same as the sender.SelectedIndex. Is there an event, or property, that I can use so that I ca...

.NET Compact Fw 3.5: Where is the numeric updown control?

According to the MSDN the NumericUpDown class is supported by the compact framework. The problem is that I can't find it on the toolbox. Is it possible to add this control to the form in the designer, if yes, how? Thank you ...

Confused about Base class libary and Framework Class Library

Is ADO.NET and ASP.NET a part of Base Class Library? The information given in wikipedia looks ambiguous to me. In the figure, it is shown as a separate block. What is the difference between Base Class Library(BCL) and Framework Class Library(FCL)? Is FCL as a part of .NET Framework? If so why is FCL not shown in the figure as part of .NE...

Can I make a dependency property that's read-only?

I need this dependency property to be accessible for read operations only. Outside objects should not be able to assign values to it. ...

Viewstate hidden field so big it makes everything crash

For some reason the viewstate of my application became gigantic (around 14 million characters). It adds around 1 minute of loading time. If the page finally loads (which is not often), the server crashes every time someone send a form because "Post size exceeded allowed limits. " It appeared suddenly. I didn't add any fields, just some ...

.NET Compact Fw 3.5: Background worker

I want to use something similar to the BackgroundWorker on mobile devices. Sadly it is not available in the compact framework. What can I use instead? ...

Oracle ASCII Character Set - .Net Extensions

Hello, I am trying to extract data out an Oracle table. The column is defined as char(40) and contains extended ASCII values. Currently in SQL*Plus, the extended characters are displaying as an "upside-down" question mark. I need to be able to extract the ASCII characters that have a decimal value > 128 and display in the extended or 8-...

Match a string that does not contain a certain character sequence

I'm trying to use regular expressions to match a string that does not contain the sequence of characters of a less than symbol (<) followed by a non space. Here are some examples Valid - "A new description." Valid - "A < new description." Invalid - "A <new description." I can't seem to find the right expression to get a match. I'm usi...

ASP.NET runtime error : Ambiguous Match found

Recently, my team converted ASP.NET project from .NET 1.1 to .NET 2.0. Everything is pretty good so far except for one web page. This is the error message I got when I tried to open this page: Server Error in '/' Application. Parser Error Description: An error occurred during the parsing of a resource required to service t...

Cannot read True Type Font FIle in my WPF APplication!

Hi, i'm developing a project in Wpf with Vista Sp1 on my laptop ,in this project i add some True Type Font that Windows Xp did not get and when i debug my project on Windows XP i cannot see the True Font File,so i wish add in my project those fonts as resources but i cannot work out this step. I followed all advices of MSDN but not luck...

.NET Libraries to work with JSON

Hi, We are currently writing our ASP.NET pages using c# and .NET 2.0 framework and we are about 4 months out from upgrading to .NET 3.5 framework. Meanwhile we have a very client-side JS heavy page to push out in 2 months. We are currently looking at JayRock to handle our client-to-server service methods invoking with JSON data. One of...

WinForms: automating common chores

When adding a control to my form, currently I have to wire it up with my save and load code, with my internal data structures and I have to do this with all my controls. This scenario severely violates the DRY (don't repeat yourself) principle and can introduce subtle bugs. I have came up with the idea of traversing all the Controls in ...

.NET / C# - Convert char[] to string

Guess I have just never run across it before. What is the proper way to turn a char[] into a string? The ToString() method from an array of chars doesn't do the trick. Guess I had always imagined that was what it was for. ...

Regex to validate at most 2 numbers and at most 4 alphabets in an string of length 6.

Max Length of the String is 6. The string should contain at most 2 digits The string should contain at most 4 alphabets So the following examples should match abcd22 a1cd3d 11acde a1c 1ad ...