Random Tech Findings
Atom FeedAtom Feed
Monday, April 19, 2004
In particular, non-integer results should not normally be compared for equality; and non-integer computed results generally need rounding. (From the site mentioned above.)
Tuesday, April 06, 2004
Trial and Error Stuff
1. Have you ever used any of the IndexFromPoint function in ListBoxes, TreeViews and such? Does not seem to give the right answer always. Anyway the reason is the way to get the right index because of difference between screen and client coordinates is something like
Point pt = listEx2.PointToClient(new Point(e.X, e.Y));
int i=listEx2.IndexFromPoint(pt.X , pt.Y);
You can of course combine this in one line. Just for clarity.
2. Have you ever used COM Interop and gotten the error "Referenced assembly 'Interop.xxxxxx' does not have a strong name". The easiest way to overcome is to follow these steps.
1. Open the properties of the Project
2. In Common Properties, go to General
3. In the Wrapper Assembly Key File field, add the key file.
In order to know what is key and how to generate a key file see the previous posts.
Thursday, April 01, 2004
I think quite a lot of developers would have come across the problem of somehow cancelling the refresh action of the user. Normally on a posted page, a box with re-posting message shows up which allows you to , well, re-post or cancel. From my searching till now, there is no way you can stop the refresh. If you think you do not have the ID10t user problem, below is the suggestion that I found at various places. User onBeforeUnload event in the page.
<BODY onBeforeUnload="event.returnValue = 'Press Cancel to not Refresh.';">
But the problem is this event is called in the following circumstances.
1 Close the current browser window.
2 Click the Back, Forward, Refresh, or Home button.
3 Click on an anchor that refers the browser to another Web page.
4 Invoke the anchor click method.
5 Invoke the document write method.
6 Invoke the document open method.
7 Invoke the document close method.
8 Invoke the window close method.
9 Invoke the window open method, providing the possible value _self for the window name.
10 Invoke the window navigate or NavigateAndFind method.
11 Invoke the location replace method.
12 Invoke the location reload method.
13 Specify a new value for the location href property.
14 Navigate to another location by entering a new address or selecting a Favorite.
Of course one can do solution on the server to handle reposting by session variable and cookies manipulation depending on the situation. But seems like no simple solution.
In order to faciliate my work I had to create a Custom Windows Control and since I was trying to use it in project which had a strong name, this particulat control also needed to be strong named. So, following are the steps to do strong-naming the assembly.
1. First thing one needs to do to create a strong name assembly is to generate strong name keys for the assembly. Microsoft Visual Studio ( not .Net Framework) ships with a Strong naming tool (sn.exe) which you can find at %Program Files&\Microsoft Visual Studio .NET 2003\SDK\v1.1\Bin. Usage of the tool is like
snk=strong name key
Copy this file to the folder in the assembly which you need to strong name.
2. In the AssemblyInfo.cs file of the assembly you are trying to strong-name you will need to add the location of the keys like this
if the snk file lies in the folder above the source code folder and assembly file(dll) in the bin/debug.
3. In order to add the assembly to the GAC, use gacutil \i
Also read the previous post for pitfalls.
That is it, your asembly is strong-named and in the GAC!!