<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>.NET General Forum RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest threads from the '.NET General' forum at Programmer's Heaven, excluding replies.</description>
    <language>en</language>
    <copyright>Copyright 2009 Programmers Heaven</copyright>
    <pubDate>Fri, 03 Jul 2009 20:13:42 -0700</pubDate>
    <lastBuildDate>Fri, 03 Jul 2009 20:13:42 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>Applications Using Windows Concurrency APIs</title>
      <link>http://www.programmersheaven.com/mb/dotnet/393098/393098/applications-using-windows-concurrency-apis/</link>
      <description>I am searching for a few applications that extensively use the windows synchronization functions... specifically the critical-section functions, mutex functions and the wait functions. If anyone has any information in this regard, your help would be highly appreciated....&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/dotnet/393098/393098/applications-using-windows-concurrency-apis/</guid>
      <pubDate>Wed, 01 Jul 2009 01:49:41 -0700</pubDate>
      <category>.NET General</category>
    </item>
    <item>
      <title>Using Class Template in Visual C++</title>
      <link>http://www.programmersheaven.com/mb/dotnet/393052/393052/using-class-template-in-visual-c++/</link>
      <description>Hello,&lt;br /&gt;
&lt;br /&gt;
I wrote template which return matrix in Window Form Application .My template is below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;template&amp;lt;class T&amp;gt;
    class matrix1 {
    protected:  
 
    public:
          T *data;
 
            const unsigned rows, cols, size;
                matrix1(unsigned r, unsigned c) : rows(r), cols(c), size(r*c) {
 
          data = new T[size];
            }
            ~matrix1() { delete data; }
            void setValue(unsigned row, unsigned col, T value) { 
                    data[(row*cols)+col] = value;
            }
            T getValue(unsigned row, unsigned col) const {
                    return data[(row*cols)+col];
            }
};&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
I wrote this code in Main Project File in Windows Form Application.I defined 341*680 matrix with using this template :&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;matrix1&amp;lt;double&amp;gt;A(341,680);&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
I used function that do operation on this template and I defined it like this:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;void function(matrix1&amp;lt;double&amp;gt; &amp;amp;b,array&amp;lt; double&amp;gt;^ temp)&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
And call it:&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
function(A,temp);&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
(temp is one dimensinonal data array that I have to use for my programming algorithm)&lt;br /&gt;
&lt;br /&gt;
For Example;When I want to print data that is located in the first row and first column.&lt;br /&gt;
&lt;br /&gt;
Visual C++ recognise getvalue and setvalue function ,but couldn't print anything and gave a lot of error interested with matrix1 template&lt;br /&gt;
&lt;br /&gt;
I tried this template and function on CLR Console Application and it worked.How could I do this On Windows Form Application.And Where should I locate template class on Windows Form Application.&lt;br /&gt;
&lt;br /&gt;
Best Regards... &lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/dotnet/393052/393052/using-class-template-in-visual-c++/</guid>
      <pubDate>Tue, 30 Jun 2009 06:06:15 -0700</pubDate>
      <category>.NET General</category>
    </item>
    <item>
      <title>ListView + Edit Item</title>
      <link>http://www.programmersheaven.com/mb/dotnet/392787/392787/listview-+-edit-item/</link>
      <description>I want to edit the data into the ListView of the first item. when i right click on item..But when i right click selected item not come in edit mode....Plz check it out..&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        For lcount As Integer = 1 To 3
            ListView1.Items.Add(lcount.ToString, lcount - 1)
        Next
    End Sub

 Private Sub ListView1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListView1.MouseClick
        If e.Button = Windows.Forms.MouseButtons.Right Then
            Dim ht As ListViewHitTestInfo = ListView1.HitTest(location)
            If ht.Location = ListViewHitTestLocations.Label Then
                ListView1.LabelEdit = True
                ht.Item.BeginEdit()
            End If
        End If
    End Sub
&lt;/pre&gt;&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/dotnet/392787/392787/listview-+-edit-item/</guid>
      <pubDate>Wed, 24 Jun 2009 09:46:38 -0700</pubDate>
      <category>.NET General</category>
    </item>
    <item>
      <title>datetime conversion</title>
      <link>http://www.programmersheaven.com/mb/dotnet/392704/392704/datetime-conversion/</link>
      <description>Hi All,&lt;br /&gt;
&lt;br /&gt;
I want to convert current datetime (differs in format depending regional setting) into 20090622172120 format.&lt;br /&gt;
How do I do that? I want solution that work with any regional setting.&lt;br /&gt;
&lt;br /&gt;
many thanks,&lt;br /&gt;
&lt;br /&gt;
Jeet&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/dotnet/392704/392704/datetime-conversion/</guid>
      <pubDate>Mon, 22 Jun 2009 23:10:08 -0700</pubDate>
      <category>.NET General</category>
    </item>
    <item>
      <title>Context Menu</title>
      <link>http://www.programmersheaven.com/mb/dotnet/392679/392679/context-menu/</link>
      <description>Hey frnds i want to show context menu on drop down menu item right click...As an example,Suppose we add bookmark in mozilla &amp;amp; when we right click on that item..context menu is showing.&lt;br /&gt;
