Andrei Rinea

.NET Framework & SQL Server

Improving your Visual Studio experience : MetalScroll

clock November 5, 2009 11:57 by author Andrei Rinea

I've heard of RockScroll from Scott Hanselman a while ago in his blog entry. The Visual Studio plug-in basically replaces the vertical scroll bar with a real time thumbnail of the code. Plus it highlights words if you double-click them. It's niiiiceee!! I've soon downloaded it and used since then (more than a year).

However lacking the ease of using the window split, having parasyte double click highlightings and desynchronizing when you collapse a region of code annoyed me for a while...

Until today!!

Scott did it again and twitted about a good replacement for RockScroll : MetalScroll.

It does all RockScroll does plus :

  • double-clicking the scrollbar brings up an options dialog where the color scheme and scrollbar width can be altered.
  • the widget at the top of the scrollbar which splits the editor into two panes is still usable when the add-in is active.
  • you must hold down ALT when double-clicking a word to highlight all its occurrences in the file. RockScroll highlights words on regular double-click, which can be annoying when you actually meant to use drag&drop text editing, for example when dragging a variable to the watches window.
  • pressing ESC clears the highlight markers.
  • lines containing highlighted words are marked with 5x5 pixel blocks on the right edge of the scrollbar, to make them easier to find (similar to breakpoints and bookmarks).
  • multiline comments are recognized.
  • hidden text regions are supported.
  • it works in split windows.
  • it's open source, so people who want to change stuff or add features can do so themselves.
  • Here's how it looks in my VS :

     

     Later edit : This also comes as a patriotic thing for me as the author is a fellow romanian like me, Mihnea Balta :) 

    Currently rated 5.0 by 1 people

    • Currently 5/5 Stars.
    • 1
    • 2
    • 3
    • 4
    • 5


    A useful Custom Configuration Section for inline unconstrained XML

    clock September 21, 2009 00:05 by author Andrei Rinea

    As I was writing a small TCP server for serving Silverlight local TCP policy I came across a certain need. Inspired by Dan Wahlin's server implementation I chose to write a simplified version for myself. I needed to keep some XML in App.config without constraining it with a schema.

    The normal solution in this case is a custom section, sibling to appSettings if you wish. So my App.Config looked at first like this :

    <configuration>

      <
    appSettings
    >
        <
    add key="ipAddress" value="127.0.0.1"
    />
      </
    appSettings
    >

      <
    access-policy
    >
        <
    cross-domain-access
    >
          <
    policy
    >
            <
    allow-from
    >
              <
    domain uri="*"
    />
            </
    allow-from
    >
            <
    grant-to
    >
              <
    socket-resource port="4502" protocol="tcp"
    />
            </
    grant-to
    >
          </
    policy
    >
        </
    cross-domain-access
    >
      </
    access-policy
    >

    </
    configuration>

    Upon running the program even addressing the "ipAddress" key in the appSettings section throws an exception like:

    System.Configuration.ConfigurationErrorsException was unhandled
      Message="Configuration system failed to initialize"
      Source="System.Configuration"
      BareMessage="Configuration system failed to initialize"
      Line=0
      StackTrace:
           at System.Configuration.ConfigurationManager.PrepareConfigSystem()
           at System.Configuration.ConfigurationManager.GetSection(String sectionName)
           at System.Configuration.ConfigurationManager.get_AppSettings()
           at ConsoleApplication1.Program.Main(String[] args) in C:\Users\Andrei\Documents\Visual Studio 2008\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs:line 21
           at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
           at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
           at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
           at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Threading.ThreadHelper.ThreadStart()
      InnerException: System.Configuration.ConfigurationErrorsException
           Message="Unrecognized configuration section access-policy. (C:\\Users\\Andrei\\Documents\\Visual Studio 2008\\Projects\\ConsoleApplication1\\ConsoleApplication1\\bin\\Debug\\ConsoleApplication1.vshost.exe.config line 8)"
           Source="System.Configuration"
           BareMessage="Unrecognized configuration section access-policy."
           Filename="C:\\Users\\Andrei\\Documents\\Visual Studio 2008\\Projects\\ConsoleApplication1\\ConsoleApplication1\\bin\\Debug\\ConsoleApplication1.vshost.exe.config"
           Line=8
           StackTrace:
                at System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean ignoreLocal)
                at System.Configuration.BaseConfigurationRecord.ThrowIfParseErrors(ConfigurationSchemaErrors schemaErrors)
                at System.Configuration.BaseConfigurationRecord.ThrowIfInitErrors()
                at System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey)
           InnerException:

    So something is wrong. We need to tell the runtime that the "access-policy" section is allowed.

    <configuration>
      <
    configSections
    >
        <
    section name="access-policy" type="CustomSections.InlineXmlSection, CustomSections"
    />
      </
    configSections
    >
    ...

    At first I haven't placed the type attribute in the "section" element but it turned out it had to specified and be not empty. Moreover it must containt the fully-qualified class name and the assembly which contains it. The class must inherit from System.Configuration.ConfigurationSection.

    So I created an assembly called CustomSections, added references to the System.Configuration assembly and the System.Xml assembly.

    All you need to do is override the DeserializeSection method and load the XML document in there :

    using System.Configuration;
    using
    System.Xml;

    namespace
    CustomSections
    {
      public class InlineXmlSection :
    ConfigurationSection
      {
        public XmlDocument Content { get; private set
    ; }

        protected override void DeserializeSection(XmlReader
    reader)
        {
          (
    this.Content = new XmlDocument
    ()).Load(reader);
        }
      }
    }

    The code is pretty self-explanatory : we instantiate a new XmlDocument and load it from the XmlReader provided to us by the configuration infrastructure. If anything goes bad the exception handling will be the responsability of the caller. In this case the first call to ConfigurationManager.

    Now let's put the code to use :

    private static void Main(string[] args)
    {
      expectedRequestBytes =
    Encoding.UTF8.GetBytes("<policy-file-request/>"
    );
      listener =
    new TcpListener(IPAddress.Parse(ConfigurationManager.AppSettings["ipAddress"
    ]), 943);
      var policySection = (InlineXmlSection)ConfigurationManager.GetSection("access-policy"
    );
      policyBytes =
    Encoding
    .UTF8.GetBytes(policySection.Content.OuterXml);
      ...

    The underlined code is the relevant portion (the rest is provided for context). We get the section via ConfigurationManager.GetSection and we have to cast the result to the desired section type. The we use the section as we see fit.

    I will use this code sample in a future blog post regarding writing a very small TCP server for serving Silverlight 943 TCP Port policy XML content. Hope you find this useful.

    Currently rated 1.0 by 1 people

    • Currently 1/5 Stars.
    • 1
    • 2
    • 3
    • 4
    • 5


    Creating a reusable class - with all the goodies - part 3 : Final analysys

    clock September 7, 2009 23:59 by author Andrei Rinea

    I've decided to write a class that would model a SSN-like personal identification number used in Romania. It should be useful both in production code and as a learning material for my readers. In the first part I've shown a preliminary analysys and further analysys in the second part.

    Validation logic and what interfaces to implement is what is left for this part.

    Let's see the fragments that can be validated so we'll see how to model the validation flow. The first digit (the fragments can be seen in the first part) can have values from 1 to 9 so all possible values are valid. Nothing to validate here. The second fragment is the year. Also all possible values (00 to 99) are valid so nothing to validate here.

    The fun starts at the next fragment, the month. Only 01 to 12 values are valid anything outside (00, 13, 14, ..., 99) are invalid as they don't represent a valid year. The dating fun gets even hotter at the day. Although 00, 32, 33 and so on values are obviously invalid, some values are valid only in some months or some years.
    29th of february is valid in 2008 but not in 2009. 31 is valid in January but not in April. 30 is valid in April but not in February and so on.

    Next, the county has a list of predefined values as shown here, in the specs, so their validations should be piece of cake. The Enum.IsDefined (remember from the previous part that I've decided to use an enum for the county) should be a snap :)

    The index value must only not be 000 any other value is valid. This brings us to the final check : the check digit. The algorithm is moderately complex (as in not really 1+1 but something close) as seen in the specs :

    You take the PNC without the last (check) digit and put it next to the predefined value 279146358279. Next you multiply the first digit of the PNC to be validated to the first digit of this special validation value. Then you store it. Then you take the 2nd digit of your PNC and the 2nd digit of the special value and multiply it and you add it (the product) to the previously stored number and so on until you finish. In the end you have a sum of products that you will modulo by 11 and have a result : for 0..9 this is the final result. For 10 the result will be 1. This is the check digit. Enough theory, let's test it on my PNC :

    My PNC :               1810623420056
    The validation value : 279146358279
    
    1. 1 x 2 = 2; Partial-result (PR) : 2
    2. 8 x 7 = 56; PR : 56 + 2 = 58
    3. 1 x 9 = 9; PR : 67
    4. 0 x 1 = 0; PR : 67
    5. 6 x 4 = 24; PR : 91
    6. 2 x 6 = 12; PR : 103
    7. 3 x 3 = 9; PR : 112
    8. 4 x 5 = 20; PR : 132
    9. 2 x 8 = 16; PR : 148
    10. 0 x 2 = 0; PR : 148
    11. 0 x 7 = 0; PR : 148
    12. 5 x 9 = 45; PR : 193

    Now 193 % (modulo) 11 = 6 => my check digit is 6. This verifies my full PNC.

    As for interfaces to implement there are already-stated interfaces (as shown in the end of part 1) :

    • IEquatable<T> (enables equality comparison to another instance; type-safe)

      NOTE : Here type safe means the comparand is forced to be of the same type whereas in the type-unsafe versions the comparand is of type System.Object from which all classes inherit in .NET which allows invalid type instances to be passed in - these are required to work with old components and classes.
    • IComparable (enables value comparison to another instance; type-unsafe)
    • IComparable<T> (enables value comparison to another instance; type-safe)
    • IConvertible (enables converting to many basic types)
    • ICloneable; I thought of this later - after the initial analysys (enables deep cloning of the instance)

    There are also interfaces necessary to improve the serialization performance (speed and memory) :

    In the end, the IsValid and Violations properties should be grouped into a IValidable<T> interface that I'll define right now :

    interface IValidable<TFieldEnum> where TFieldEnum : struct
    {
        bool IsValid { get; }
        KeyValuePair<TFieldEnum, string>[] Violations { get; }
    }

    In the next part we'll FINALLY begin writing some code :)

    Be the first to rate this post

    • Currently 0/5 Stars.
    • 1
    • 2
    • 3
    • 4
    • 5


    Creating a reusable class - with all the goodies - part 2 : Further analysys

    clock September 7, 2009 23:27 by author Andrei Rinea

    In the first part we've layed out the basic requirements and had a glance of the data the class would model. In short it would model a SSN-like identificator for romanian citizens.

    Let's see what properties and methods the class should expose and what interfaces should be implemented and how.

    Basic data :

    • Sex
    • Foreigner or native
    • Resident
    • Birth date
    • Birth county
    • Index
    • Check digit

    Extra information :

    • The raw value
    • A list of violations (if any)
    • A boolean to quickly see if the instance is valid or not

    Let's make a quick range check and see what data type we could choose for the underlying (raw) value :

    The smallest valid PNC could be 1010100010011 (male, January 1st, 1900, born in Alba, first born in that day and the last digit, the check digit I am too lazy to compute it - we'll see later and - its value won't change the calculations much). The largest valid could be 9311299529999 (non-resident foreigner born on December 31st, 1999 and so on..).

    The range would be 9311299529999 - 1010100010011 = 8,301,199,519,988

    Now this is larger than Int32's (2 billion and something) and UInt32's (4 billion and something) maximum values so Int64 is the smallest numeric data type that could fit the raw value. It also fits the value without using an offset (having the raw value stored as a difference between a minimum value and the actual value) which simplifies the storage logic.

    Having it fit in an Int64 is reassuring that at least on 64bits OSs + CPUs the operations on it will be fast.

    Let's go back to the public properties now. The sex property could have been a simple boolean and set up a convention to set true for one sex and false for the other (I won't go in deep phylosophical discussion whether men or women are "true" :P ). However value 9 for the first digit screws things up as it does not specify the sex. Sure, a nullable boolean could be in order but I will choose an enum over this one. Let's call it PersonBirthSex and assign three values for it : Male, Female and Unknown (for 9'ers).

    The Foreigner property can very well be a bool just like Resident.
    The BirthDate will be a DateTime.
    For the county of birth an enum will fit the bill.
    Index is always positive and has values from 1 to 999 inclusive. So the nicest fit will be the UInt16 (ushort) type.
    The check digit is from 1 to 9 inclusive so a byte should do the trick.

    Having settled on the public properties, their types and the raw value type we'll see the validation part.

    As I said in the beginning the instance of the class should be able to report zero, one or more violations that it may contain. For a quick check it will also expose a bool that we'll call "IsValid". Let's end the analysys in the next episode.

    Be the first to rate this post

    • Currently 0/5 Stars.
    • 1
    • 2
    • 3
    • 4
    • 5


    Creating a reusable class - with all the goodies - part 1 : Preliminary analysys

    clock September 7, 2009 22:22 by author Andrei Rinea

    I always wanted to build a class that could have some value in the real life and that could serve as an example for some (good) practices. It seems that I have the opportunity right now.

    In every country, mine included, there is some sort of identification number, unique for all its citizens. In the US there is the SSN and in Romania there is a PNC (CNP spelled in romanian) which stands for Personal Numeric Code. 

    Some applications (web sites and other kinds) may require you, at some point, to specify a valid PNC. These apps usually validate it (lightly most of them) and none of them I've seen to take advantage of the info the PNC conveys for pre-filling certain fields. This sparked me the idea to write a dedicated class for this.

    The specifications for this romanian SSN (the PNC) can be found on Wikipedia : translated to english version and romanian (original version).

    In short there are 13 digits like so :

    S YY MM DD CC III X

    S represents the sex and the century of the birth date. Odd digits for males and even digits for females. 1 and 2 for 20th century, 3 and 4 for 19th century, 5 and 6 for 21st century, 7 and 8 for resident foreigners and 9 for non-resident foreigners
    YY represents the two-digit version of the birth date's year
    MM the same for the month
    DD the same for the day of the month
    CC represents the two-digit code of the county of birth
    III represents an index number - unique per county per day
    and finally
    X represents the check digit

    Not very complicated, isn't it? Let's take mine for example :

    1810623420056

    So:

    1. I am a male, born in the 20th century (1)
    2. I was born in 1981
    3. .. in June
    4. on the 23rd day
    5. in the 42 county (that is Bucharest, 2nd district)
    6. The fifth in the birth center
    7. and the check digit is 6

    What I would like from a class that models this entity :

    • To have a parameterless (default constructor) so it can be easily serializable
    • To not throw exceptions in the other constructors if the data is bogus but rather to sum up a list of violations (for example the day is 32)
    • To be bind friendly in Winforms, WPF, ASP.NET Web forms and ASP.NET MVC
    • To expose a read/write property (we'll call it "Value") to enable easy binding with the ASP.NET MVC's default binder
    • The XML serialization should take minimal space (only relevant data should be serialized and elements and attributes should have short names - but still understandable)
    • The same for binary serialization
    • It should implement IConvertible so the class users should have minimal effort in converting it to/from other types
    • It should implement IEquatable and IEquatable<T> so it is easy for one to compare two instances
    • Similar thing for IComparable so sorting should be fast and efficient
    • There should be a compact form so large collections could be marshalled efficiently even over slow channels
    • Last but not least it should provide (a) static method(s) to generate random values

    There's a long list of requirements... let's see how we'll manage over the course of the next parts :)

    Be the first to rate this post

    • Currently 0/5 Stars.
    • 1
    • 2
    • 3
    • 4
    • 5


    Using ADO.NET Data Servics in Silverlight 3 and eager loading parent entities

    clock August 19, 2009 09:57 by author Andrei Rinea

    We decided that in our Silverlight app that we develop we should not waste time writing WCF services manually to interact with data. So we turned to ADO.NET Data Services.  

    I created a small Web App to host the ADO.NET Data Service which exposed the Entity Framework Model. All fine and dandy, being a bit pedant I created a very small console application just to add a service reference and test the data retrieval. All went well. Then I put the querying logic in the Silverlight app.

    Something like

    var employees = (from e in GetFreshContext().Employees select e).ToArray();

    But upon running in Silverlight (in the console app it ran great) I get thrown with this exception : 

    System.NotSupportedException: Specified method is not supported.
    at System.Data.Services.Client.DataServiceQuery`1.System.Collections.Generic.IEnumerable<TElement>.GetEnumerator()
    at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
    at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
    at MyApp.MainPage..ctor()
    at MyApp.App.Application_Startup(Object sender, StartupEventArgs e)
    at System.Windows.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
    at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)

    WTF?! The very same code doesn't work in Silverlight no matter how I try. Searching on the web desperately, led me in the end to this nice post on the blog called (how ironically?) theproblemsolver : Consuming an ADO.NET Data Service from Silverlight written by Maurice De Beijer

    It turns out you can't query synchronously in Silverlight although the exception did **NOT** contain any clue whatsoever regarding this although it should. The correct way :

    var query = from t in GetFreshContext().Employee select t;
    var dsQuery = (DataServiceQuery<Employee>)query;
    dsQuery.BeginExecute(result =>
    {
        ComboEmployees.ItemsSource = dsQuery.EndExecute(result).ToArray();
    }, null);
    ComboEmployees.DisplayMemberPath = "FullName";
     

    Then I ran across another problem and it puzzled me for a while too until I found the answer. Specifically I needed to load the Department along with Employee (the entities are different in the real app). Retrieving the list of employees brought the Department property null.

    I (might) retrieve a long list of employees so re-querying for each employee entity for the department would be a very costful operation (too many HTTP requests). Looking for solutions I came across Typed Eager Loading Using Entity Framework (& What is Eager Loading vs Deferred Loading) which solves the magic string problem of eager loading but I didn't really care about the string.

    I needed the entities eager-loaded. However on Silverlight/ADO.NET Data Services I don't have the option of

    DbDataContext.Categories.Include(“Products”)

    as presented in the blog post.

    Finally it turns out that, as John Papa describes in the MSDN Magazine (Using Silverlight 2 With ADO.NET Data Services), you have an Expand method :

    var query = from t in GetFreshContext().Employee.Expand("Department") select t;
    var dsQuery = (DataServiceQuery<Employee>)query;
    dsQuery.BeginExecute(result =>
    {
        ComboEmployees.ItemsSource = dsQuery.EndExecute(result).ToArray();
    }, null);
    ComboEmployees.DisplayMemberPath = "FullName";

    Hope this helps

    Currently rated 5.0 by 1 people

    • Currently 5/5 Stars.
    • 1
    • 2
    • 3
    • 4
    • 5


    Tip : Middle click on tab

    clock August 16, 2009 11:18 by author Andrei Rinea

    Did you know that middle-clicking (that is clicking on the mouse's middle button - usually the wheel) on a tab in most decent software applications will close the tab? Here's a small list of applications which honor this :

    • Most main browsers (IE 7+, Opera 7.x+, Firefox 2.x+, Chrome 1.x+ - yes, Safari - doesn't)
    • Visual Studio
    • RSS Bandit (my RSS Reader of choice - have tried Google Reader and Feed Reader in the past but no thanks)

    Why would this be useful? Because CTRL-F4 or searching for the "X" closing button might take more time and/or precision than middle clicking anywhere on the tab label up there :)

    Currently rated 5.0 by 1 people

    • Currently 5/5 Stars.
    • 1
    • 2
    • 3
    • 4
    • 5


    Beware of writing DHTML for many small sites

    clock June 15, 2009 23:59 by author Andrei Rinea

    I've recently had to write a "pop-up" (javascript simulated modal box) invitation for surveys to be automatically embedded in certain (over 2,000) relatively small sites. 

    These sites share a common web analytics javascript snippet, just like Google Analytics and the goal was to seamlessly integrate this facility. The integration was not the first version but the second, the first being archaic, simplistic, unmodular and hard to maintain. However there was something good in it (I'll post a joke at the end of the post) : the client-side part was written in ActionScript / Flash. The pm however pushed (literally) the idea of having a DHTML part (HTML/CSS + JavaScript that is) instead of the Flash since it won't require the clients to have the Adobe Flash plug-in installed.

    At first this seemed a GREAT idea since it would be lighter, faster and it would allow more clients / visitors to be able to receive the invitation. Only javascript was required but the whole tracking snippet was already written in javascript so it wouldn't mean any more requirements for the visitors.

    Of course we looked at several pre-made "modalboxes" such as Lightbox and ModalBox. At first the PM chose ModalBox since it was fancy, has smooth animation, a click outside the box or an ESC keypress would dismiss it and so on. Things seemed to go well in the beginning but there were three javascript library dependencies.

    In the first tests I would just hardcode three script elements and feed the apropiate src attribute values. Things went perfect. However I remembered that the whole thing this invitation was served was from a javascript already embedded on the webmasters' sites. And the business requirement was to not have to bother the webmasters to alter in any way their sites.

    Alrightee, I thought, we'll just "documen.write" them dynamically. There came the first screw-up. The libraries will load perfectly, serialized, if they were statically referenced in the HTML markup but NOT if they were document.written. A library could be loaded before the previous (and on which it depended) was loaded.

    At first I combined all of them in one big file (~180k = prototype, scriptaculous/effects, modalbox and the custom code), then gzipped it and so on. Gzipping was not much of a cinch since the last one, the custom code one was different for any of the 2,000 sites. So I cached them in RAM (ASP.NET MVC / HttpRuntime Cache / Custom ActionResult).

    This seemed to work ok until I've tested with sites that already have a prototype reference in code. Seems that loading prototype when it already is crashes the javascript. Dohhh!!!!

    Of course I just thought how much nicer a flash version would have been since there is less chance of having flash elements collide with each other. But no, the pm is just in love with his DHTML.

    Well, let's fix this fucker... I went back to a non-combined form and at the end of the first library (prototype) I would load the next and so on through callbacks. Rewrite the whole client-side just days before the deadline. Included check to see if any of the libraries was already loaded and skip the loaded one(s). This went great until I hit sites that had too old versions of prototype and/or scriptaculous. Bummer.

    I couldn't unload the old version and load the new one because I simply couldn't plus it could have broken site functionality. Well-well-well. I designed rules such as "if IE 6 or older and prototype older than 1.6.0 don't serve the invitation" - since, again, it would crash the javascript execution. I came up with so many exceptions that they became almost impossible to maintain/grasp/etc.

    In a desperate attempt since the deadline was extended I searched for another modal box out there to fix the whole damn thing and came upon Facebox. In parallel a colleague of mine offered to help and started to write a modal box from scratch to avoid the dreaded javascript library references that would cause conflicts between the site's javascript and our own javascript code.

    Did I mention how much I hate javascript? The nasty, dynamically typed, typo-prone, slow interpreted shit...and implemented in a thousands ways across several browsers and versions. Jeez..

    The facebox was another re-write in the last day of an other deadline extension and that was last friday and saturday. No, working in weekend because of the pm's folly is NOT fun. Not one byte, not one bit even! Turns out several sites were crashing (btw when I say crash I don't mean a literal process crash with dump report and so on but stopping the javascript execution and such) on IE 6 and sometimes on 7 and 8. Turns out IE and only IE stops the whole page from loading if you alter the body of the document if it is altered by a script which is NOT a DIRECT descendent of the body element.

    This reminds me of Tanya Stephens - It's a pity lyrics (the song is here), specifically "It really fuck me up because me check fi you so much". 

    This IE crap of behaviour is documented in the Knowledge Base. But still the suggested solutions mean altering (only statically!!) the site's content which I CAN'T since I don't own the site. So I am screwed up once again. The facebox is already jQuery dependent (more conflicts with MooTools and so on) and has the bad habit of appending at the end of the body. Some sites place our analytics script in a div in the body so the execution will literally bring down the page.

    In the meantime I called up on my colleague who developped the custom modal box from scratch with no dependencies and with his help and another's colleague we were able to integrate it, HTML/CSS fine tune it and debug it. We also implemented the "click outside" and the "press ESC" for dismissal. After working one day from 9:00 (AM) to 22:00 with no lunch break.

     

    By the way, did I tell you how much our pm loves to tell us how the company "rewards result and not effort"? He is really a ... character (he might read this). 

    I think I finally nailed it for the most of the scenarios (5 browsers, 9 total versions and 2,200+ sites) and tomorrow might be the big day. Keep your fingers crossed for me people Cry

    Be the first to rate this post

    • Currently 0/5 Stars.
    • 1
    • 2
    • 3
    • 4
    • 5


    Solving automatic properties compile problems when migrating an ASP.NET 2.0 site to .NET 3.5

    clock March 19, 2009 01:02 by author Andrei Rinea

    I've recently migrated/adapted a web site built on ASP.NET 2.0 (.NET Framework 2.0) to .NET Framework 3.5.

    Oh the goodies of .NET Framework 3.5 : LINQ, lambdas, automatic properties and so on. At first I just set the build option to .NET Framework 3.5 :

    Everything fine and dandy till I ran the site :

    WTF? I mean it is set to use the .NET Framework 3.5, it should see that these are automatic properties not abstract property fragments. Well it doesn't. After a few comparisons of the Web.config files with freshly created .NET 3.5 web sites I discovered what has to be done : include the system.codedom element in web config just as a child of the configuration element :

     

    <system.codedom>
      <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <providerOption name="CompilerVersion" value="v3.5"/>
      <providerOption name="WarnAsError" value="false"/>
      </compiler>
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <providerOption name="CompilerVersion" value="v3.5"/>
      <providerOption name="OptionInfer" value="true"/>
      <providerOption name="WarnAsError" value="false"/>
      </compiler>
      </compilers>
    </system.codedom>

     

    That's it! It works fine now. I hope this can help some of you :) 

    Be the first to rate this post

    • Currently 0/5 Stars.
    • 1
    • 2
    • 3
    • 4
    • 5


    Carefully test your sensitive code

    clock February 19, 2009 11:42 by author Andrei Rinea
     am also working on a site that will handle real money. I was having a little hard time determining why the users don’t get their money back if the bet (a bets site) is cancelled

    In the CancelBet stored procedure (T-SQL) :

    ..
    UPDATE		Account
    
    SET		Amount = Account.Amount + BB.Amount
    
    FROM		BetBettings	BB
    
    INNER JOIN	BetOutcomes	BO	ON	BB.BetOutcomesId = BO.BetsId
    
    WHERE		BO.BetsId = @BetId
    
    AND	        Account.UserId = BB.UserId
    



    The bold-underlined text fragment should have been "BO.Id". A very small slip-up but enough to not trigger any automatic checking in Microsoft SQL Server Management Studio 2008 and enough to have the users cry out loud : “FRAUUUD”.

    The site is not live yet, so no user has been hurt during the experiment. However anyone wouldn’t have believed me that this error in favor of the site was not intentional … they would have said something like “how convenient…”.

    Be the first to rate this post

    • Currently 0/5 Stars.
    • 1
    • 2
    • 3
    • 4
    • 5


    About me

    A passionated .NET Developer working closely with Microsoft technologies. View my public site.

    Page List

    Sign in