Almost everytime you switch computer while in a project you encounters one or more problemes since you miss things that you haven't though of. I of course ran into such problems but the good thing about these problems is that they are farily easily solved.
I howevered also ran into a problem that was much harder to understand why it suddenly appared. When I was attempting to run my tests that uses locally created servicehosts any test that created such a service failed with some version of the error message below.
HTTP could not register URL http://+:8000/. Your process does not have access rights to
this namespace (see http://go.microsoft.com/fwlink/?LinkId=70353 for details).
The reason for this is apparent but the solution isn't. Since I'm not running as the Administrator when debugging in Visual Studio, the service fails to start when I run it because if missing privileges. To make sure that you have the rights to setup these servicepath you need to add them using the command shell tool netsh.
One other solution for this problem is to run Visual Studio in administrator mode.
More information about how this can be done can be found in the excellent blog.
05 July 2010
14 May 2010
Mounting network drives
How many time shave you mounted a network drive, supplied the "correct" identifications and then detected that you made an error and then needs to reboot the computer just to "get ride" of the connection to the network drive that isn't working?
I grew tired of this and looked for another way to handled this since it takes far to much time to reboot just because you made a slight error.
Open a command prompt and type the command NET USE you will see a list of connected network drivers. This command is quite good a adressing problems with net work drives. You can change the logged in user by typing NET USE / USER: or remove the connection by typing NET USE /delete.
Hopefully this helps some out there so you lose less time dealing with this problem.
I grew tired of this and looked for another way to handled this since it takes far to much time to reboot just because you made a slight error.
Open a command prompt and type the command NET USE you will see a list of connected network drivers. This command is quite good a adressing problems with net work drives. You can change the logged in user by typing NET USE / USER:
Hopefully this helps some out there so you lose less time dealing with this problem.
Labels:
connection,
credentials,
NET USE,
Network drives,
username
Initializations during test cases
In any larger project a complex test suite should be built, a test suite that when run through should cover most of the code that handles buisness logic, aggregations and such. Presentations aren't always that important even if it is good to include those parts in the tests too,When the tests starts to increase they will take longer and longer to complete which will impact on the performance of the developers since these have to wait for tests to complete during verficiations of changes.
There are several methods for dealing with this one is the use of a common initializations class that setup the basic structure and adds basic data needed for the tests. The problem with this approach is that if you need to add some new data or change data in the setup you will have a huge impact on the tests and maybe changing a few that should have given indications on a problem that has been introduced. Its often better to separate the tests and let each test setup the data required for just that test and clean up afterwards. If using a database the setup and teardown of the database could be a common setup that is run first in the testclass and teardown occured at the end after all tests. In such an instance you need a way to clean out the database without tearing it down compleatly.
Of course these are just my thoughts and there a several methods in dealing with this. One that we often use is the use of mocking of objects since you then don't need a real database just the apperance of one. from the systems point of view. This makes that test much much more efficient and faster but has the drawback that you aren't really testing the database which also needs to be done.
I any circumstance test ARE important and you should never feel that a test is useless and remove them if you aren't compleatly and absolutly sure since there is often a very good reason for that the test was created in the first place.
Happy testing!
Labels:
database,
initialization,
mock,
performance,
test cases,
testing
12 March 2010
Language pack and Windows 7 Professional
If you are using a version of Windows 7 that haven't gotten integrated user control of how to install language packs you need to do some manual work to get it working.
First of all you need the lp.cab file for you language of choice, can be found in the language pack ISO file on MSDN and possible also in other places on the net.
Once you have the language file follow these few steps and you can have you Windows version in the language of your choice.
* Start a command windows with administror rights
* Type: DISM /Online /Add-Package /PackagePath:
* Type bcdedit /set {current} locale
* Type bcdboot %WinDir% /l
* Start a register editor with administator rights
* Locate HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/MUI/UILanguages
* Delete en-us
* Restart computer and you have your own selected language
Example to add swedish to Windows 7
DISM /Online /Add-Package /PackagePath C:\lp.cab
bcdedit /set {current} locale sv-se
bcdboot %WinDir% /l sv-se
First of all you need the lp.cab file for you language of choice, can be found in the language pack ISO file on MSDN and possible also in other places on the net.
Once you have the language file follow these few steps and you can have you Windows version in the language of your choice.
* Start a command windows with administror rights
* Type: DISM /Online /Add-Package /PackagePath:
* Type bcdedit /set {current} locale
* Type bcdboot %WinDir% /l
* Start a register editor with administator rights
* Locate HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/MUI/UILanguages
* Delete en-us
* Restart computer and you have your own selected language
Example to add swedish to Windows 7
DISM /Online /Add-Package /PackagePath C:\lp.cab
bcdedit /set {current} locale sv-se
bcdboot %WinDir% /l sv-se
15 February 2010
Nhibernate and mapping Enums
When using NHibernate one has to be careful in certain circumstances to avoid small errors that may have a huge impact. In one area an "error" might be hidden for a long time without anybody noticing it and everything working as it should.
As soon as you create a mapping file with properties that are explicitly given types your should be aware what you are doing. If you for instance create a mapping file where you map a bit column and specify that the type for this column is Int32 and then in the mapping class define this property as an Enum you might be getting into problems.
Since the class that is used for the mapping in the project might differ from the actual values in the database NHibernate will have problems understanding that nothing really has changed.
For example if you have the following in your mapping file, maybe for mapping up a user and specify gender for the user.
<property name="Gender" not-null="true" type="Int32" />
And the following class defined:
public class Person
{
public enum GenderEnum
{
Male = 0,
Female
}
public enum GenderEnum
{
Male = 0,
Female
}
public GenderEnum Gender;
}
Once you load this element into memory the property Gender will be tranformed from being an Int32 value in the database to a GenderEnum type in the project. Later on when you either want to unload this object or load another object of the same type or any operation on the object that might trigger an update event for NHibernate such an event will indead be triggered, regardless if you have changed any values or not. The reason for this is that NHibernate detects a change of in the object, the property that is mappped as being Int32 in the database is now returned as an Enum.
To fix this problem remove the type declaration in the mapping file and let NHibernate resolve the type itself.
A more extensive information about this problem can be found in the following links:
Reading of text files
In more or less every medium sized or bigger project there will be a need for reading text files sooner or later. Most of the time the text files will be quite good organized either as fixed post files or separated file (comma, tab and newline being the most common separator).
If the file is of type fixed post file one of the best method is to match the file structure into a class structure in the program and read line by line an instance of such an object. This supports multiple instances of subsections for elements and such too. Serializing the file becomes quite easy and goes farily smooth and if there is some error in the filecontent it will propagate and show early instead of being hidden away. Also it is possible to store information from the file in a database farily easy with this approch since a direct mappping to a database structure is possible. If you are using NHibernate (or Hibernate for Java) it is even possible to create a mapping file where the underlying class is the same for the database as for the textfile. One more advantage is the possibility to create automatic tests for the objects use to verify that the business rules are followed in the application.
With a file that is using some sort of separators to differentiate between the different post many times the easies way is to read up the entire file (or row by row) and run a split over the separators and then parse each element into a underlying object that holds the structure of the file. Using this approch measn its easy to detect errors in length of each element in the file as well as each field for each element. This also means that if the file becomes corrupt or changed in the future (not uncommon) this will be detected and can be handled correctly.
When it omes to have to actually read the text from the files it differes from project to project as well as from language to language but most of the times some simple loop expression is easy enough to use and quite effective at the same time. Don't complicate things, keep it easy and you will earn stability and readability of the source code.
If the file is of type fixed post file one of the best method is to match the file structure into a class structure in the program and read line by line an instance of such an object. This supports multiple instances of subsections for elements and such too. Serializing the file becomes quite easy and goes farily smooth and if there is some error in the filecontent it will propagate and show early instead of being hidden away. Also it is possible to store information from the file in a database farily easy with this approch since a direct mappping to a database structure is possible. If you are using NHibernate (or Hibernate for Java) it is even possible to create a mapping file where the underlying class is the same for the database as for the textfile. One more advantage is the possibility to create automatic tests for the objects use to verify that the business rules are followed in the application.
With a file that is using some sort of separators to differentiate between the different post many times the easies way is to read up the entire file (or row by row) and run a split over the separators and then parse each element into a underlying object that holds the structure of the file. Using this approch measn its easy to detect errors in length of each element in the file as well as each field for each element. This also means that if the file becomes corrupt or changed in the future (not uncommon) this will be detected and can be handled correctly.
When it omes to have to actually read the text from the files it differes from project to project as well as from language to language but most of the times some simple loop expression is easy enough to use and quite effective at the same time. Don't complicate things, keep it easy and you will earn stability and readability of the source code.
09 February 2010
MSN and AVG antivirus setting
I'm using the free version of AVG antivirus (http://www.avgantivirus.se/avg-free/view-all-products) at home and recently had to setup my computer again, reinstallation problems. When I sat up MSN i saw that my settings for virus scanning didn't work. Regarless to say I wanted to have a antivirus scan of files that arrives and searched the internet for solutions.
There is some parameters for AVG scanner that SHOULD work but to really get it to workw ith msn you need to make some extra handling, otherwise it will just say that scan completed but if you look at the logs no files have been scanned.
To make it so that AVG really scans incomming files you need to create a batchfile that is run instead of the pure exeutable. Don't ask me why!
The looks of the batch file should be as follows:
@echo off
"\avgscan?.exe" /SCAN=%1 /HEUR /ARC /PUP /CLEAN
where you either use avgscanx.exe or avgscana.exe depending on if you are using 32 or 64-bit version of the program.
Below is a more extensive presentation of this and the source of where I found this information.
http://www.mydigitallife.info/2009/07/07/how-to-use-avg-anti-virus-scanner-with-msn-windows-live-messenger-winzip-winrar-download-express-miranda-im/
There is some parameters for AVG scanner that SHOULD work but to really get it to workw ith msn you need to make some extra handling, otherwise it will just say that scan completed but if you look at the logs no files have been scanned.
To make it so that AVG really scans incomming files you need to create a batchfile that is run instead of the pure exeutable. Don't ask me why!
The looks of the batch file should be as follows:
@echo off
"
where you either use avgscanx.exe or avgscana.exe depending on if you are using 32 or 64-bit version of the program.
Below is a more extensive presentation of this and the source of where I found this information.
http://www.mydigitallife.info/2009/07/07/how-to-use-avg-anti-virus-scanner-with-msn-windows-live-messenger-winzip-winrar-download-express-miranda-im/
Subscribe to:
Posts (Atom)