..How to do that..can somebody plz tell tell me..&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
Private Sub MenuAddToFavorites_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MenuAddToFavorites.MouseDown

        If e.Button = Windows.Forms.MouseButtons.Right Then
            'ContextMenuFavorites.Show(e.Location)
            ContextMenuFavorites.Show(DirectCast(sender, ToolStripMenuItem).GetCurrentParent.PointToScreen(
e.Location))
        End If
    End Sub
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
Problem is dat when i right click,context menu is showing..&amp;amp; menu disappeared..But i want that menu should not be disappeared,..&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/dotnet/392679/392679/context-menu/</guid>
      <pubDate>Mon, 22 Jun 2009 10:20:10 -0700</pubDate>
      <category>.NET General</category>
    </item>
    <item>
      <title>Add dll file in project</title>
      <link>http://www.programmersheaven.com/mb/dotnet/392640/392640/add-dll-file-in-project/</link>
      <description>Hello ,,&lt;br /&gt;
I want to Apply the *.dll file that programming by .NET as in vb6 IDE.&lt;br /&gt;
Best regards ..&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/dotnet/392640/392640/add-dll-file-in-project/</guid>
      <pubDate>Mon, 22 Jun 2009 01:46:51 -0700</pubDate>
      <category>.NET General</category>
    </item>
    <item>
      <title>vb.net 2005</title>
      <link>http://www.programmersheaven.com/mb/dotnet/392495/392495/vbnet-2005/</link>
      <description>Hi guy's am writing an application using vb.net 2005 and mysql i w'd like any body to help me or show me a code that can  save a date function in to mysql because later am supposed to print a report showing all goods which were sold in aprticular month and on weekly basis thank you&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/dotnet/392495/392495/vbnet-2005/</guid>
      <pubDate>Thu, 18 Jun 2009 13:33:43 -0700</pubDate>
      <category>.NET General</category>
    </item>
    <item>
      <title>TabPage Image + DrawItem</title>
      <link>http://www.programmersheaven.com/mb/dotnet/392317/392317/tabpage-image-+-drawitem/</link>
      <description>hi frnds, I want to add cross button image on the right hand side of tabPage...I m creating tabpages at Runtime....&lt;br /&gt;
Mine code is added image to the Right along with the text at the left...&lt;br /&gt;
&lt;br /&gt;
I want to just ask that is that possible to write the code the image...so dat i m able to close tab when i click on the image&lt;br /&gt;
PLZ help me on this matter&lt;br /&gt;
Mine code below that is adding tab at runtime along with image-&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
Public Class Form2
    Dim TabPageIndex As Integer
    Dim tab As TabPage = New TabPage("SONIA SARDANA")
    Public Sub New()
        InitializeComponent()
        TabControl1.DrawMode = System.Windows.Forms.TabDrawMode.OwnerDrawFixed
    End Sub

    Private Sub TabControl1_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs)
        Try


            Dim img As Image = ImgIcons.Images(0)

            Dim _imageLocation As Point = New Point(15, 5)
            Dim _imgHitArea As Point = New Point(13, 2)


            Dim r As Rectangle = e.Bounds
            r = Me.TabControl1.GetTabRect(e.Index)
            r.Offset(2, 2)

            Dim TitleBrush As Brush = New SolidBrush(Color.Black)
            Dim f As Font = Me.Font

            Dim title As String = Me.TabControl1.TabPages(e.Index).Text
            e.Graphics.DrawString(title, f, TitleBrush, New PointF(r.X, r.Y))
            e.Graphics.DrawImage(img, New Point(r.X + (Me.TabControl1.GetTabRect(e.Index).Width - _imageLocation.X), _imageLocation.Y))

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Try
            Static lTabIndex As Integer
            lTabIndex = lTabIndex + 1
            tab.Name = "Tab" &amp;amp; lTabIndex
            TabControl1.TabPages.Add(tab)
            TabPageIndex = TabControl1.TabPages.Count - 1
            AddHandler TabControl1.DrawItem, AddressOf TabControl1_DrawItem

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
End Class
&lt;/pre&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/dotnet/392317/392317/tabpage-image-+-drawitem/</guid>
      <pubDate>Sun, 14 Jun 2009 09:25:32 -0700</pubDate>
      <category>.NET General</category>
    </item>
    <item>
      <title>Use of OMR sheets in .Net</title>
      <link>http://www.programmersheaven.com/mb/dotnet/392226/392226/use-of-omr-sheets-in-net/</link>
      <description>Please can any one tell me&lt;br /&gt;
How to use OMR scanned sheets in C#.Net&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/dotnet/392226/392226/use-of-omr-sheets-in-net/</guid>
      <pubDate>Fri, 12 Jun 2009 03:53:22 -0700</pubDate>
      <category>.NET General</category>
    </item>
    <item>
      <title>Can I make a form at runtime change into design mode?</title>
      <link>http://www.programmersheaven.com/mb/dotnet/392075/392075/can-i-make-a-form-at-runtime-change-into-design-mode/</link>
      <description>Hi all,&lt;br /&gt;
