Tuesday, 20 December 2011
DropDownList has a SelectedValue which is invalid because it does not exist in the list of items
This can be fixed by clearing the selection and selected item of the drop down list before rebinding to a new datasource.
eg:
Friday, 16 December 2011
How to fire a non static code behind method from a javascript postback
This in conjunction with an UpdatePanel produces a method that can be called from javascript that does not refresh the page.
If an update panel is used, then its a good idea to use the Id for a control inside the update panel so its marked for asyncrous postback, then differentiate between methods using the event argmument
to post back to the server using a javascript function the following code can be used:
We can then set the code behind to inspect the Request.Form collection for any postback information.
This can be very powerful as potentially any code behind method can be called!
Wednesday, 14 December 2011
How to Show a jQuery Dialog from Code behind
aspx:
js in aspx:
Note: dlg.parent().appendTo(jQuery('form:first')) is required so the dialog can be the same state after postback
code behind:
Basically we are adding a script to page load to create the dialog by calling our javascript method.
Thursday, 8 December 2011
Application pool crashes with The identity of application pool, 'your app pool' is invalid
The application pool was actually running as a local user on the web server. In order for a user account to be used in an application pool it needs to be added to a local security group (I have never done this before so its certainly not always the case).
To get it working be sure that the account is a member of the local security group "IIS_WPG", for membership in the IIS_WPG group is needed to run the w3wp.exe worker process.
Friday, 2 December 2011
Showing a modal dialog while page is updating
Markup:
Javascript
Tuesday, 15 November 2011
Custom Resource File Considerations
2) Custom resource file is added after
Temporary asp.net files needs to be cleared
Monday, 7 November 2011
jQuery document.ready and update panels
In this case, another handler needs to be added so call the ready event at the end of every request.
The code below can be used to achieve this.
Thursday, 3 November 2011
Visual Studio Installer Project - Unable to build project output group 'Content Files from (Your website) (Active)'
Unable to build project output group 'Content Files from SOMEWEB (Active)'
And you'll have no idea why this happened, no descriptive error message, nada.
Turns out that this is the MSI builder's way of telling you that it can't physically find a Content File that is referenced in the Project (CSPROJ, or VBPROJ).
The trick is turn on 'Show All Files' and open every folder until you find one with the Yellow Yield Icon. This subtle tip is telling you that this file doesn't exist on disk, but it does exist in the Project. Right-Click on it and Exclude From Project.
When the MSI Installer builder can't find a file marked as Content it fails
Friday, 14 October 2011
Referencing Control libraries in Web.Config - not each page
To fix this issue I removed all references to the report viewer assembly that were contained in aspx pages, and added an entry to the reportviewer dll to the web config so it can be accessed via the specified tag.
eg:
extracts from the web.config, here you can see the referenced ReportViewer assemblies, and where the controls are.
You can then use the report viewer controls in an asp page with the following:
Saturday, 10 September 2011
Thursday, 8 September 2011
Using a Form tag or Panel to handle Submit on pressing Enter
There is a property on both the Form Tag, and an ASP Panel called 'DefaultButton' simply specifying the ID of the button in this property will fire the button click when the enter key is pressed whilst in that container.
Tuesday, 6 September 2011
Show label on ReportViewer report based on whether its the last page
To Show on Last page should be:
To Show on All pages but the last should be:
Show Page X of Y in ReportViewer Footer
Thursday, 18 August 2011
Dynamically create and show a jQuery UI dialog from Javascript
Tuesday, 16 August 2011
Monday, 15 August 2011
How to check whether a column exists in a particular database (SQL)
Monday, 8 August 2011
Add "Open with Notepad" to the Context Menu for All Files
Right-click on “shell” and choose to create a new key, calling it “Open with Notepad”. Create a new key below that one called “command”. Double-click on the (Default) value in the right-hand pane and enter in the following:
The change should take effect immediately… just right-click on any file and you’ll see the next menu entry.
Monday, 1 August 2011
TargetInvocationException - Object Does Not Match Target Type
This is because the gridview looks at the type of the first item in the grid and expects all other items to be the same type.
There is an easy work around for this which can be achieved by converting all of the columns to template fields so the properties are evaluated separately.
Tuesday, 26 July 2011
Web Application not loading debug symbol information
If anyone knows a solution to this to fix it properly please comment!
Friday, 22 July 2011
Wednesday, 20 July 2011
Tuesday, 19 July 2011
How to name the output filename of an msi installer project
Tuesday, 12 July 2011
GridView - Fire selected index changed on row click
Wednesday, 15 June 2011
Move window hidden from view.
Friday, 3 June 2011
DATEPART considerations
My sql server is set up to use Sunday as the first day of the week which res returning the wrong day for my DATEPART queries.
To set the first day of the week to Monday you can use:
To set the first day of the week to Sunday you can use:
To check what DATEFIRST is currently set to you can use:
Thursday, 2 June 2011
Chuck Norris Programmer Jokes
2. All arrays Chuck Norris declares are of infinite size, because Chuck Norris knows no bounds.
3. Chuck Norris doesn’t have disk latency because the hard drive knows to hurry the hell up.
4. Chuck Norris writes code that optimizes itself.
5. Chuck Norris can’t test for equality because he has no equal.
6. Chuck Norris doesn’t need garbage collection because he doesn’t call .Dispose(), he calls .DropKick().
7. Chuck Norris’s first program was kill -9.
8. Chuck Norris burst the dot com bubble.
9. All browsers support the hex definitions #chuck and #norris for the colors black and blue.
10. MySpace actually isn’t your space, it’s Chuck’s (he just lets you use it).
11. Chuck Norris can write infinite recursion functions…and have them return.
12. Chuck Norris can solve the Towers of Hanoi in one move.
13. The only pattern Chuck Norris knows is God Object.
14. Chuck Norris finished World of Warcraft.
15. Project managers never ask Chuck Norris for estimations…ever.
16. Chuck Norris doesn’t use web standards as the web will conform to him.
17. “It works on my machine” always holds true for Chuck Norris.
18. Whiteboards are white because Chuck Norris scared them that way.
19. Chuck Norris doesn’t do Burn Down charts, he does Smack Down charts.
20. Chuck Norris can delete the Recycling Bin.
21. Chuck Norris’s beard can type 140 wpm.
22. Chuck Norris can unit test entire applications with a single assert.
23. Chuck Norris doesn’t bug hunt as that signifies a probability of failure, he goes bug killing.
24. Chuck Norris’s keyboard doesn’t have a Ctrl key because nothing controls Chuck Norris.
25. When Chuck Norris is web surfing websites get the message “Warning: Internet Explorer has deemed this user to be malicious or dangerous. Proceed?”.
26. Chuck Norris CAN divide by 0.
27. Chuck Norris can overflow your stack just by looking at it.
28. Chuck Norris doesn’t need sudo, he just types “Chuck Norris” before his commands.
29. Chuck Norris can instantiate an abstract class.
30. The class object inherits from Chuck Norris
31. Chuck Norris can write multi-threaded applications with a single thread
32. There is no Esc key on Chuck Norris’ keyboard, because no one escapes Chuck Norris.
33. Visual SourceSafe actually works for Chuck Norris.
Thursday, 26 May 2011
Application Pool stops when started
A failure was encountered while launching the process serving application pool 'WAP'. The application pool has been disabled.
or
The identity of application pool 'WAP' is invalid, so the World Wide Web Publishing Service can not create a worker process to serve the application pool. Therefore, the application pool has been disabled.
then you may need to grant some permissions to the account you are using.
Here is a list of things to try
- Add user to IIS_WPG group
- Add user to local admin group and adding the "Act as part of the os" right.
- run aspnet_regiis -ga "domain\user" on the user account you are using
- Check password
- Grant the Log on as service role in local / group policy
Friday, 20 May 2011
Loading a Drop down List in Row Created
I found this problem is caused if you call databind on the drop down list from within the Row Created event of the grid view. It looks as though the drop down list is automatically calling DataBind when the gridview calls the Row Databound event.
Removing the call to databind from the row created event fixed the issue.
eg:
Thursday, 19 May 2011
Style textboxes with css
After about 2 hours of searching I found out it was being overridden because a skin file was changing the css class.
Long story short, If you want to apply custom classes to the same type of control, don't use a skin file. I removed the skin file, never to be used again, and replaced with the following css:
Monday, 9 May 2011
Ajax Controls Toolkit: ModalPopup extender with UpdatePanel
Straightforward combination of ModalPopup extender with UpdatedPanel, containing data-bound controls will work pretty much out of the box with few caveats to consider, mainly with OK/Cancel buttons:
1. Place both OK and Cancel buttons outside the Update panel, otherwise when leaving the page you may get a JScript error "Microsoft JScript runtime error: Sys.InvalidOperationException: Handler was not added through the Sys.UI.DomEvent.addHandler method.".
When client-side objects of the Update Panel are being disposed, the cleanup script tries to remove all registered handlers. If buttons are inside of the UpdatePanel, their handlers are still registered as for all child controls by default, but weren’t re-attached during the callback. Obviously, you can spend time and do it properly, but simply re-placing the buttons will do the job while keeping layout appearance unaltered.
2. Now our buttons are outside of the UpdatePanel and we need to make it aware of relevant Click events. So we will have to add trigger to serve the OK operation:
Same will do for a Cancel operation but it will work just fine (and with less code) by setting ModalPopup.CancelControlID property.
3. In the case of the Cancel button a ModalPopup “window” will be closed automatically but if you want it to be closed after the OK click, you should do it manually by calling the mpMyPopup.Hide() method.
4. If databound controls were changed on a callback then don't forget to call the UpdatePanel.Update() method to refresh the data.
5. Another important point to mention is that you have multiple popup control extenders on a page, including user controls that contain the extenders the Popup Control ID, and Cancel Control ID etc must be unique.
Most but not all information found at:
http://lazyloading.blogspot.com/2009/03/ajax-controls-toolkit-modalpopup.html
Friday, 6 May 2011
Use Fiddler with Blackberry simulator
This is as simple as opening the config file at 'C:\Program Files (x86)\Research In Motion\BlackBerry Email and MDS Services Simulators 4.1.2\MDS\config\rimpublic.property' for a default installation.
Once the config file is open you need to look for the section titled [HTTP HANDLER] and add the following three lines
The proxy port in this example is 8888 which is the default port used by Fiddler.
The complete HTTP handler section should look similar to the following:
Blackberry Simulator - Insufficient Network Coverage
I have been doing a bit of mobile web development and had a problem when testing the site in a Blackberry simulator.
The message displayed on the black berry when doing a postback reads 'There is insufficient network coverage to process your request. Please try again later.'
The simulator has full signal and 3g etc is enabled. After doing a bit of research it appears the message is displayed becuase the page is trying to submit the form with a 'POST' action which causes this problem on both the Blackberry simulator and actual Blackberry devices. To get around this issue you can specify the form method to use 'GET' which resolves the problem.
eg:
Wednesday, 4 May 2011
jQuery Mobile Document Ready not firing
Tuesday, 19 April 2011
Bring window to front with jQuery and Javascript
Wednesday, 13 April 2011
Tuesday, 12 April 2011
Disable a button with jQuery and still do postback
The one pitfall that comes with disabling a submit button on the client side is that it will cancel the browser’s submit, and thus the postback. Setting the UseSubmitBehavior property to false tells .NET to inject the necessary client script to fire the postback anyway, instead of relying on the browser’s form submission behavior.
for example:
(aspx)
(javascript)
Saturday, 9 April 2011
Thursday, 7 April 2011
ReportViewer - object datasource, nested objects return #Error
This has been fixed in Service Pack 1 for Visual studio 2010 although you must ensure all classes referenced in the report have the [Serializable] attribute for EVERY property that is a user type, they must also be a public class, and also a public constructor with no parameters. Without these you will still get the error. When a class is serialized it cannot be unserialized without the Default constructor as the class is instanitated with that constructor, then the properties set once the class is created. It also seems that if the entire class cannot be serialized the report will not show it.
To use a nested property on the report the following expression should be entered:
=Fields!Supplier.Value.SupplierLocation.Address1
This expression adds a field to the report that is three properties deep from the object the report is bound to.
The report datasource binds to an Order class, the order class contains a Supplier property, and the Supplier class contains a Supplier Location Property.
The Order, Supplier and Supplier Location class must use the [Serializable] attribute, and also any other property of any of the classes referenced. eg, Just make every class in your project Serializable and you should be good to go. ( technically you dont need every class but this was easier than checking every property of each nested object to make sure its serializable.
eg:
UPDATE: 16/06/2011
I tried to do another report with a different object and the #Error problem returned. However, After going though every single property that is a class in my datasource, and adding the serializable attribute to the report started working again. So, Every property of the object needs to be serializable, otherwise it seems the whole object cannot be serialized.
Checklist:
- ALL classes are serializable (every user type in the class must be serializable, and any user type in a property of a usertype must be serialzable)
- ALL classes have a public parameterless constructor
- ALL classes used in the report must have the public modifier
- If any property of the datasource, or any property of a property cannot be serialized then your will get the #Error. Just make sure everything is serializable
- Make sure there will be no infinite recursion issues - eg, class A has a property of class B, and class B has a property of class A. Use XMLIgnore / ScriptIgnore attributes
UPDATE: 22/06/2011
Sample project can now be downloaded from
Sample Web Project
MIME Types
Type/sub-type | Extension |
---|---|
application/envoy | evy |
application/fractals | fif |
application/futuresplash | spl |
application/hta | hta |
application/internet-property-stream | acx |
application/mac-binhex40 | hqx |
application/msword | doc |
application/msword | dot |
application/octet-stream | * |
application/octet-stream | bin |
application/octet-stream | class |
application/octet-stream | dms |
application/octet-stream | exe |
application/octet-stream | lha |
application/octet-stream | lzh |
application/oda | oda |
application/olescript | axs |
application/pdf | |
application/pics-rules | prf |
application/pkcs10 | p10 |
application/pkix-crl | crl |
application/postscript | ai |
application/postscript | eps |
application/postscript | ps |
application/rtf | rtf |
application/set-payment-initiation | setpay |
application/set-registration-initiation | setreg |
application/vnd.ms-excel | xla |
application/vnd.ms-excel | xlc |
application/vnd.ms-excel | xlm |
application/vnd.ms-excel | xls |
application/vnd.ms-excel | xlt |
application/vnd.ms-excel | xlw |
application/vnd.ms-outlook | msg |
application/vnd.ms-pkicertstore | sst |
application/vnd.ms-pkiseccat | cat |
application/vnd.ms-pkistl | stl |
application/vnd.ms-powerpoint | pot |
application/vnd.ms-powerpoint | pps |
application/vnd.ms-powerpoint | ppt |
application/vnd.ms-project | mpp |
application/vnd.ms-works | wcm |
application/vnd.ms-works | wdb |
application/vnd.ms-works | wks |
application/vnd.ms-works | wps |
application/vnd.openxmlformats-officedocument.presentationml.presentation | pptx |
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet | xlsx |
application/vnd.openxmlformats-officedocument.wordprocessingml.document | docx |
application/winhlp | hlp |
application/x-bcpio | bcpio |
application/x-cdf | cdf |
application/x-compress | z |
application/x-compressed | tgz |
application/x-cpio | cpio |
application/x-csh | csh |
application/x-director | dcr |
application/x-director | dir |
application/x-director | dxr |
application/x-dvi | dvi |
application/x-gtar | gtar |
application/x-gzip | gz |
application/x-hdf | hdf |
application/x-internet-signup | ins |
application/x-internet-signup | isp |
application/x-iphone | iii |
application/x-javascript | js |
application/x-latex | latex |
application/x-msaccess | mdb |
application/x-mscardfile | crd |
application/x-msclip | clp |
application/x-msdownload | dll |
application/x-msmediaview | m13 |
application/x-msmediaview | m14 |
application/x-msmediaview | mvb |
application/x-msmetafile | wmf |
application/x-msmoney | mny |
application/x-mspublisher | pub |
application/x-msschedule | scd |
application/x-msterminal | trm |
application/x-mswrite | wri |
application/x-netcdf | cdf |
application/x-netcdf | nc |
application/x-perfmon | pma |
application/x-perfmon | pmc |
application/x-perfmon | pml |
application/x-perfmon | pmr |
application/x-perfmon | pmw |
application/x-pkcs12 | p12 |
application/x-pkcs12 | pfx |
application/x-pkcs7-certificates | p7b |
application/x-pkcs7-certificates | spc |
application/x-pkcs7-certreqresp | p7r |
application/x-pkcs7-mime | p7c |
application/x-pkcs7-mime | p7m |
application/x-pkcs7-signature | p7s |
application/x-sh | sh |
application/x-shar | shar |
application/x-shockwave-flash | swf |
application/x-stuffit | sit |
application/x-sv4cpio | sv4cpio |
application/x-sv4crc | sv4crc |
application/x-tar | tar |
application/x-tcl | tcl |
application/x-tex | tex |
application/x-texinfo | texi |
application/x-texinfo | texinfo |
application/x-troff | roff |
application/x-troff | t |
application/x-troff | tr |
application/x-troff-man | man |
application/x-troff-me | me |
application/x-troff-ms | ms |
application/x-ustar | ustar |
application/x-wais-source | src |
application/x-x509-ca-cert | cer |
application/x-x509-ca-cert | crt |
application/x-x509-ca-cert | der |
application/ynd.ms-pkipko | pko |
application/zip | zip |
audio/basic | au |
audio/basic | snd |
audio/mid | mid |
audio/mid | rmi |
audio/mpeg | mp3 |
audio/x-aiff | aif |
audio/x-aiff | aifc |
audio/x-aiff | aiff |
audio/x-mpegurl | m3u |
audio/x-pn-realaudio | ra |
audio/x-pn-realaudio | ram |
audio/x-wav | wav |
image/bmp | bmp |
image/cis-cod | cod |
image/gif | gif |
image/ief | ief |
image/jpeg | jpe |
image/jpeg | jpeg |
image/jpeg | jpg |
image/pipeg | jfif |
image/png | png |
image/svg+xml | svg |
image/tiff | tif |
image/tiff | tiff |
image/x-cmu-raster | ras |
image/x-cmx | cmx |
image/x-icon | ico |
image/x-portable-anymap | pnm |
image/x-portable-bitmap | pbm |
image/x-portable-graymap | pgm |
image/x-portable-pixmap | ppm |
image/x-rgb | rgb |
image/x-xbitmap | xbm |
image/x-xpixmap | xpm |
image/x-xwindowdump | xwd |
message/rfc822 | mht |
message/rfc822 | mhtml |
message/rfc822 | nws |
text/css | css |
text/h323 | 323 |
text/html | htm |
text/html | html |
text/html | stm |
text/iuls | uls |
text/plain | bas |
text/plain | c |
text/plain | h |
text/plain | txt |
text/richtext | rtx |
text/scriptlet | sct |
text/tab-separated-values | tsv |
text/webviewhtml | htt |
text/x-component | htc |
text/x-setext | etx |
text/x-vcard | vcf |
video/mpeg | mp2 |
video/mpeg | mpa |
video/mpeg | mpe |
video/mpeg | mpeg |
video/mpeg | mpg |
video/mpeg | mpv2 |
video/quicktime | mov |
video/quicktime | qt |
video/x-la-asf | lsf |
video/x-la-asf | lsx |
video/x-ms-asf | asf |
video/x-ms-asf | asr |
video/x-ms-asf | asx |
video/x-msvideo | avi |
video/x-sgi-movie | movie |
x-world/x-vrml | flr |
x-world/x-vrml | vrml |
x-world/x-vrml | wrl |
x-world/x-vrml | wrz |
x-world/x-vrml | xaf |
x-world/x-vrml | xof |
ReportViewer - Prints Extra blank pages or splits accross multiple pages
When you are editing the rdlc file in design mode, firstly click on an empty part of the BODY area of your design. Hit F4 to see the properties tab. Here, you will see a "Size" property. This can be expanded for the width and height. The width you see here represents the width that the body of your report requires as printable area. Even if you have white space all over, the page knows that it needs to keep it as a printable area. It reserves the space, in some sense. As for the height, the system generally knows that it can grow or shrink as necessary, unless you have specified otherwise within your controls therein. So the width is what will, usually, play the most important role.
Next, click on an empty area of the report (outside the header, body, and footer; basically the gray area around the design), then hit F4 to view the properties panel. Under the "Layout" category of the properties, you will see 3 different options: InteractiveSize, Margins, PageSize. Each of those Size attributes can be expanded to show the Width and Height. The Margins attribute can be expanded for the left/right/top/bottom.
Basically, the pdf export works out of the PageSize (though I generally try to keep Interactive and Page size equal). When the pdf file is rendered via the ReportViewer's built-in export function, the width and height of each "page" within the pdf will be determined by the width and height in the report's PageSize attribute (you could override this if you used your own custom code for the pdf rendering). As for the margins, they specify how much space MUST be left blank and unprintable between the printable area reserved for your report and the edge of the page.
In other words: Your report's Body's Width, Plus the Report's Left Margin, Plus the Report's Right Margin, MUST be smaller than or equal to the Report's PageSize's Width!
So...if your margins are too wide, or if your report's body is too wide, or if the PageSize's width is too narrow, the rendered result is forced to be broken down to multiple pages in order to fit!
For example: If my report's body has width 7.75", my Left margin is 0.5", my right margin is 0.5", and the width specified in the PageSize is 8.5", my report will always use 2 pages for each 1 page of data. The 7.75" width of the body, plus 0.5"+0.5" for the margins add up to 8.75", which is larger than the 8.5" available in my page. So the first 7.5" (or so) of each page of my report's body will be shown in the first page, and the rest will be split down to the next page. This will not be done inside the report viewer, as it allows for the report to grow beyond the page size by just adding a scrollbar, but it will be annoyingly noticeable in the pdf export. In order to make my example report fit in 1 page, I can either try and reduce the body of my report to 7.5" or less, or I can reduce the left and right margins by a total of 0.25" or more (for example, set them to 0.3" for a total reduction of 0.4"), or I can increase the PageSize to something larger than 8.75". Note: Acrobat Reader is pretty smart and knows about various paper sizes. Therefore, while arbitrary PageSizes will work, it is typically best to use real page sizes. As such, in my last example I would rather set the PageSize to have Width = 11" and Height = 8.5", which is a real letter-size in landscape! Adobe will typically understand this and print properly. Also Note: Some printers, especially older ones, have trouble printing with less than 0.3" margins. If you want to be nice to your users, you should best keep the margins large enough for those older printers ;)
Tuesday, 29 March 2011
Could not load file or assembly CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304
To begin with I downloaded the latest crystal reports 2008 runtime and installed on the server. This seemed to install version 12.0 assemblies. After a bit of searching on the net it seems that the version number of the assemblies changed to 13.0 in the Crystal reports for Visual Studio 2010 version. This means there is a seperate runtime to install if this is what the reports were built against.
The correct runtime can be downloaded from here:
SAP VS.net runtime distributions
Failed to open the connection. Database Vendor code 4060
It dawned on me that is may be due to an issue similar to the 'double hop' problem where ReportViewer looses its impersonation context. This was easy to resolve by changing the application pool identity to a user that has access to the datasources and databases. Sure enough everything started to play nicely after the application pool was changed to match the user the web application was impersonating.
If you are interested in the ReportViewer double hop problem then here is the link:
Report Viewer Impersonation Context
Friday, 25 March 2011
BlackBerry MDS Simulator does not launch
The BlackBerry MDS Simulator appears to have started successfully; however, the command prompt window disappears after a few seconds.
Cause
The following are possible causes:
An incorrect version of the Java® software development kit (SDK) or Java Development Kit (JDK) is installed on the computer, or the SDK or JDK is missing.
The path environment variable is not set correctly.
The Java_Home environment variable is pointing to the incorrect Java version.
There is interference with existing environment variables.
Resolution
Complete the following:
Verify that a supported version of the SDK or JDK is installed as follows:
Review the Add/Remove Programs to determine the current version installed.
Search Windows® Explorer for the Java installation directory (e.g., C:\Program Files\Java\jdk1.5.0_21).
If there is no Java SDK or JDK installed, install one.
If an incorrect version of Java SDK or JDK is installed, remove it and install the version that is supported by BlackBerry JDE. See here for a list of supported versions of Java for the the BlackBerry JDE.When the installation is complete, make sure that the Java directory is created and that the environment variable has been set correctly.
When the installation is complete, make sure that the Java directory is created and that the environment variable has been set correctly.
Check the path environment variable:
Right-click My Computer and then select Properties. On the Advanced tab, click Environment Variables.
Verify that the C:\Program Files\Java\jdk1.5.0_21 directory appears first in the path environment variable, as in the following example:
C:\Program Files\Java\jdk1.5.0_21;C:\Perl\bin\;C:\Oracle\Ora81\bin;C:\Program Files\Oracle\jre\1.1.7\bin;%SystemRoot%\system32;%SystemRoot%
Note: If there are multiple versions of Java installed by other applications, move the Java SDK path to the beginning of the list.
Check the “JAVA_HOME” environment variable.
Right-click My Computer and select Properties. On the Advanced tab, click Environment Variables.
Verify that the Java_Home variable is pointing to the correct version of Java. The BlackBerry JDE software does not require the Java_Home variable to be set. It can be removed as long as there are no conflicts with other applications running on your local computer.
Edit the \INSTALL_DIRECTORY\MDS\setBMDSEnv.bat file and remove the reference to %cd%\ from the following line:
@set BMDS_CLASSPATH=%BMDS_CLASSPATH%;"%cd%\%1"
The line should now read as follows:
@set BMDS_CLASSPATH=%BMDS_CLASSPATH%;"%1"
Save this change and restart the BlackBerry MDS Simulator.
Monday, 21 March 2011
How to open a window from a button in an update panel
How to create a Unique index based on two columns
Here is the SQL Query to add the constraint in SQL 2008.
If you are using SQL 2005 then you can achieve this by creating a view and adding a constraint to the view.
Friday, 18 March 2011
How to Add Virtual PC hard disk to Virtual Box
- Create a new Virtual Machine
- Set the details for the VM
- Set memory as normal
- Untick the Boot Hard disk Option
- Finish creating the machine
- Go into the Storage settings for the machine. Under the IDE Controller section click the add new Hard Disk Button
- Click choose existing disk
- Browse to the existing file
- You should now be good to Go. The reason it wont boot if you don’t add the disk as an IDE controller is because by default the disk is added as SATA and the virtual pc disks were not set up as SATA. If you selected the disk during the initial wizard then you will need to remove it from the SATA controller in the Storage settings and add it to the IDE controller
Thursday, 17 March 2011
Error Reading File: Source Safe and Virtual PC
To resolve this make sure the virtual PC is closed and not in a saved state.
Edit the .vmc file to remove the MAC address. Find the following line:
Remove the number so the line appears as follows:
After you remove the number, Virtual PC will create a new MAC address the next time you start the virtual machine.
Thursday, 10 March 2011
IIS Service Unavailable after setting 32bit (IIS 6.0)
Our problem was that ASP.net was trying to run a 64 bit DLL, which failed after we reset IIS to 32 bit mode. All we needed to do was change the bitness of the ASP.net DLL to 32 bit mode. To do that, first turn on the server service. Once that service is running, run the following:
C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -i -enable
This will reinstall ASP.NET with the appropriate bitness.
Configuring IIS to Run 32-bit Applications on 64-bit Windows (IIS 6.0)
- Open a command prompt and navigate to the %systemdrive%\Inetpub\AdminScripts directory.
- Type the following command:
cscript.exe adsutil.vbs set W3SVC/AppPools/Enable32BitAppOnWin64 “true”
- Press ENTER.
Monday, 7 March 2011
JQuery Mobile: Switching Pages: new page does not get style
The problem: In jQuery Mobile Alpha 2.0 all pages in the same root will not receive the proper style when linking to each other.
Example:
site/mobile/index.html <- contains a link to news.
site/mobile/news.html <- news will not receive style because index and news are in the same directory.
There are three solutions to fix this(for the time being before they release the next alpha).
Solution 1:
Use jquery 1.4.3 instead of 1.4.4. you lose icon in your headers but it's not a complete loss if you dont need them.
Solution 2:
place all your sub pages from your index in sub folders or in a sub folder. You cant use a flat site system but all the pages will style properly.
Example:
site/mobile/news/index.html
Solution 3:
add a "?" at the end of the hyperlink. This tells the jquery mobile that it needs to render a new page but it could be the same page so have it style properly. (if your hyperlinks already have GET variables in your URLs then you are all set.)
Example:
site/mobile/news.html?
Friday, 4 March 2011
Command Prompt from here context menu item
Navigate in your Registry to
HKEY_LOCAL_MACHINE/Software/Classes/Folder/Shell
and create a key called "Command Prompt" without the quotes.
Set the default string to whatever text you want to appear in the right-click menu.
Create a new key within your newly created command prompt named "command," and set the default string to
cmd.exe /k pushd %1
You may need to add %SystemRoot%\system32\ before the cmd.exe if the executable can't be found.
The changes should take place immediately. Right click a folder and your new menu item should appear.
Thursday, 3 March 2011
Fixing “ResGen.exe exited with code–1073741701” in Visual Studio 2010
Option 1:
- Open a Visual Studio command-prompt as an administrator
- Navigate to the Microsoft SDKs\Windows\v7.0A\bin directory.
- ***SAVE A COPY*** of your original resgen.exe file. This is very important if you want to be able to replace our tweak with the original file without having to repair your installation.
copy resgen.exe regen.exe.old - Set the 32-bit flag to true using corflags.exe
corflags.exe resgen.exe /32BIT+ /Force - Note the warning about strong name issues. On my machine the build now succeeds, without needing to do any additional work due to strong name issues. IF you have problems after trying this method, you can try the following to skip string name verification for that assembly-
- Register resgen.exe for strong name verification skipping using sn.exe
sn.exe –Vr resgen.exe
WARNING! This is a security risk. You are bypassing strongname verification for this assembly, making it possible for malicious code posing as resgen.exe to execute. To turn verification back on, use sn.exe –Vu resgen.exe
Option 2:
Add the following line to your csproj file ...
Option 3:
Try using the 64-bit version of tracker.exe, even for 32-bit builds, when targeting .NET 3.5 and lower. Indicate you want to run ResGen as a tool, and that it is ManagedIL (Managed32Bit doesn't work because of this flagging issue):
a. Add this to your MSBUILD command-line:
b. Or add this to your project:
System.InvalidOperationException: Request format is unrecognized
System.InvalidOperationException: Request format is unrecognized
This may be becuase the required protocol is disabled in the web config file.
Here is a list of the possible protocols that could be missing from the web or machine.config.
Tuesday, 1 March 2011
Could not load file or assembly 'your assembly name' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Could not load file or assembly 'yourassemblyname' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.BadImageFormatException: Could not load file or assembly 'Sicon.API' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Now this message is not particularly helpful but after a while searching the problem was caused becuase the web application was installed on a 64bit server, in a 64bit application pool when the web application is compiled specifically for 32bit.
This is easy enough to fix by changing the application pool to allow 32bit applications from the advanced settings screen.
Wednesday, 23 February 2011
How to Compact your Virtual PC Hardisk Files (VHD)
- Download and install Virtual PC Service Pack 1.
- Defragment your guest operating system.
- Install Guest Additions if its not already
- From the CD menu, select Capture ISO Image and browse to the Virtual PC additions directory, which is %ProgramFiles%\Microsoft Virtual PC\Virtual Machine Additions by default.
- Mount Virtual Disk Precompactor.iso. By default with auto-run enabled, the precompactor will start automatically.
- When it has finished, unmount the ISO from the CD menu.
- Run the Virtual Disk Wizard from the File menu and follow the instructions to compact your VHD file.
Saturday, 19 February 2011
ReportViewer - Sub Report with integrated security problem
After much investigation is looks as though this is caused by a phenomenon called a 'double hop'. The request is sent from the web server, to the SQL server and identity information is passed across to the SQL server. When the sub report is processing the request is again made to the SQL server but at this point the indentity information is lost as it only lasts 2 'hops' This is aparently by design for NTLM authentiation. I have read this can be fixed by using Kerberos authentication but I know nothing about this.
Two solutions that I have come up with seem to work.
1) Change all connection strings to the database to explicity specify the UserID and Password for the SQL connection. This seems to work ok but unless you want to mess about encrypting web configs and connect strings then this isnt really an option.
2) Change the user account the web applications app pool is running under. I changed this account to use the same domain user account that the web application was impersonating. It seems the sub report request is using the identity of the application pool to connect. Changing this then uses the correct user account for the integrated security in the connection string. One thing to note with this method is that I had to change the Anonymous access user in IIS to also use this domain account as a login box was being presented when browsing to the site.
Here is the code for the aspx page that is loading the report. The problem manifests itself in the LocalReport_SubreportProcessing event.
Friday, 18 February 2011
How to open SQL server ports on the firewall
Copy and paste the following code into Notepad:
@echo ========= SQL Server Ports ===================
@echo Enabling SQLServer default instance port 1433
netsh firewall set portopening TCP 1433 "SQLServer"
@echo Enabling Dedicated Admin Connection port 1434
netsh firewall set portopening TCP 1434 "SQL Admin Connection"
@echo Enabling conventional SQL Server Service Broker port 4022
netsh firewall set portopening TCP 4022 "SQL Service Broker"
@echo Enabling Transact-SQL Debugger/RPC port 135
netsh firewall set portopening TCP 135 "SQL Debugger/RPC"
@echo ========= Analysis Services Ports ==============
@echo Enabling SSAS Default Instance port 2383
netsh firewall set portopening TCP 2383 "Analysis Services"
@echo Enabling SQL Server Browser Service port 2382
netsh firewall set portopening TCP 2382 "SQL Browser"
@echo ========= Misc Applications ==============
@echo Enabling HTTP port 80
netsh firewall set portopening TCP 80 "HTTP"
@echo Enabling SSL port 443
netsh firewall set portopening TCP 443 "SSL"
@echo Enabling port for SQL Server Browser Service's 'Browse' Button
netsh firewall set portopening UDP 1434 "SQL Browser"
@echo Allowing multicast broadcast response on UDP (Browser Service Enumerations OK)
netsh firewall set multicastbroadcastresponse ENABLE
Save the file as a .txt file by using the following name: OpenSqlServerPort.txt
Rename the OpenSqlServerPort.txt file to the following: OpenSqlServerPort.bat
run the batch file on the server you would like to open the ports and you should be good to go
Wednesday, 16 February 2011
Visual Studio 2010 Report Viewer - Object Datasource
When I tried to create a new report the datasources window would never pick up my business objects. Here is a solution that I finally got working.
Create a new class library project to host reports. This library can contain the object datasources added by using the Data menu, then Add New Datasource. The reason I could not do this in the Web Application is because this menu item is missing for Web Applications!
Anyway, once you have added the datasources, add a new report to the reporting class library, here it will have access to all of the datasources (my data sources are actually business objects in another class library) This report needs to be set as an embedded resource.
Once you have the report and datasources ready its time to add the ReportViewer to an aspx page. I ran into a problem here when setting the ReportViewer.LocalReport.ReportEmbeddedResource. It looks like the report viewer looks for the resource in the current assembly. Luckily this can be resolved by adding a helper class to the reporting library to set the embedded resource from within the library.
Here is the code for the helper function in the reporting library
and here is how you would use it in the aspx page
Update for .net 4.0 I had an issue where the report would not load after being compiled in .net 4.0. The message read: 'The report definition for report 'xxx.rdlc' has not been specified' even though it was clearly in the assembly. Changing the way the Embeded resource was loaded seemed to fix the problem with the following simple change to the SetReportEmbeddedResource method in the reporting assembly.
Friday, 11 February 2011
How to resize and Existing Virtual Box Image (.vdi)
Start off by creating a fresh new drive of the size you’re after using the VirtualBox user interface. Then, locate both the your old, smaller HD and the new, larger one and run the following command in the command prompt.
After some progress indicators have come and gone your hard disk should have been cloned to the larger one. You now need to use some software to expand your drive partition into the new space. Vista and W7 have this feature built in to Disk Management so you can just opt to extend the partition to fill the remaining space.
How to remove and EFI System Partition from a Hard Disk
1. On the command prompt type diskpart
2. On the new diskpart prompt, type list disk. Note the Disk ### column.
3. Type, select disk ### (with ### being the partition you wish to delete. Usually partition 0 and with those 200 MB of size)
4. Finish by typing, clean.
Friday, 4 February 2011
SQL Server - Shrink Transaction Log with DBCC
Tuesday, 25 January 2011
Star wars episode IV A new hope in ASCII
- Click on start
- Click "Run"
- Type "CMD"
- In the command prompt window type "telnet" and press enter
- then type "o" and press enter
- Now type "towel.blinkenlights.nl" And press enter
- Now wait a few seconds and it will start Star wars episode IV A new hope
Wednesday, 12 January 2011
How to Copy and Object with Reflection
Calling private Methods and Properties
Example Below