Log in

No account? Create an account
C# Developers' Journal
20 most recent entries

Date:2013-01-08 00:39
Subject:My open source project


I want to share with you my open source project.

The purpose of my project is to demonstrate my visual filter builder WPF control in use. FilesFilter application allows you to filter your files by many parameters applying filtering expressions. Essentially my WPF user control builds LINQ binary tree lambda expressions to select a subset of items from a list. In terms of C sharp code it can be applied to lists of elements of any given classes. If you need such a filtering expression builder, you're welcome to use my component in your projects. Any changes and improvements would be also very much appreciated.

Please, take a look at this:

I think you may find it useful and interesting.

post a comment

Date:2011-07-12 17:04
Subject:Any DBAs in the New York area looking for work?


Hey all, I am trying to hire a DBA in NYC that has a background in MS SQL Server 2005/2008. If you're interested or know someone who might be please pass their resume along via the link above. Thanks!

post a comment

Date:2011-03-14 16:27

I was always impressed by the bing.com image search AJAX. The bit where where more images load as you scroll down the page. Is there an AJAX control in .Net that can do that sort of thing using an update panel and a repeater?

post a comment

Date:2011-02-22 21:43
Subject:.Net custom control help

I want to use a SEO friendly link button on my page. Mind you i am sure that the page is really not all that accessible as the page I am linking to will still have javascript running on it - but thats besides the point. The correct way to do this would be to put the href thats generated by a link button into the onclick event and return void or false or whatever. And then have a SEO / accessibility friendly URL in the HREF. This seems to be what Google recommends and t seems to make sense to me.

I found this nifty .CS file here - http://files.codes-sources.com/fichier.aspx?id=44402&f=CrawlableLinkButton.cs. Essentially it inherits a linkbutton and adds a NavigateUrl parameter to it so that I can put whatever href I want in there. Awesome. Just what I was looking for.

Trouble is I have no idea how to include it in my code. I feel ashamed for admitting my ignorance here. I can register a control at the top of the page, but I think I need to either use a .dll (like I do with things like the AjaxToolKit) and then reference the assembly name and the namespace. Or I can register an ascx control, and set the tagname and the src. How do I reference this .cs file in the aspx page the way this dude does? I feel like I am missing something so obvious.

For example:
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

<%@ Register TagPrefix="uc1" TagName="videocontrol" src="~/controls/videocontrol.ascx" %>

Assume for the moment I have the file stored in ~/controls/CrawlableLinkButton.cs, and I want to refer to his control as he does:
<cs:CrawlableLinkButton runat="server" CommandName="Select" Text="Select" NavigateUrl='<%# "temp.aspx?PID=" + Eval("id").ToString() %>' />

Any help here? I am a bit thick and getting more and more tired. I know deep down I am a good .Net developer, honest - so why can I not figure out the little things?

post a comment

Date:2011-02-09 13:59
Subject:Socket Programming


I have created a socket connection as described on MDSN web site:
client: http://msdn.microsoft.com/en-us/library/bew39x2a(v=VS.85).aspx
server: http://msdn.microsoft.com/en-us/library/fx6588te(v=VS.85).aspx

It works fine. Events here are:
1) Client sends request
2) Server receives it
3) Server sends response
4) Server shutdown the socket
5) Client receives response

Then, I know, that between 2) an 3) might be a time gap. I want to send few interim responses like:
2a) Server sends response: Still working on your request.
The problem here is that I cannot send a response without shutting down the socket, but as I shout it down I am not able to send neither 3) nor another 2a)

Is it possible for client to get response without closing the socket connection? Something like .flush()?

corresponding piece of code under cut...Collapse )

5 comments | post a comment

Date:2010-08-05 12:15
Subject:Marshaling a union with a pointer

I am using Mono on Linux, and want to marshal the following unmanaged structure to a native one:

int 	type
union {
   guint32   u
   gint32   i
   gboolean   b
   gdouble   d
   gchar *   s
} 	value

According to Mono's excellent page on native-library interop, the way to deal with unions is to use StructLayoutAttribute with LayoutKind.Explicit and specify a FieldOffsetAttribute that is the same for all union members. So you might do something similar to this:

public struct Rpc {
 [FieldOffset(0)] public int type;
 [FieldOffset(4)] public uint value_u;
 [FieldOffset(4)] public int value_i;
 [FieldOffset(4)] public bool value_b;
 [FieldOffset(4)] public double value_d;
 [FieldOffset(4)] public string value_s;

The problem however is this, the Mono runtime crashes when this code is run, complaining that: "you cannot have a reference field that is the same offset as another field" in an [ExplicitLayout] structure. I assume this is referring to the last member of the union which is a pointer. Thing is, I'm not sure how else to do this.

I thought about just having a "public object value;" member of the structure, and then casting this as appropriate in managed code, but the runtime apparently cannot marshal to a vanilla object this way.


1 comment | post a comment

Date:2010-07-07 10:36
Subject:Help with Error Module

I posted my question here originally last night but I figured I might as well reach out to the LJ crowd to see if anyone here has answers.

I implemented an error handling httpmodule similar to the one described here:


If I run the application locally through the Visual Studio Development Server everything works as expected. If I run it through IIS with a wildcard mapping set up in the ISAPI extensions to go to the dotnet dll, and I have the checkbox to "Verify that the file exists" turned off - it works as expected for .aspx files but not for anything else.

In my web.config I have the following:

    <customErrors mode="RemoteOnly" defaultRedirect="~/_errors/500-server-error.aspx">
      <error statusCode="403" redirect="~/_errors/403-forbidden.aspx"/>
      <error statusCode="404" redirect="~/_errors/404-page-not-found.aspx"/>
      <add name="HttpErrorModule" type="tmpw.applicationname.App_Code.HttpErrorModule, applicationname" />

And under IIS errors I have it set up so that 404 errors go to the same 404 URL in web.config.

The behavior I am expecting is that if I go to appliationname.com/xyz.html and the page does not exist, it is kicked into the error handling code. The error handling module is set up to log the event and I should get an email. And even failing that the 404 page should still load in IIS settings.

The error handling code does kick in if I go to appliationname.com/xyz.aspx - a page which does not exist. But for any other file extension the 404 processing is handled by IIS. So any error logging I am doing in the HTTPModule is not getting called.

When I run an HTML page it does get processed to some extent. The code I have in Application_BeginRequest in global.asax does get called. But at the end of that block it stops processing.

The application I am working on is a migration of older code. I want to be alerted to every 404 that comes through the application so that I can see if we missed anything. I could potentially get this sort of information from the IIS logs or I could try to move the error logging to the code behind of the error pages instead of the HTTPModule. But I shouldn't have to should I? Why won't it process HTML? And why does it work when when running the application through Visual Studio but bot when I run it through IIS?

Any help would be appreciated.

8 comments | post a comment

Date:2010-04-14 12:28
Mood: confused

I'm getting very frustrated with trying to generate text on images in .Net. Whilst the process to do so is pretty simple, the results one gets simply aren't that satisfactory.

I have the following code (really very simple, as you can see) in an IHttpHandler, which I call in a loop to iterate through some of the fonts on my system as a proof-of-concept:

Far more detail here, behind a cut so as not to confuse / irritate all my non-techy friendsCollapse )

1 comment | post a comment

Date:2010-01-21 06:32
Subject:Custom validator in a custom control

I am programming a control that will have a custom validator in it. The control will be called on a page inside a repeater. I was hoping to have client validation on this custom validator. If I do this, when the page is rendered, won't the javascript function names be repeated and won't that cause an error? Is there a way around this and does anyone have any example code I can look at?

2 comments | post a comment

Date:2010-01-07 18:27


For a long time I was wandering how easy and comfortable to work with smart tags. Actually I didn’t knew how it was called officially, but anyway I thought (and still think) that this feature is awesome! Some time ago I’ve started to develop my own components and also spend more time tuning user’s interface. I found that it’s very time consuming and boring to setup necessary properties from the Property view. Its okay to setup few controls in little program, but when you have over 30 complicated views with custom components – you quickly became in a sad mood. So I decide found out how to create for my controls those pretty little triangles on the top right corner at the most standard components.

I found articles, books; I performed several tests and finally made what I want. And you know, it’s really helps me with development! Time saving in action! )

Now I’d like to share how to make it from the very beginning.

For all described actions below I used VS2008, ReSharper5

Read more...Collapse )

3 comments | post a comment

Date:2009-12-12 01:59
Subject:LINQ beginner

I have a pair of LINQ "group" statements, each outputs a IEnumerable<IGrouping<bool,int>>. Call these results a and b. I want to create four collections of ints, The ones that correspond to "a.Key && b.Key", "a.Key && !b.Key", "!a.Key && b.Key", "!a.Key && !b.Key".