&lt;br /&gt;
Can I make a form at runtime change into design mode in .Net framework 3.5?&lt;br /&gt;
&lt;br /&gt;
For example: when users run my form, they can change a position of the controls (of course with the rule like design mode), and can change a properties of the controls .. (like design mode).&lt;br /&gt;
&lt;br /&gt;
Can I just config this function in .Net framework? not coding so much?&lt;br /&gt;
&lt;br /&gt;
Thanks a lot,&lt;br /&gt;
Dan&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/dotnet/392075/392075/can-i-make-a-form-at-runtime-change-into-design-mode/</guid>
      <pubDate>Tue, 09 Jun 2009 01:32:47 -0700</pubDate>
      <category>.NET General</category>
    </item>
    <item>
      <title>reverse feed the paper so that the printing starts from the top</title>
      <link>http://www.programmersheaven.com/mb/dotnet/391443/391443/reverse-feed-the-paper-so-that-the-printing-starts-from-the-top/</link>
      <description>In my application i am printing invoices by dot matrix printer.&lt;br /&gt;
Now I have to implicitly eject extra paper so that i can easily tear it from the perforated line.But for the next invoice it is esential to reverse feed the paper so that the printing starts from the top.&lt;br /&gt;
The problem is how to reverse feed the paper.Is there any command for it .or simply the printing should start from the beginning of the paper.I am using tvs msp seri---350 paper length is 4 inch&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/dotnet/391443/391443/reverse-feed-the-paper-so-that-the-printing-starts-from-the-top/</guid>
      <pubDate>Sun, 24 May 2009 10:24:37 -0700</pubDate>
      <category>.NET General</category>
    </item>
    <item>
      <title>Time format in Microsoft Access</title>
      <link>http://www.programmersheaven.com/mb/dotnet/391212/391212/time-format-in-microsoft-access/</link>
      <description>Hello. I have an access database linked to my vb.net program. When I update a record from my dataset back to the database, a "StartTime" field is being saved with full the format "DDD MMM DD, YYYY HH:MM tt", instead of a time "HH:MM tt" only. I have this datacolumn binded to a textbox within my program. The datatype for the datacolumn for my dataset is "DateTime", I believe this to be the culprit but there are no other options for "Time" or "Medium Time". The format for the field in access is set to "Medium Time", but vb.net seems to want to write the entire date and time to the database. Any suggestions, pulling my hair out as this is one of many problems I've encountered while using vb.net.  Thanks in advance for any help!&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/dotnet/391212/391212/time-format-in-microsoft-access/</guid>
      <pubDate>Tue, 19 May 2009 15:04:37 -0700</pubDate>
      <category>.NET General</category>
    </item>
    <item>
      <title>[.MSIL Reversing] Damn pointer instructions...</title>
      <link>http://www.programmersheaven.com/mb/dotnet/391199/391199/msil-reversing-damn-pointer-instructions/</link>
      <description>Hi all! Hope it's not a problem if I ask something about IL instructions in a forum about .NET languages, but I really need some help fixing a problem.&lt;br /&gt;
&lt;br /&gt;
I'm trying to reverse those instructions...&lt;br /&gt;
&lt;pre class="sourcecode"&gt;ldloc.s texturedRef
conv.i 
ldloc.s num11
ldloc.1 
mul 
ldloc.s num12
add 
conv.i 
sizeof [Microsoft.DirectX.Direct3D]Microsoft.DirectX.Dire
ct3D.CustomVertex/TransformedColoredTextured
mul 
add 
conv.u 
stloc.s texturedPtr&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
My best try is:&lt;br /&gt;
&lt;pre class="sourcecode"&gt;CustomVertex.TransformedColoredTextured* texturedPtr = (CustomVertex.TransformedColoredTextured*)((byte)(
texturedRef + ((k * num2) + m)));&lt;/pre&gt;&lt;br /&gt;
Buy I obviously get something like that:&lt;br /&gt;
&lt;pre class="sourcecode"&gt;ldloc.s texturedRef
conv.i 
ldloc.s num11
ldloc.1 
mul 
ldloc.s num12
add 
conv.i 
sizeof [Microsoft.DirectX.Direct3D]Microsoft.DirectX.Dire
ct3D.CustomVertex/TransformedColoredTextured
mul 
add 
conv.u4 &amp;lt;--------------- Difference
conv.u 
stloc.s texturedPtr&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
If I compile this line removing the (byte) boxing, like that:&lt;br /&gt;
&lt;pre class="sourcecode"&gt;CustomVertex.TransformedColoredTextured* texturedPtr = (CustomVertex.TransformedColoredTextured*)(texture
dRef + ((k * num2) + m));&lt;/pre&gt;&lt;br /&gt;
I get those instructions (without final conv):&lt;br /&gt;
&lt;pre class="sourcecode"&gt;ldloc.s texturedRef
conv.i 
ldloc.s num11
ldloc.1 
mul 
ldloc.s num12
add 
conv.i 
sizeof [Microsoft.DirectX.Direct3D]Microsoft.DirectX.Dire
ct3D.CustomVertex/TransformedColoredTextured
mul 
add 
stloc.s texturedPtr&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
Those differences are making texture rendering process very very slow... with .NET Reflector Reflexil I injected the correct instructions and all is working fine, then I need to find a way to get rid of this megind difference. Well... I can't get a stand alone "conv.u". Any ideas anyone?&lt;br /&gt;
&lt;br /&gt;
Thanks in advance!&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/dotnet/391199/391199/msil-reversing-damn-pointer-instructions/</guid>
      <pubDate>Tue, 19 May 2009 06:38:20 -0700</pubDate>
      <category>.NET General</category>
    </item>
    <item>
      <title>Need Tips for Optimizing Windows Form Applications</title>
      <link>http://www.programmersheaven.com/mb/dotnet/390938/390938/need-tips-for-optimizing-windows-form-applications/</link>
      <description>Hi guys!&lt;br /&gt;
