.net

Accessing the original HTTP request packet in an IHttpHandler

I am trying to write an IHttpHandler that can work with a request for streaming media coming from Windows Media Player/Silverlight. That means responding to a raw HTTP request like this (taken from the protocol document) "GET /ms/contoso_100_files/0MM0.wmv HTTP/1.0" "Accept: */*" "User-Agent: NSPlayer/4.1.0.3925" "Host: netshow.micro.c...

Checking for session expiration with Facebook Connect and .Net

Is there a way in the Facebook Connect API for .Net to check if a session is expired or if it is still valid? Some times I can receive the userId but if I try to get any other info, it tells me that the session is expired, which is why I would like to check if the session is expired before trying to receive the uid (since I won't be able...

How to embed a Font in a PDF with RDLC

hi, i am using Microsoft.Reporting.WebForms.LocalReport to generate some PDF, everything works like a charm, but now evil marketing wants to use a custom font (they are using such crazy arguments as "corporate identity" and stuff). i already goggled around and now i know that i need ReportViewer 2008 SP1 or greater the font has to b...

Using reflection to determine assembly module type

How would one use .net reflection to determine the type of the executing assembly, by type I mean dll or exe. Currently its possible to do something like: Assembly.GetExecutingAssembly().CodeBase.ToLower.EndsWith(".exe") But it seems like something better could exist that does not need to do a string comparison, i.e. comparing the asse...

Focus on a Textbox in DataTemplate selected by TemplateSelector

I've got a ListView that displays different kinds of items. One of those has a textbox I want to set the focus to. I use a DataTemplateSelector to select the DataTemplate for each item. This question explains how to set the focus on a textbox in a DataTemplate. But, in this case the DataTemplate is definded directly on the ListView. In...

ServiceController Required Privileges

I'm using a ServiceController to Start services on a remote machine. When I want to query the services on that machine, I get the following exception: Cannot open Service Control Manager on computer 'machinename'. This operation might require other privileges. What privileges are required to query/start/stop the services on a remote ma...

Can a combobox control hosted in DataGridView cell ask to end edit?

I have a combobox control hosted in a unbound DataGridView control. When the user selects an item (or types an entry and hits enter) I want it to apply the change and come out of edit mode. Is this possible? ...

How to determine if a File Matches a File Mask?

I need to decide whether file name fits to file mask. The file mask could contain * or ? characters. Is there any simple solution for this? bool bFits = Fits("myfile.txt", "my*.txt"); private bool Fits(string sFileName, string sFileMask) { ??? anything simple here ??? } ...

POCO vs DTO

POCO = Plain Old CLR (or better: Class) Object DTO = Data Transfer Object In this post there is a difference, but frankly most of the blogs I read describe POCO in the way DTO is defined: DTOs are simple data containers used for moving data between the layers of an application. Are POCO and DTO the same thing? (ps: look at this great...

Can you include condition-checking code in a format string?

I have a custom control which is part of a list. The text that it should display is set by assigning a value to its Text property. At runtime, this text is loaded from a database. I want to prepend this text with the string "Toelichting: " (Dutch for "Explanation"). I can accomplish this by setting the FormatString property of the contro...

Can I access a session variable which is declared in another language in the same application in Dot net?

Hi all, Dot net allow you to develop an application in multiple languages i.e c# vb.net,j# etc. Suppose I develop an application in two languages vb.net and c#. If I declare one session variable in vb.net code and i want to access the same session variable in c# code. Is it possible? ...

Multiple UpdatePanelAnimationExtender Controls AjaxControlToolKit

I am having a problem with the UpdatePanelAnimationExtender and multiple update panels. What I want to happen is for the panel to fade out, update, and then fade back in. However, it fades out all the panels and only fades the one I updated back in. Apparently this is a rather common problem with UpdatePanelAnimationExtender, but I ...

How to insert only new records using Linq-to-SQL?

I have to insert some data periodically in my SQL Server database. But the feeds where I read the data repeats some data that was inserted before. When I use Linq-to-SQL to insert into the DB either some data is duplicated, or a primary key violation exception is raised, depending on the primary key. How to insert the data without dupli...

OutOfMemoryException in Regex Matches when processing large files

I've got an exception log from one of production code releases. System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown. at System.Text.RegularExpressions.Match..ctor(Regex regex, Int32 capcount, String text, Int32 begpos, Int32 len, Int32 startpos) at System.Text.RegularExpressions.RegexRunner.Init...

How to access a binary resource in a C# application

I'm trying to store an empty Access database (.mdb) as a resource in my application. I then want to write it out the file system and populate it with table definitions, etc. The problem I'm having in Visual Studio 2005 and my C# application is with not being able to access the resource stored in the same assembly (which I would have th...

A good example of overview like documentation of an API in NET

Would someone recommend an example of a good API (.NET) overview documentation. I don't mean, chm file with all the method/classes, but actual overview with diagrams, explanation, tutorial, etc., preferably commercial... Thanks ...

Attributes in C#

I know that C# (and .NET in general) is big on attributes. However, despite the fact I have programmed in C# for many years, I haven't found myself ever using them. Would someone get me started on them, and explain where is the best to use them? Thanks ...

How does one register an assembly in GAC while installation of website?

Hi all. I'm working on a project that depends on third party controls. While opening website after installation, I've an error message regarding these controls, Could not load file or assembly. assembly_file_name. The system cannot find the file specified. web.config file, has an assembly tag for each dll. When I remove these t...

DllImport and ASP.NET

Hi, I'm having some problems with DllImport and ASP.NET because when I use a imported method ASP.NET loads the Dll and locks the file even after it finished using it. Is there any way to force ASP.NET to release the lock on the file? ...

.Net: Empty string is not clear space character?

Hi all. I've always use String.IsNullOrEmpty to check for a empty string. It recently come to my attention that a " " count as not a empty string. For example, Dim test As String = " " If String.IsNullOrEmpty(test) Then MessageBox.Show("Empty String") Else MessageBox.Show("Not Emtpy String") End If It wi...