.net

scale fonts together with controls

in WinForms I can use Control.Scale to scale control larger. when I do that, all child controls are repositioned and scaled correctly, but font size remains the same. is there an easy way to force font to scale up/down as well? or is the only way for me to manually update font for all controls when control is being scaled? background: ...

End of Stream encountered before parsing was completed?

I am trying to deserialize a stream but I always get this error "End of Stream encountered before parsing was completed"? Here is the code: //Some code here BinaryFormatter b = new BinaryFormatter(); return (myObject)b.Deserialize(s);//s---> is a Stream object that has been fill up with data some line over here ...

.NET Framework: Are objects apartment bound?

Given: Constructing an ADO Connection object from one thread and giving it to another thread is forbidden. The two threads are different apartments, and even though the first thread will never touch it again (not even maintain a reference to it!), it doesn't matter. That ADO Connection object was created by ThreadA, ThreadA is the onl...

What is the best way to provide "search as you type"?

I'm porting a Forms app to a VB.NET web app, and one of the feature the users really liked was the ability to narrow the possible choices as the user typed in a search box. The search itself goes against multiple tables and columns (and takes several seconds), so it's not a simple AutoComplete or anything. What's the best way to allow th...

Building a bulk mail sender

Hi, I want to build an application that will allow my customers to send marketing information by e-mail. This will be a carefully monitored tool used for legitimate bulk mailing only. It's going to have all of the necessary 'unsubscribe' functionality etc. The solution will be built using VB.NET. My question relates to the best way to...

How do I encrypt app.config file sections during install with WiX?

I have found an example for encrypting a web.config during installation here, but my app is a windows service. The aspnetreg_iis method works only for web.config files. I know how to programatically encrypt the config file, but I don't think I can do that using WiX. Am I wrong? Any ideas? ...

maintaining ids in database that match client software enumerations

Lets say I have a table in a sql server 2000 database called TransactionType: CREATE TABLE [dbo].[TransactionType]( [ID] [int] NOT NULL, [Description] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, CONSTRAINT [PK_TransactionType] PRIMARY KEY CLUSTERED ( [ID] ASC ) ON [PRIMARY] ) ON [PRIMARY] I then have a t...

Test for a syntactically correct path

In .NET is there a function that tests if a string is syntactically a correct path? I specifically don't want it to test if the path actually exists. my current take on this is a regex: ([a-zA-Z]:|\\)?\\?([^/\\:*?"<>|]+[/\\])*[^/\\:*?"<>|]* matches: c:\ bbbb \\bob/john\ ..\..\ rejects: xy: c:\\bob ...

ITemplate and DataGrid Column in Codebehind

I have a situation where I need to work with a datagrid and adding columns dynamically in PageInit as the grid has a few conditional requests that it must handle. I'm moving along easily with BoundColumns, and ButtonColumns, those are easy. The problem is with the creation of a TemplateColumn via code. I have found examples out there ...

How do I render a ViewPage to a string?

I have tried to implement simple ViewPage caching with ASP.NET MVC, however I cannot get the page to render correctly into a custom HtmlTextWriter when it has a master page. I have tried overriding Render. If I simply call the base implementation, then everything renders correctly. If I render to my own writer and then write that string...

Best test runner? (Unit Testing, .NET)

I'm using MBUnit Framework for unit testing and looking for a good test runner. MbUnit's runner is fast however lacking lots of stuff such as You can't set execution path It's collapsing all trees in every run which drives me crazy And almost all other test runner provides so many extra quite and lovely features I used Zanebug, but...

corrupted email attachments in .NET

I'm trying to attach a PDF attachment to an email being sent with System.Net.Mail. The attachment-adding part looks like this: using (MemoryStream pdfStream = new MemoryStream()) { pdfStream.Write(pdfData, 0, pdfData.Length); Attachment a = new Attachment(pdfStream, string.Format("Receipt_{0}_{1}.pdf", jobId, DateTime...

How do I apply OrderBy on an IQueryable using a string column name within a generic extension method?

public static IQueryable<TResult> ApplySortFilter<T, TResult>(this IQueryable<T> query, string columnName) where T : EntityObject { var param = Expression.Parameter(typeof(T), "o"); var body = Expression.PropertyOrField(param,columnName); va...

Do you use the "this" operator in C#?

Duplicate post, see: When do you use the "this" keyword? On almost every project I worked the "This" operator is used, when i start developing i was told that it is a good practice. is this really necessary does it gives you more readability? ...

How frequent is DateTime.Now updated ? or is there a more precise API to get the current time?

I have code running in a loop and it's saving state based on the current time. Sometimes this can be just milliseconds apart, but for some reason it seems that DateTime.Now will always return values of at least 10 ms apart even if it's only 2 or 3 ms later. This presents a major problem since the state i'm saving depends on the time it w...

.NET (web) How to execute some code after all events are handled?

Hi, I have this .NET web app that draws a table in Page_Load. Then after that it handles the events, which should change the table drawn in Page_Load. This is very inefficient. Is there a way to execute the code (which draws the table) after it finishes handling all events? (instead of doing it in Page_Load) Thank you in advance. ...

Clean up AppBar after process kill.

I have written an Application Desktop Toolbar (a.k.a AppBar), it works great except for the fact that if I kill the process, the AppBar code never gets a chance to cleanup by sending an ABM_REMOVE. The problem is that this basically screws the users desktop up. The AppBar is written in .NET using interop code. Does anyone know of a way...

Add a common namespace reference by default to all pages in a project

Is there any easy way to add a using statement to every class I create in a project without having to write using SomeNamespace; in every file? [edit] I could add a template I realise but I'm talking about doing it for every file in an existing project. ...

ASP.NET: Problem with event handlers for dynamically created controls

Hi, I've got this problem with dynamically created TextBox. When the TextBox is created in PageLoad, it's TextChanged event was fired. But when I dynamically delete and recreated the TextBox, the TextChanged was not fired. This is the code: .aspx <asp:Table ID="Table1" runat="server"> <asp:TableRow> <asp:TableCell ...

How can I raise an event every hour (or specific time interval each hour) in .NET?

I'm working on a little web crawler that will run in the system tray and crawl a web site every hour on the hour. What is the best way to get .NET to raise an event every hour or some other interval to perform some task. For example I want to run an event every 20 minutes based on the time. The event would be raised at: 00:20 00:40 01:...