&lt;br /&gt;
I have been doing minor projects in C# in the past, but this is the only time where I feel I need to optimize the application. Specifically, I am looking for ways to improve the performance of the application through the following:&lt;br /&gt;
&lt;br /&gt;
1. Data caching before application starts.&lt;br /&gt;
2. Improving drawing performance of user controls.&lt;br /&gt;
&lt;br /&gt;
Especially for no. 2, it is very noticeable that when the application starts, a slight delay in the drawing of controls and images is evident (My application has a lot of custom controls). You can easily see some controls being drawn first compared to others. I am pretty much sure this is not due to my hardware, since more complex applications run flawlessly. What could be a way to fix this?&lt;br /&gt;
&lt;br /&gt;
If my statements are vague, forgive me, because I really have no clue on the solution and even the problem itself. If anyone can point me to the right direction, you would really be helping me out.&lt;br /&gt;
&lt;br /&gt;
Thanks guys!&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/dotnet/390938/390938/need-tips-for-optimizing-windows-form-applications/</guid>
      <pubDate>Wed, 13 May 2009 08:53:34 -0700</pubDate>
      <category>.NET General</category>
    </item>
    <item>
      <title>Text printing - alignment problem</title>
      <link>http://www.programmersheaven.com/mb/dotnet/390908/390908/text-printing---alignment-problem/</link>
      <description>Hai to all …&lt;br /&gt;
