If you are using Teststand 2010 with DOTNET 4.0 you will get an error as Teststand 2010 was build with DOTNET 2.0. The work around for this is to create a file called SeqEdit.exe.config. In this file add the following:
<?xml version="1.0"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
</assemblyBinding>
</runtime>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" />
</startup>
</configuration>
Adding supportedRuntime = v4.0 will set Teststand to use the DOTNET 4.0 runtime engine. Then all you need to do is save this file in the Teststand directory. <Teststand>\Bin. In my case it was C:\Program Files (x86)\National Instruments\TestStand 2010 SP1\Bin. Once it is in this location restart Teststand and you should now be able to use DOTNET 4.0 libraries. Typically in my case I use CSharp DLL's to do the main part of my code and Teststand is just the sequencer.
Blog for developers on Microsoft Visual Studio implementation and coding examples. With this blog I am going to post some of the problems I have solved and the solutions to those problems.
Thursday, August 14, 2014
Saturday, August 9, 2014
Click Once Deployment
I have been to busy and have gotten out of the habit of doing blogs. So now I am going to restart up my blogs. The post will be on how to create a click once deployment with CSharp. Click once provided a means to deploy applications to you users and then it allows the user to update when you make changes. This is nice if you have a lot of clients and want to ensure they get the latest releases.
The first step is to go to properties page and click publish on the bottom left. For the location I user the \\servername that the client will have access to.
If you click on prerequisites you can select any items needed. Normally the default setting will install all the required items.
Under updates I normally select the application should check for updates before it starts. This will check for new versions and allow the user to update the application is they want to.
Under options I select description and for the publisher name this will end up being the main menu item group under the start short cut. The product name will be the name of the program. So when the program is installed the start menu will have a short cut called MTCode->TestDeployment.
The other change I normally make is to click options and under manifests select create short cut on desktop. I find this a good option as some users have trouble finding it otherwise.
Once all the setting are done then the next step is to save and deploy. The property page has a deploy option on the bottom, but sometimes this dose not seam to work and give an error. So normally I go to the build tab and publish form there.
Once deploy is successfully done you will see the proper directory on your server location with the setup files. Then the user just needs to run the installer and the program installs. After that every time they run the program is will check for new updates and allow the user the option to upgrade if needed.
The first step is to go to properties page and click publish on the bottom left. For the location I user the \\servername that the client will have access to.
If you click on prerequisites you can select any items needed. Normally the default setting will install all the required items.
Under options I select description and for the publisher name this will end up being the main menu item group under the start short cut. The product name will be the name of the program. So when the program is installed the start menu will have a short cut called MTCode->TestDeployment.
The other change I normally make is to click options and under manifests select create short cut on desktop. I find this a good option as some users have trouble finding it otherwise.
Friday, August 16, 2013
USB Virtual Comport Assignements
In this article I am going to go over how to force a USB device with a virtual comport to use the same comport.
HKEY_LOCAL_MACHINE\SYSTEM/CurrentControlSet/Control/USBFlags
Add REG_BINARY value 01 key named IgnoreHWSerNum"VID""PID"
VID = 10C4
PID = EA70
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB
IgnoreHWSerNum10C4EA70
HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/COM Name Arbiter
COMDB = 03 00 00 00, if you have 2 built-in serial ports (or 01 00 00 00 if you only have one built-in COM port).
NOTE: 03 in binary is 0000 0011 so the lowest bit set (the 1 on the right) means COM1 is in use, and the bit to its left, in the 2 position, means COM2 is set. You will also want to clean keys for any non-standard serial ports from these places:
HKEY_LOCAL_MACHINE/HARDWARE/DEVICEMAP/SERIALCOMM
HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows NT/CurrentVersion/Ports You should be able to power down and reinstall the Digi adapter if it had been removed from the system. If it is installed, reboot the system. The adapter should be redetected and the driver installed. The com ports should now default to start at COM3 (or COM2 with only one built-in serial).
HKEY_LOCAL_MACHINE\SYSTEM/CurrentControlSet/Control/USBFlags
Add REG_BINARY value 01 key named IgnoreHWSerNum"VID""PID"
VID = 10C4
PID = EA70
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB
IgnoreHWSerNum10C4EA70
HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/COM Name Arbiter
Saturday, September 8, 2012
Creating an Occasionally Connected Smart Device Application a working example with emulator
In this blog I plan on going thru how to create an occasionally connected smart device application and get it working correctly. I found this example Smart Device Example link to explain how to create and connect to the emulator. The problem is this is not a complete and working example, so after spending several days just trying to get this to work I will try to go back thru what I did. I will start with this example with my added changes and present a working version of this example.
The first issue I ran into when trying to create this project is which Visual Studio version should I use. After searching thru the web from the best that I can see I the newest version that still supports winCE is VS2008, so I started with this version. The first step is to make sure you install all the prerequisites as listed below:
Prerequisites
One mistake I made was to not install all of the preequisites, since I noticed I already had MSQL Server Comact 3.5 installed. You must make sure you install the Service pack 1 for this or you will get connection errors when you try to do your remote connection with the compact framework. Mine would blow up on the client side of code listed below:
Microsoft.Synchronization.Data.
This would give the following cryptic error unhandled Message="TargetInvocationException" and I had to seach lots of articles to finally figure this out. Once I added service pack 1 that error went away.
After fixing that I then got a client error in Microsoft.Synchronization.Data.SyncStatistics syncStats = syncAgent.Synchronize(); for the following ArgumentException error on the client side.
The first thing to do is see if IE can connect to the WCF service to ensure it is still working. To do this I set theMiddleTierServiceLibrary as the startup project and then select the start without debugging option in the Debug menu. This will bring up the deployment window where I will just select cancel and then in the deployment errors click continue. Figure 1 shows the WCF screen and from here I just copy the http://10.83.4.96:8080/NorthwindCacheSyncService/ from the WC F test client and paste it in IE where you should see the page as listed in figure 2. From this I now know that the WCF service is working and a client can connect to it.
Once the device is connected you should see the phone and active sync screens pop up and establish a connect. Now the PocketPC has a ENET connect thru active sync and it should be able to connect to WCF service. But in my case using http://10.83.4.96:8080/NorthwindCacheSyncService/ still did not connect with the same connection error. So the next thing I tried was to use ppp_peer:8080 as the connection name as this is the default name for the emulated device and behold it was able to connect. Great now I know I can connect on ppp_peer with IE, but what about the client application.
After running the Smart Device Client code I was still getting a argument error and from this I see that it cannot connect to the WCF service thru IP address directly. So for a test I inserted strHostName = Convert.ToString(Dns.GetHostEntry(Dns.GetHostName()).AddressList[0]); into the Sync() function just to see what the address was that it returned. The address returned was 192.168.55.101 and this was what I was expecting. Then I just let the code run and magic it now started to work.
string
ServerSyncProviderProxy syncProxy =new Microsoft.Synchronization.Data.ServerSyncProviderProxy(svcProxy);
The first issue I ran into when trying to create this project is which Visual Studio version should I use. After searching thru the web from the best that I can see I the newest version that still supports winCE is VS2008, so I started with this version. The first step is to make sure you install all the prerequisites as listed below:
Prerequisites
To complete this walk through you must:
- Install the Northwind sample database on a Microsoft SQL Server or Microsoft SQL Server Express Edition database. The local database cache on the device emulator will synchronize with this database. For more information, see How to: Install Sample Databases.
- Install Windows Mobile Device Center (Windows Vista) or ActiveSync.
- Install Visual Studio 2008 Service Pack 1.
- Install Microsoft Synchronization Services for ADO.NET.
- Install Microsoft SQL Server Compact 3.5 Service Pack 1 for Windows Mobile.
Microsoft.Synchronization.Data.
This would give the following cryptic error unhandled Message="TargetInvocationException" and I had to seach lots of articles to finally figure this out. Once I added service pack 1 that error went away.
After fixing that I then got a client error in Microsoft.Synchronization.Data.SyncStatistics syncStats = syncAgent.Synchronize(); for the following ArgumentException error on the client side.
The first thing to do is see if IE can connect to the WCF service to ensure it is still working. To do this I set theMiddleTierServiceLibrary as the startup project and then select the start without debugging option in the Debug menu. This will bring up the deployment window where I will just select cancel and then in the deployment errors click continue. Figure 1 shows the WCF screen and from here I just copy the http://10.83.4.96:8080/NorthwindCacheSyncService/ from the WC F test client and paste it in IE where you should see the page as listed in figure 2. From this I now know that the WCF service is working and a client can connect to it.
Figure 1
Figure 2
Once I know a client can connect I then set SmartDeviceSyncClient as the start up project. Then I just select start debugging from the Debug menu option. Once the code runs I will get the ArgumentException error so I ignore the error and let the code run. My next step is to try to connect thru IE on the PocketPC emulator with the saem address as listed above. As Shown below you can see that connection files and I cannot connect to the WCF service from the PocketPC.
Figure 3
No back to reading more articles on this problem and I come up with this. How is the PocketPC able to establish a connection to the service. Some how it has to have a enet connection and know how to resolve it to an IP address. So the way to do this is in VS IDE Tools->Device Emulator Manager. Once this is selected it bring up a panel with all the emulation devices. On this screen I selected window Mobile 5.0 and right click on it. The right click option and select connect.
Figure 4
Once the device is connected you should see the phone and active sync screens pop up and establish a connect. Now the PocketPC has a ENET connect thru active sync and it should be able to connect to WCF service. But in my case using http://10.83.4.96:8080/NorthwindCacheSyncService/ still did not connect with the same connection error. So the next thing I tried was to use ppp_peer:8080 as the connection name as this is the default name for the emulated device and behold it was able to connect. Great now I know I can connect on ppp_peer with IE, but what about the client application.
Figure 5
string
Figure 6
So from this I am not sure what caused it to start working, but I tested it several times and it seams to run and connect correctly now. I would assume that forcing a DNS look up made the look up table instantiate the connection. I will test this further in another article, but for not it works.
Thursday, June 14, 2012
Regular Expressions for Date/Time Validation
On one of my projects I was asked to validate the date/time input into a textbox. So my solution was to use the built in Validator controls in VS2008. Since this project is based on 2008 I will use that for the IDE on this project.
The first step for this project was to select the RegularExpressionValidator from the toolbox under Validation tab. Once I dragged it to the project all I had to do was add the ControlToValidate, some text on error and then add the ValidationExpression. This is where it got a little tricky as I assumed all I had to do was find someone that already had a sample that worked and add it. Here is a link that has some good examples on validation.Self-Validating-Text-Box
The problem was for the examples I found none of them seamed to work correctly. So then I had to dive into Regular Expressions and try to figure out how to make the one I downloaded work.
Here is a link on using regular expressions:The-30-Minute-Regex-Tutorial. After reading this I then downloaded Expresso and installed it on my computer. From here I could then use Expresso to test and validate my expressions.
Here is the expression I found on the internet:
\A(?:1[0-2]|0[1-9])[/.-](?:3[01]|[12][0-9]|0[1-9])[/.-][0-9]{4}[ \t]+(?:1[0-2]|0[1-9])[:.](?:1[0-9]|0[1-9])[:.][0-5][0-9][ \t]+(?:AM|PM)
This seamed to work fine on my first test case, so I put it in my code and of course it did not work. Therefore I then put it into the Expresso tool and started to run test cases.
So with a date/time of 06/13/2012 02:11:10 AM it worked fine, but when I changed the date/time to 06/13/2012 02:31:10 AM it did not work. So from here I needed to dive into regular expressions to see why it was not working. The first step I took was to review the Regex Analyzer on the right screen of Espresso. This will explain what the commands are doing and as listed below I went thru each on of them.
\A - Beginning of string
Date
(?:1[0-2]|0[1-9])
[/.-] - Match [] operator so this will match / . -
This will match the /
(?:3[01]|[12][0-9]|0[1-9])
[/.-] Match [] operator so this will match / . -
This will match the /
[0-9]{4} - any class from 0-9 repeat 4 times
This will match the year to 2012
[ \t]+ match \t tab with any repetitions
This will match any tabs
Time
(?:1[0-2]|0[1-9])
[:.] - any character in this class
(?:1[0-9]|0[1-9])
[:.]- any character in this class
[0-5][0-9]
[ \t]+ match \t tab with any repetitions
This will match any tabs
(?:AM|PM) - Match AM or PM
This will get the AM or PM
So from this break down I can see a couple of my problems in the time.
\A(?:1[0-2]|0[1-9])[/](?:3[01]|[12][0-9]|0[1-9])[/][0-9]{4}[ \s]+(?:1[0-2]|0[1-9])[:.](?:[1-5][0-9]|0[1-9])[:.][0-5][0-9][ \s]+(?:AM|PM)
Also you can easily use regex in CSharp to validate or filter data just like grep. All you need to do is add using System.Text.RegularExpression and then call RegEx.IsMatch(...) to evaluate the data of interest.
The first step for this project was to select the RegularExpressionValidator from the toolbox under Validation tab. Once I dragged it to the project all I had to do was add the ControlToValidate, some text on error and then add the ValidationExpression. This is where it got a little tricky as I assumed all I had to do was find someone that already had a sample that worked and add it. Here is a link that has some good examples on validation.Self-Validating-Text-Box
The problem was for the examples I found none of them seamed to work correctly. So then I had to dive into Regular Expressions and try to figure out how to make the one I downloaded work.
Here is a link on using regular expressions:The-30-Minute-Regex-Tutorial. After reading this I then downloaded Expresso and installed it on my computer. From here I could then use Expresso to test and validate my expressions.
Here is the expression I found on the internet:
\A(?:1[0-2]|0[1-9])[/.-](?:3[01]|[12][0-9]|0[1-9])[/.-][0-9]{4}[ \t]+(?:1[0-2]|0[1-9])[:.](?:1[0-9]|0[1-9])[:.][0-5][0-9][ \t]+(?:AM|PM)
This seamed to work fine on my first test case, so I put it in my code and of course it did not work. Therefore I then put it into the Expresso tool and started to run test cases.
So with a date/time of 06/13/2012 02:11:10 AM it worked fine, but when I changed the date/time to 06/13/2012 02:31:10 AM it did not work. So from here I needed to dive into regular expressions to see why it was not working. The first step I took was to review the Regex Analyzer on the right screen of Espresso. This will explain what the commands are doing and as listed below I went thru each on of them.
\A - Beginning of string
Date
(?:1[0-2]|0[1-9])
- () - grouping
- ?: match : 0 or 1 times
- 1[ looking for 1
- [0-2] range of 0 to 2
- 0[ looking for 0
[/.-] - Match [] operator so this will match / . -
This will match the /
(?:3[01]|[12][0-9]|0[1-9])
- () - grouping
- ?: match : 0 or 1 times
- 3[ looking for 3
- [01] - match 01
- [12] match 12
- [0-9] range of 0 to 9
- 0[ looking for 0
- [1-9] range of 1 to 9
[/.-] Match [] operator so this will match / . -
This will match the /
[0-9]{4} - any class from 0-9 repeat 4 times
This will match the year to 2012
[ \t]+ match \t tab with any repetitions
This will match any tabs
Time
(?:1[0-2]|0[1-9])
- () - grouping
- ?: match : 0 or 1 times
- 1[ looking for 1
- [0-2] range of 0 to 2
- 0[ looking for 0
- [1-9] range of 1 to 9
[:.] - any character in this class
(?:1[0-9]|0[1-9])
- () - grouping
- ?: match : 0 or 1 times
- 1[ looking for 1
- [0-9] range of 0 to 9
- 0[ looking for 0
- [1-9] range of 1 to 9
[:.]- any character in this class
[0-5][0-9]
- [0-5] - match 0 to 5
- [0-9] - match 0 to 9
[ \t]+ match \t tab with any repetitions
This will match any tabs
(?:AM|PM) - Match AM or PM
This will get the AM or PM
So from this break down I can see a couple of my problems in the time.
- (?:1[0-2]|0[1-9]) I need this to go from 0 to 5
- (?:1[0-9]|0[1-9]) I need this to also go from 0 to 5
- [ \t]+ I need to also handle space
- [/.-] I only want to match /
\A(?:1[0-2]|0[1-9])[/](?:3[01]|[12][0-9]|0[1-9])[/][0-9]{4}[ \s]+(?:1[0-2]|0[1-9])[:.](?:[1-5][0-9]|0[1-9])[:.][0-5][0-9][ \s]+(?:AM|PM)
Monday, June 4, 2012
There were deployment errors. Continue! Missing popup
For this blog I will go thru how to enable the delpoyment errors measage box if it is not showing in VC2008.
I ran into this problem on one of my PC's while testing a WCF service for a smart device. When I configure this device to deploy I will select cancel and then hit yes to continue to test out the WCF interface. Below is a snapshot of the WCFTest client.
Well for one of my PC's this was working, but for the other I would just get a deployment error. In order to enable this option got to tools->options->Projects and Solutions->Build and Run->On Run, when build or deplyment errors occur: Prompt to Launch.
I ran into this problem on one of my PC's while testing a WCF service for a smart device. When I configure this device to deploy I will select cancel and then hit yes to continue to test out the WCF interface. Below is a snapshot of the WCFTest client.
Well for one of my PC's this was working, but for the other I would just get a deployment error. In order to enable this option got to tools->options->Projects and Solutions->Build and Run->On Run, when build or deplyment errors occur: Prompt to Launch.
Thursday, June 16, 2011
Silverlight developer version
I was working on testing a Silverlight web with WCF I created I wanted to run the page in debug mode. When I tried to run it I got the error Silverlight Debug version not installed. After some quick we searching I found the installer for it from Microsoft and installed it. This enabled me to run and step thru the code in debug mode. Which is a nice feature to help in debugging and understanding the code.
Subscribe to:
Posts (Atom)