Hilarious …
Check this out : http://www.thewebsiteisdown.com/salesguy.html
|
Hilarious … Check this out : http://www.thewebsiteisdown.com/salesguy.html I have a side project on reflection where I try to reproduce Lutz Roeder’s Reflector in such a way as to allow me to inspect several issues within my projects. This has led me to research into all kinds of issues from MSIL to C# code model and Reflection, the latest one becoming one of my favorite topics from .NET technologies. My lattest hurdle was to overcome the devious “FileNotFoundException” when trying to resolve a type which is not in the main loaded assembly for reflection. What happens? Let’s suppose you load an assembly which you want to inspect using reflection. You would use something like: Assembly assembly = Assembly.LoadFile(path); Then you start the usual work of gettting the types and then get the methods of one of the types and then of course try to see something like the parameters of one of the methods. Ain’t reflection great? NO. Not if you don’t know how to use it. Because when you hit the line where you want to load the parameters of a method, the application will crash with a “FileNotFoundException” when the dll inspected is not in the same directory as the executable that is loading that assembly. Why the hell is that happening. Well I scoured the net for an answer and all where giving partial responses but none were actually giving me a sollution. Let’s consider the following. namespace A And let’s consider that the namespaces A and B are declared in separate projects and thus result in two different dlls and the project that defines namespace B references the project that defines namespace A. Now you want to load the “B.dll” to inspect the parameters from method “MyMethod” and you use the code I described above. Here the runtime will fail because he does not have a definition of the class C1, only of the class C2 which he already loaded and he will try to load the dll from the current directory (the directory of the running assembly - not A or B, but you program which inspects B). If the “A.dll” is not located there he will try in GAC and if that fails he will throw an exception. How do you fix this? Well you have the choice to copy the “A.dll” in your running directory or registed in GAC but hell, it is not nice and sometimes not possible. What you can do is to instruct the application domain to call a custom method defined by you when he needs to load an assembly. AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve); static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) What I told the domain here is to call tyeh CurrentDomain_AssemblyResolve method and there I made an assumption. When you compile the namespace B, in it’s debug directory the dll of namespace A is also copied. So if you load the assembly of namespace b from it’s debug directory, in the same directory we will have also the assembly of A. So we will load the assembly from there Simple and effective. This approach solves also the error “Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.” Cheers Today I want to talk about a strange issue and my workaround. Scenario: you have an UpdatePanel and a button outside it. You want upon an asyncronous postback to execute some custom javascript on the button outside the UpdatePanel. Normally this would be done by inserting a javascript from codebehind, either by using ClientScriptManager.RegisterScript or by adding a literal control which is actually a simple script. Well, this does not work during asyncronous postbacks, or at least not as it normally should. The document.GetElementById is returning always null when calling from an updatepanel with an ID of an element outside the updatepanel. So how to run that javascript? Subscribe a javascript function to the EndRequest event of the PageRequestManager: <script language=”javascript” type=”text/javascript”> What this does is to define a function and then set it to be executed after successfully asyncronous postback. Cheers! I never thought to live this day. I have Vista for over an year now and I have never seen the dreaded blue screen on it. I thought it was a thing of the past, an pre-Vista feature :). Still it happened. I tried running the Windows version of the TCPDump and the moment packets started flying through the network pipeline I was presented with the blue screen. Still this happened once in 1.3 years so I can say it’s a pretty good record so far. Vista is the most stable Windows version I worked with and even though it’s a resource hog, on a high end machine it moves like it should. Cheers. Since the Microsoft Ajax was released, a lot of ASP.Net developers began using UpdatePanel for streamlining their applications and indeed the WWW starts to seem a little bit more fluent nowadays. Unfortunately UpdatePanel is not used always in the right places or in the right way, some applications begin to feel clumsy and slow and you’re thinking WHY?! Below I compiled a small list of tips and tricks on how and where to use an UpdatePanel.
There are more, feel free to add your own Hi, Yesterday I was asked a simple question about using a separate browser window for selecting a value and then using the selected value in the main browser window. I’ve done this before but I realized that for a novice web programmer it is not trivial especially when you are accustomed to the ASP.Net programming model. Let’s consider the following scenario. You are editing an order for buying some books. You enter your name, address, and other information in the textboxes, but you are then required to select the book you are searching for. The problem the programmer is facing is that on one hand he has alot of books in the database (let’s say 5000 items), which means that it would be overkill to fill a dropdown with those names and hard for the user to select from it (too many options), on the other hand ussually he does not have the space to put a complex search in place. So the most ideal situation is to put a separate window that opens on command and where the user can use a more complex algorithm to search for the book he wants. Ok, this is not a very good example as in real world you first select the book, add it to cart and then go to the checkout and fill all remaining data. Still let’s say this is ok for the sake of the demonstration. So, we have a main window and from there we must open a second window where the user selects some data, then the selected data must be passed back to the main window. Well, ASP.Net does not offer something out of the box for this as the Asp model is based on a single window. So what you can do with asp is to redirect the page to a search window and then upon selecting the desired value redirect it back to the main window and put the values there (you can pass the values either through the Session object or QueryString). This unfortunately requires some extra programming and also might be a little bit difficult for the user to understand. Thus we get the the javascript sollution. User clicks on a button, a new browser window opens, user makes selection, the new browser window closes and the selection is put in the main window. Below you can find an example and some explanations. This is the main window: <%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”master.aspx.cs” Inherits=”_master” %> <html xmlns=”http://www.w3.org/1999/xhtml” > <%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”child.aspx.cs” Inherits=”child” %> The javascript function called on the click event is “openChildWindow” which has as parameter the id of the control that will receive the selection made in the child window. In the method we construct the URL of the child window where we will pass the id as a query string, then we use the window.open to open the child in a separate browser window. In the child window we have 2 textboxes from where we will take the selection. When the user presses the button, the “Done” function will first retrieve the opener object, which is a handle to the window that oppened the child window (this is normally null, unless the window was opened as a result of a window.open call). then we retrieve the html object from the opener window that has as id the string passed as query string. we use a separate function for that, which will search within the query string the keyvaluepair with the specified key and retrieve the value (we used “id” as we sent it like this from the master window). Afterwards we set the value of the target element with the values from the two textboxes and close the window. This is highly extensible as the child window can host a normal ASPX page and the results can be multiple and returned in various locations within the master page (just use more keys in the QueryString). That’s it for now. Feel free to adapt the above code to your needs and post any questions you might have. Edit: You can find also a more detailed example here Hi there, I just read a small article on slashdot.org about Intel being on the verge to release 80 and 120Gb Flash drives (solid state drives). Beside this being a quite astonishing news, because we use to think Intel is making only processors and chipsets, one gas got me thinkinh of the current state of computing within the PC area. I got now a rig with 4Gb Ram, and a SATA2 WD400Gb hardrive and still I don’t feel like my computer is flying or running extremly fast, although there are improvements. But this has a very solid reason - the harddrive. This is the slowest component in a system. The ram supports nowadays around 6400Mb/sec when using 800Mhz memory or 4267Mb/sec when using 533Mhz memory and the internal bus of a modern chipset can handle that easily; and dual core / quad core processor can process most available data on the bus. But all this hit a wall when communicating with the harddrive. Although the SATA2 interface can handle a theoretical 3000Mb/sec, and the best deliver around 2000Mb/sec, because of the physical constraints and how the drives are build, a typical read/write operation is around 1000Mb/sec and that is in ideal conditions. So what can be done to improve this state of matters. You really have few options and all of them are expensive.
So, there is a problem and there are sollutions. The choice depends really on the person, scenario and budget. At this point I would recoment 2 drives in Raid1 if you need extra performance but that’s just my pick, you have to find yours. If you have better ideas, let us know … Update I just found a news on TomsHardware (here) about OCZ anouncing a SSD with SATA2 capable of sustained 120Mbps reads and 100Mbps writes which is almost twice as fast as the old SSD generation and it’s available already in the UK with prices starting around 700USD for the 32Gb model and 1300USD for the 64Gb model. There are quite a lot of us who have a lot of papers on their desks with notes, tasks, observations. And there are those who use notepad alot to store usefull information on the project. Still it’s not easy to do this organization tasks when programming as it makes you either leave the development IDE or take your hands of the mouse and keyboard. Why don’t we have a way to make quick notes within Visual Studio 2005. Well we actually do, although I have not seen any using it. Just go to the View menu and select Task List. A dockable window will come in front and you can dock it somewhere, I dock it in a group of windows below the code, so that it is easy accessible. How do you use it, well, just double click on the first available row in the list and enter your comments/tasks there. For example, you have a task which is actually containing 7 inner tasks/functionalities. At some point you have to hardcode a variable so that you can go faster to another task and at some point you have to get back and correct this. This happens. No, no, don’t shake your head! you did it at some point. The problem is that you will likely forget this. Well, add a task like “Correct the hardcoding on file myfile.cs line 44″. At some point you will check that list and you can see what you still need to do and well … do it. Then just mark the task as completed (checkbox on the same line left side), or delete it. No more yellow stickers and endless blocknotes Cheers Well, URL Redirect, which is mostly used in PHP for making user friendly urls is supported by IIS but with a twist, at least in IIS7. I banged my head for a couple of hours and for some reason I could not make it work. Lastly I decided to google for url rewrite AND IIS7. To my surprise there is an additional step to be done when registering your HttpModule (the one that will handle the url rewriting). You not only need to add it to the modules tag of the web.config, but also to the <system.webServer> modules tag. See example below (of course this is a stripped down code, you have to intertwine it with your existing web.config) <system.web> Lots of thanks to Scott Guthrie for his article on url rewriting in asp.net: http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx and also to Denis van der Stelt for his observations on IIS7 and url rewriting: http://bloggingabout.net/blogs/dennis/archive/2006/11/29/IIS7-and-Url-Rewriting.aspx 07-03-2008 <add name=“UrlRewriter“ type=“UrlRewriter.Rewrite, UrlRewriter, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null“ /> I’m sick and tired of people bashing Vista. What’s wrong with you people?! I use Vista for over a year now. I am a proffesional .Net Developer and I do all my work on Vista. Problems? Where? Slowness? Where? When? Incompatibilities? For god’s sake … where? The only incompatibility I have is with my tv-tuner and that only in Media Center which does not yet support my Leadtek. Gaming issues? Nope … and I played over 15 titles last year. And let me point out another thing. Recently at work I had to work with XP (until the new licences come) and you cannot imagine the horror … It’s slow, buggy, unreliable and after 6 hours of work I have to restart it in order to make sure I can work further (and the machine it’s a beast in terms of raw performance). I can’t wait to put a Vista on that machine … I confess, I always update my machine and I started using SP since the first beta came out and that makes a difference, but the OS is good and more reliable that XP was even after SP2. The only anoying things with Vista are the new file dialogs and UAC, but UAC can be turned off and the file dialogs have a tendency to learn how you use them so after two days of working everything is ok. Don’t forget that the new SP (which is now available on MSDN) also brings the kernel of Windows Server 2008 which makes it more stable and faster. Take your time and install it, you won’t regret it. Ding, dong … |
PagesCategories
BlogrollMeta
|
|||||||||||||||||||||||||||||||||||||||||||||||||