I am doing small project this project dot-matrix –text printing  method used to print bill , this is my coding  bill printing not problem but &lt;br /&gt;
Bill output not correct align format  how to set fixed point poss ion &lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
       PrintLine(1, Space(1) &amp;amp; "BillNo" &amp;amp; _&lt;br /&gt;
                Space(1) &amp;amp; " AdmissionFees" &amp;amp; _&lt;br /&gt;
                Space(2) &amp;amp; " StudentName" &amp;amp; _&lt;br /&gt;
                Space(3) &amp;amp; "std" &amp;amp; _&lt;br /&gt;
                Space(3) &amp;amp; " Group")&lt;br /&gt;
                PrintLine(1, Space(1) &amp;amp; "=================================================
==================================================
===============================================")&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
                Dim b1, b2, b3, b4, b5, b6, b7, b8 As Object&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
                Do While dr.Read()&lt;br /&gt;
&lt;br /&gt;
                    If (dr("Admn_Fees") = 0) Then&lt;br /&gt;
 b1 =Space(7)&amp;amp;Microsoft.VisualBasic.Left(Format(("Admn
_Fees"),"0.00"), 10)&lt;br /&gt;
                    Else&lt;br /&gt;
&lt;br /&gt;
                        b1 = Space(5) &amp;amp; Microsoft.VisualBasic.Left(Format(dr("Admn_Fees"), "##,##,###.00"), 10)&lt;br /&gt;
                    End If&lt;br /&gt;
&lt;br /&gt;
                    PrintLine(1, Space(1) &amp;amp; Microsoft.VisualBasic.Right(dr("Bill_No"), 6) &amp;amp; _&lt;br /&gt;
 Space(0) &amp;amp; b1 &amp;amp; _&lt;br /&gt;
Space(4) &amp;amp; Microsoft.VisualBasic.Right(dr("Stu_Name"), 15) &amp;amp; _&lt;br /&gt;
 Space(6) &amp;amp; Microsoft.VisualBasic.Right(dr("Standard"), 5) &amp;amp; _&lt;br /&gt;
 Space(5) &amp;amp; Microsoft.VisualBasic.Right(dr("Group_Type"), 10))&lt;br /&gt;
                Loop&lt;br /&gt;
&lt;br /&gt;
                PrintLine(1, Space(1) &amp;amp; "----------------------------------------------------------------------------------------------------------------------------------------------")&lt;br /&gt;
&lt;br /&gt;
OUT PUT  &lt;br /&gt;
-------------&lt;br /&gt;
Billno     Admn_Fees   Student Name  Standard        Group&lt;br /&gt;
-------------------------------------------------------------&lt;br /&gt;
1000       2546.00     jon kalan   XI                  Group1&lt;br /&gt;
1001       25 .00     kalan haro      XI            Group3&lt;br /&gt;
1000       546.00      jon kalan    XI                  Group1&lt;br /&gt;
1003       2546.00      kalan            X          Group1&lt;br /&gt;
100       546.00       rahul kalan       XI         Group2&lt;br /&gt;
1000       2546 .00     jon kalan      I     Group1&lt;br /&gt;
1000       46.00       peterkalan      XI           Group54&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/dotnet/390908/390908/text-printing---alignment-problem/</guid>
      <pubDate>Tue, 12 May 2009 18:52:00 -0700</pubDate>
      <category>.NET General</category>
    </item>
    <item>
      <title>Encrypt (AES) in Javascript and decrypt in .NET</title>
      <link>http://www.programmersheaven.com/mb/dotnet/390794/390794/encrypt-aes-in-javascript-and-decrypt-in-net/</link>
      <description>Hi All,&lt;br /&gt;
With the help of following link,&lt;br /&gt;
&lt;a href="http://www.hanewin.net/encrypt/aes/aes.htm"&gt;http://www.hanewin.net/encrypt/aes/aes.htm&lt;/a&gt;&lt;br /&gt;
I encrypted(AES) data with Javascript . I want to decrypt this in c#. While decrypting in c3 I am getting error "length of the data to be decrypt is not valid" Can any one provide some example?  &lt;br /&gt;
Thanks for your help...&lt;br /&gt;
Code:&lt;br /&gt;
&lt;br /&gt;
For encryption in Javascript I am using following code,&lt;br /&gt;
&lt;br /&gt;
var&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
randomnumber="91860F52E5C3A09BA3B827F28070E08D";&lt;br /&gt;
var encByteData = byteArrayToHex(rijndaelEncrypt(strFileContent, hex2s(randomnumber), "CBC"));&lt;br /&gt;
&lt;br /&gt;
definition for the rijndaelEncrypt() can be found in env-test.js of following link,&lt;br /&gt;
&lt;a href="http://www.hanewin.net/encrypt/aes/aes.htm"&gt;http://www.hanewin.net/encrypt/aes/aes.htm&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
For the decryption in c# I am using following code,&lt;br /&gt;
&lt;br /&gt;
Calling function,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
DecryptData(byteArraySignData, "91860F52E5C3A09BA3B827F28070E08D",&lt;br /&gt;
&lt;br /&gt;
ref byteArrayDecryptedData);&lt;br /&gt;
--------------------------------------------------------------- &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
public static bool EncryptData(byte[] clearData, string Password, ref byte[] byteArrayEncryptedData) &lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
PasswordDeriveBytes pdb = new PasswordDeriveBytes(Password, &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
new byte[] {0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, &lt;br /&gt;
&lt;br /&gt;
0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76});&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
EncryptData(clearData, pdb.GetBytes(32), pdb.GetBytes(16),&lt;br /&gt;
&lt;br /&gt;
ref byteArrayEncryptedData); &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
return true; &lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
-----------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
static&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
bool DecryptData(byte[] byteArrayEncryptedData, byte[] Key, byte[] IV, ref byte[] byteArrayDecryptKey) &lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
bool bRetVal = false; &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// Check arguments.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
if (byteArrayEncryptedData == null || byteArrayEncryptedData.Length &amp;lt;= 0) &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
throw new ArgumentNullException("ByteArray"); &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if (Key == null || Key.Length &amp;lt;= 0) &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
throw new ArgumentNullException("Key"); &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if (IV == null || IV.Length &amp;lt;= 0) &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
throw new ArgumentNullException("IV"); &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
try&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
MemoryStream ms = new MemoryStream();&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Rijndael alg = Rijndael.Create(); &lt;br /&gt;
&lt;br /&gt;
alg.KeySize = 128;&lt;br /&gt;
&lt;br /&gt;
alg.Mode =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CipherMode.CBC; &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
alg.BlockSize = 128;&lt;br /&gt;
&lt;br /&gt;
alg.Key = Key;&lt;br /&gt;
&lt;br /&gt;
alg.IV = IV;&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
CryptoStream cs = new CryptoStream(ms, &lt;br /&gt;
&lt;br /&gt;
alg.CreateDecryptor(),&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CryptoStreamMode.Write); &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// Write the data and make it do the decryption &lt;br /&gt;
&lt;br /&gt;
cs.Write(byteArrayEncryptedData, 0, byteArrayEncryptedData.Length);&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
// Close the crypto stream (or do FlushFinalBlock). &lt;br /&gt;
&lt;br /&gt;
cs.Close();&lt;br /&gt;
&lt;br /&gt;
byteArrayDecryptKey = ms.ToArray();&lt;br /&gt;
&lt;br /&gt;
bRetVal =&lt;br /&gt;
&lt;br /&gt;
true; &lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
catch (Exception ex) &lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
return bRetVal; &lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Narasimha&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/dotnet/390794/390794/encrypt-aes-in-javascript-and-decrypt-in-net/</guid>
      <pubDate>Mon, 11 May 2009 04:52:16 -0700</pubDate>
      <category>.NET General</category>
    </item>
    <item>
      <title>Downloading file from web page with authentification?</title>
      <link>http://www.programmersheaven.com/mb/dotnet/390730/390730/downloading-file-from-web-page-with-authentification/</link>
      <description>I want to download a file from website with authentification system.&lt;br /&gt;
Ok, maybe ill do some explanation. First of all, i open the site using webbrowser control. Then i logon, using following code:&lt;br /&gt;
&lt;br /&gt;
WebBrowser1.Document.DomDocument.All("uid").Value = "User"&lt;br /&gt;
WebBrowser1.Document.DomDocument.All("pwd").Value = "Password"&lt;br /&gt;
ButtonClick(("login"), WebBrowser1) //ButtonClick is predefined function&lt;br /&gt;
&lt;br /&gt;
Everything is ok, webbrowser loads the page and i see that i am logged in. Then i open another URL in same site. Still loged in. Get its source in textbox with:&lt;br /&gt;
&lt;br /&gt;
Src.Text = WebBrowser1.DocumentText.ToString&lt;br /&gt;
&lt;br /&gt;
Then with some InStr's i get URL to file which looks like http://site/download.php?id=ee290450a74a864425f54df5430298177b061202&amp;amp;f=[
some filename]. id is allways a different string. Then i try to download it with many functions from web like:&lt;br /&gt;
&lt;br /&gt;
Public Sub DownFile(ByVal sFile As String, ByVal sRemoteUrl As String)&lt;br /&gt;
Dim wr As HttpWebRequest&lt;br /&gt;
Dim ws As HttpWebResponse&lt;br /&gt;
Dim str As Stream&lt;br /&gt;
Dim inBuf(1000000) As Byte&lt;br /&gt;
Dim bytesToRead As Integer = CInt(inBuf.Length)&lt;br /&gt;
Dim bytesRead As Integer = 0&lt;br /&gt;
wr = CType(WebRequest.Create(sRemoteUrl), HttpWebRequest)&lt;br /&gt;
ws = CType(wr.GetResponse(), HttpWebResponse)&lt;br /&gt;
str = ws.GetResponseStream()&lt;br /&gt;
While bytesToRead &amp;gt; 0&lt;br /&gt;
Dim n As Integer = str.Read(inBuf, bytesRead, bytesToRead)&lt;br /&gt;
If n = 0 Then&lt;br /&gt;
Exit While&lt;br /&gt;
End If&lt;br /&gt;
bytesRead += n&lt;br /&gt;
bytesToRead -= n&lt;br /&gt;
End While&lt;br /&gt;
Dim fstr As New FileStream(sFile, FileMode.OpenOrCreate, FileAccess.Write)&lt;br /&gt;
fstr.Write(inBuf, 0, bytesRead)&lt;br /&gt;
str.Close()&lt;br /&gt;
fstr.Close()&lt;br /&gt;
End Sub&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Public Sub GetPackage(ByVal sFile As String, ByVal destination As String, ByVal sRemoteUrl As String)&lt;br /&gt;
Dim wc As New Net.WebClient()&lt;br /&gt;
Try&lt;br /&gt;
wc.DownloadFile(sRemoteUrl + sFile, destination + "\\" + sFile)&lt;br /&gt;
Catch&lt;br /&gt;
MsgBox("Unable to download file " + sRemoteUrl + sFile)&lt;br /&gt;
End Try&lt;br /&gt;
End Sub&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I get a file, but it actually is HTML page that says that i cant download, because i am not logged in (same as i would get if i try to open that link in any browser when not logged in). Looks like it has something to do with cookies, but i'm not sure about that. Strange, but in vb6 any function successfully downloads a file, i never saw such a problem there.</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/dotnet/390730/390730/downloading-file-from-web-page-with-authentification/</guid>
      <pubDate>Sat, 09 May 2009 16:07:15 -0700</pubDate>
      <category>.NET General</category>
    </item>
    <item>
      <title>multyply record,data reader,stored procedured,delivered table</title>
      <link>http://www.programmersheaven.com/mb/dotnet/390597/390597/multyply-recorddata-readerstored-procedureddelivered-table/</link>
      <description>what is the multyply recorset,data reader,store procedured,delivered table&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/dotnet/390597/390597/multyply-recorddata-readerstored-procedureddelivered-table/</guid>
      <pubDate>Thu, 07 May 2009 21:36:01 -0700</pubDate>
      <category>.NET General</category>
    </item>
    <item>
      <title>UnRecognized Picture Boxes</title>
      <link>http://www.programmersheaven.com/mb/dotnet/390194/390194/unrecognized-picture-boxes/</link>
      <description>&lt;span style="font-size: x-small;"&gt;&lt;span style="color: Green;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Hi I am trouble shooting a small issue in c#.net 2003 where i am creating picture box array dynamically and assigning the pictures dynamically.&lt;br /&gt;
&lt;br /&gt;
i am doing this in a panel with autoscroll enabled.&lt;br /&gt;
&lt;br /&gt;
so my picture boxes are having the names like picB[1],picB[2],..... &lt;br /&gt;
But if i want to use this names in another event i couldn't do as these are the names will be recognized dynamically by compiler but i am reffering these names when writing code.&lt;br /&gt;
&lt;br /&gt;
so finally i couldn't  run the application .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
can u give me the solution or better alternatives?&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/dotnet/390194/390194/unrecognized-picture-boxes/</guid>
      <pubDate>Fri, 01 May 2009 00:30:50 -0700</pubDate>
      <category>.NET General</category>
    </item>
    <item>
      <title>advantage and disadvantage of JScript .NET and  Visual C++</title>
      <link>http://www.programmersheaven.com/mb/dotnet/390192/390192/advantage-and-disadvantage-of-jscript-net-and--visual-c++/</link>
      <description>&lt;br /&gt;
hi every body&lt;br /&gt;
can you tell me advantage and disadvantage of JScript .NET and  Visual C++??&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/dotnet/390192/390192/advantage-and-disadvantage-of-jscript-net-and--visual-c++/</guid>
      <pubDate>Thu, 30 Apr 2009 23:14:43 -0700</pubDate>
      <category>.NET General</category>
    </item>
    <item>
      <title>advantage and disadvantage of JScript .NET and  Visual C++</title>
      <link>http://www.programmersheaven.com/mb/dotnet/390191/390191/advantage-and-disadvantage-of-jscript-net-and--visual-c++/</link>
      <description>&lt;br /&gt;
hi every body&lt;br /&gt;
can you tell me advantage and disadvantage of JScript .NET and  Visual C++??&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/dotnet/390191/390191/advantage-and-disadvantage-of-jscript-net-and--visual-c++/</guid>
      <pubDate>Thu, 30 Apr 2009 23:13:51 -0700</pubDate>
      <category>.NET General</category>
    </item>
    <item>
      <title>How do I caputer user's responses and send them to an "sql" database</title>
      <link>http://www.programmersheaven.com/mb/dotnet/390130/390130/how-do-i-caputer-users-responses-and-send-them-to-an-sql-database/</link>
      <description>I'm trying to write an exam with multiple choice and true/false questions. I use the repeater to populate the questions answers but having trouble storing the user's answer to my sql database.&lt;br /&gt;
&lt;br /&gt;
Any advice on the logic or what I should use, in term of coding, to do this would be greatly appreciated.&lt;br /&gt;
&lt;br /&gt;
I tried View State but got no luck. &lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/dotnet/390130/390130/how-do-i-caputer-users-responses-and-send-them-to-an-sql-database/</guid>
      <pubDate>Wed, 29 Apr 2009 20:01:42 -0700</pubDate>
      <category>.NET General</category>
    </item>
    <item>
      <title>Is P/Invoke InternetGetConnectedState cached?</title>
      <link>http://www.programmersheaven.com/mb/dotnet/390105/390105/is-pinvoke-internetgetconnectedstate-cached/</link>
      <description>Hello,&lt;br /&gt;
&lt;br /&gt;
I'm working with the compact framework and needed to use P/Invoke functionality for finding whether or not the mobile device is connected to the internet.  The connection status always seems to appear as if it is connected (through a LAN) even though the wireless is turned off and has no connection at all.  Do you know if the status is cached anywhere or what I'm doing wrong?&lt;br /&gt;
&lt;br /&gt;
Heres the code I have:&lt;br /&gt;
&lt;br /&gt;
        [DllImport("wininet.dll", CharSet = CharSet.Auto)]&lt;br /&gt;
        private extern static bool InternetGetConnectedState(ref InternetConnectionState lpdwFlags, int dwReserved);&lt;br /&gt;
&lt;br /&gt;
        [Flags]&lt;br /&gt;
        enum InternetConnectionState: int&lt;br /&gt;
        {&lt;br /&gt;
            INTERNET_CONNECTION_MODEM = 0x01,&lt;br /&gt;
            INTERNET_CONNECTION_LAN = 0x02,&lt;br /&gt;
            INTERNET_CONNECTION_PROXY = 0x04,&lt;br /&gt;
            INTERNET_CONNECTION_RAS_INSTALLED = 0x10,&lt;br /&gt;
            INTERNET_CONNECTION_OFFLINE = 0x20,&lt;br /&gt;
            INTERNET_CONNECTION_CONFIGURED = 0x40&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        InternetConnectionState flags = 0;&lt;br /&gt;
&lt;br /&gt;
        private void btnConnection_Click(object sender, EventArgs e)&lt;br /&gt;
        {&lt;br /&gt;
            bool isConnected = InternetGetConnectedState(ref flags, 0);&lt;br /&gt;
&lt;br /&gt;
            bool isConfigured = (flags &amp;amp; InternetConnectionState.INTERNET_CONNECTION_CONFIG
URED) != 0;&lt;br /&gt;
            bool isOffline = (flags &amp;amp; InternetConnectionState.INTERNET_CONNECTION_OFFLIN
E) != 0;&lt;br /&gt;
            bool isConnectedUsingModem = (flags &amp;amp; InternetConnectionState.INTERNET_CONNECTION_MODEM) != 0;&lt;br /&gt;
            bool isConnectedUsingLAN = (flags &amp;amp; InternetConnectionState.INTERNET_CONNECTION_LAN) != 0;&lt;br /&gt;
            bool isProxyUsed = (flags &amp;amp; InternetConnectionState.INTERNET_CONNECTION_PROXY) != 0;&lt;br /&gt;
&lt;br /&gt;
            listBox2.Items.Add(isConnected);&lt;br /&gt;
            listBox2.Items.Add(isConfigured);&lt;br /&gt;
            listBox2.Items.Add(isOffline);&lt;br /&gt;
            listBox2.Items.Add(isConnectedUsingModem);&lt;br /&gt;
            listBox2.Items.Add(isConnectedUsingLAN);&lt;br /&gt;
            listBox2.Items.Add(isProxyUsed);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
and the listbox2 returns:&lt;br /&gt;
&lt;br /&gt;
True&lt;br /&gt;
False&lt;br /&gt;
False&lt;br /&gt;
False&lt;br /&gt;
True&lt;br /&gt;
False&lt;br /&gt;
&lt;br /&gt;
Best Regards,&lt;br /&gt;
&lt;br /&gt;
McKenzie.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/dotnet/390105/390105/is-pinvoke-internetgetconnectedstate-cached/</guid>
      <pubDate>Wed, 29 Apr 2009 10:36:17 -0700</pubDate>
      <category>.NET General</category>
    </item>
    <item>
      <title>DataGridView refresh problem</title>
      <link>http://www.programmersheaven.com/mb/dotnet/390098/390098/datagridview-refresh-problem/</link>
      <description>Hi, I encountered a problem with refreshing my Datagridview from a MySQL database.&lt;br /&gt;
&lt;br /&gt;
Basically, my Datagridview is placed in a TabPage. This TabPage is toggled visually by a MenuStripItem. When the menu item is clicked, it will either open or close the TabPage. When it opens the TabPage, I have set an event handler to refresh the Datagridview with new data from the MySQL database.&lt;br /&gt;
&lt;br /&gt;
These are the 2 event handlers for the MenuStripItem.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;private delegate void Update_Delegate(DataTable input);
	
	private void db_list_update(DataTable input){
		//db_list.DataSource = null;
		db_list.EndEdit();
		db_list.Refresh();
		db_list.DataSource = input;
	}
	
	private void db_toggle(object sender, EventArgs e){
		if (db_shown){
			tab_control.TabPages.Remove(db_tab);
			num_tabs_shown--;
			check_tab_visibility();
			db_shown = false;
			//Hide_DB_List();
			db_list.Invoke(new Update_Delegate(this.db_list_update), new object[] {db_test.mysql_query(db_query)});
		}
		else if (!db_shown){
			tab_control.Visible = true;
			tab_control.TabPages.Insert(0,db_tab);
			tab_control.SelectedTab = db_tab;
			num_tabs_shown++;
			check_tab_visibility();		
			Show_DB_List();
			db_list.Invoke(new Update_Delegate(this.db_list_update), new object[] {db_test.mysql_query(db_query)});
			db_shown = true;
		}
		db_test = null;
		
	}	&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
The problem is that the data in the DataGridView refuses to be refreshed after the second click. That is, when I open the DataGridView, it loads from the database. Then I close it and it refreshes itself. When I open it again, it does not refresh thereafter.&lt;br /&gt;
&lt;br /&gt;
Also, I have put in a HitTest to track the DataSource values of the DataGridView. The DataSource values are being updated but the DataGridView does not reflect the updated values from the DataSource despite my attempts to refresh it and reload the DataSource.&lt;br /&gt;
&lt;br /&gt;
Any help will be much appreciated :)&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/dotnet/390098/390098/datagridview-refresh-problem/</guid>
      <pubDate>Wed, 29 Apr 2009 08:38:56 -0700</pubDate>
      <category>.NET General</category>
    </item>
    <item>
      <title>Windows Hooks in .NET</title>
      <link>http://www.programmersheaven.com/mb/dotnet/389924/389924/windows-hooks-in-net/</link>
      <description>What are the limitations of windows hooks in .net? And up to what extent can .net control OS events if windows hooks are applied? And finally, what are the controls that .net can use to control those OS events? Please help.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/dotnet/389924/389924/windows-hooks-in-net/</guid>
      <pubDate>Mon, 27 Apr 2009 06:10:08 -0700</pubDate>
      <category>.NET General</category>
    </item>
  </channel>
</rss>