I can convert a and b to Dictionaries with the ToDictionary extension method and have code like...

var foo = from aa in aMap[true] join bb in bMap[true] on aa equals bb select aa;

...but then I need to check the dictionary keys exists, which is not a huge overhead but I can't help thinking there must be some way of "join"ing a and b directly...?

6 comments | post a comment

Date:2009-11-18 17:26
Subject:NMock2 question

Is it possible in NMock2 to expect one of two different methods, A() or B(), on a mock to be called?

If there was a way to check how many times a given method had already been called, I could just


..and then test to see if one of them had been called and forcibly call the other so the expectations would be met. Ugly but good enough, but I don't think NMock2 mocks expose any interface that allows that the number of calls to be tested?

post a comment

Date:2009-10-06 17:14
Subject:Нужна помощь с DevExpress GridControl

Работал ли кто-нибудь с GridControl.AdvBandedGridView? Мне нужно, чтобы в band я мог поместить другой band на один уровень с column. А компонент позволяет в band'е держать или другие band'ы или column'ы, но не то и другое одновременно. Подскажите, как можно обойти это или же сделать визуальную симуляцию такого размещения band и column?

1 comment | post a comment

Date:2009-09-16 21:52
Subject:Application stops owing to callback from unmanaged DLL

Why does my c# application stop after receiving a callback from unmanaged DLL?

I've just encountered this very strange problem. And wonder why it could happen.

The similar situation is described by someone on MSDN-site.

But nobody there brought a clear explanation of that yet.

This little article described how to deal with callbacks from unmanaged code.
I think I did everything properly so that the program works well. But it doesn't.
If necessary, I could share snippets of my code.

Thank you.

3 comments | post a comment

Date:2009-09-03 16:09
Subject:Beginner's "-=" question

There are several ways to listen to an event with "+=". As a primarily-Java programmer I'm particulally drawn to the anonymous delegate. But if you want to subsequently remove the listener with -=, how can you identify the object? I guess it is not possible with the anonymous case, but even when you specify

MyEvent += MyInstanceMethod

a delegate for the MyInstanceMethod is being created... so will -= MyInstanceMethod remove the same object from the event's colection of listeners? Or do I have to create an explicit "new" instance of a delegate type, keep it on a field and "-=" the field?

3 comments | post a comment

Date:2009-08-18 15:54
Subject:Application.Exit() not exiting!
Mood: confused

I have the following:
                if (userDlg.ShowDialog(this) == DialogResult.Cancel)
But when I run the code, the application is not exiting when I click the cancel button on the userDlg dialog. Stepping through in the debugger it's hitting the Application.Exit(); line ok, but just carrying on!

So how can I get the program to terminate (neatly!) at this point?

Thanks in advance,


13 comments | post a comment

Date:2009-08-13 18:30

I'm having trouble populating a DataGridView from a Linq query. I have:
            var absenceQuery = from absence in currentYear.Absences select new {Start=absence.StartDate, End=absence.EndDate};
            bindingSource1.DataSource = absenceQuery;
I've checked that the Linq query is producing the entries I want, the DataSource for my DataGridView is set to bindingSource1, but the DataGridView comes out blank. What am I missing?

5 comments | post a comment

Date:2009-07-08 14:39
Subject:NMock2 question

Is there a way to change what a mock returns from its faked methods or properies after it has been initialised? Collapse )

2 comments | post a comment

Date:2009-06-10 15:19
Subject:IIS Application config wildcards

I have an application in IIS where I set up a wildcard so that all file extensions are processed via the .net dll. I did this so that I can process some URL rewriting. I see at the top of the configuration screen where I can specify which extensions should be processed by what processors. What I am wondering is if there is a way to specify an extension that should not be processed by the wildcard. Specifically I know that .jpg, .gif, .css, .png and .js extensions should not go through it. Is there a way to tell IIS to just serve them normally?

cross posted to a few communities.

1 comment | post a comment

Date:2009-05-08 13:04
Subject:Photo album component.

Is there a .net photo album component similar to facebook's photo album? Its a cheap gimmick to be sure but I do like the way the next set of photos preloads and scrolls left. I imagine similar functionality could be used to display any grid data. Any suggestions?

1 comment | post a comment

my journal