Nifty Hacks
Debugging shared Client/ASP Web Service projects in VS2010
by mark on May.19, 2011, under Windows
This post details the setup required for combined Remote Debugging server side web services with client programs in the same project. It is here mainly to assist my memory but may be of use to others as I had to dig for a lot of this info.
It assumes you log into the local development machine as a domain user and the remote IIS server is on a different domain with no shared trust.
This applies to VS2010 but should also be relevant to vs2008 and vs2005.
Local Computer Config
You will have logged on the local computer as MAINDOMAIN\user
- Create a local computer user with the same name and password as your domain one. ( This step may be unnecessary )
- Change the Sharing and Security Model In Local Security Policy/Local Policies/Network access: Sharing and security model for local accounts
set Classic – local users authenticate as themselves
Remote IIS Computer
- Create a local computer user with your domain user name and same password.
- Add Administrators group to this user.
- make sure msdeploy works.
- Add debug rights to new user In Local Security Policy/Local Policies/User Rights Assignment/Debug programs/Add User or Group
- Change the Sharing and Security Model In Local Security Policy/Local Policies/Network access: Sharing and security model for local accounts
set Classic – local users authenticate as themselves
msvsmon config
Create a batch file to run msvsmon called runmsvsmon.bat in the base path (e.g. wwwroot\ServiceTest) of the asp service as follows
SET _NT_SYMBOL_PATH=%CD%\bin cd "C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\Remote Debugger\x86" start msvsmon.exe
Run the batch file as the user added above.
This will allow symbols to be used during step into service debugging.
Change the server name in msvsmon to
DEVDOMAIN\user@LOCALMACHINENAME
This allows your user to attach juts by entering the remote ip address (domain search for remote server is disabled in this case) in the Qualifier field in VS and thus works for standard debugging too.
Visual Studio Config
In Debugger Options
- disable Enable just my code
- enable Enable source server support
In Web Service project properties
- Web/Use Custom Web Server/Url – http://remoteip/ServiceTest
- Package/Publish Web/IIS Web Site – Default Web Site/ServiceTest
In Publish Service
- username user
- password is whatever
- save password checked
- method WebDeploy
- URL http://remoteipaddr
- Site Default Web Site/ServerTest or Default Web Site/Server
- check Mark as IIS app
- check Leave extra files
Procedure
Deploy Web service first
This should succeed if msdeploy is working on the remote server.
You should see the files update on the target.
add debug=”true” to compilation tag in web.config.<compilation debug="true" targetFramework="4.0"> </compilation>
Test Tools/Process Attach
If you get a list of processes, you have everything should be working.
Debug Client and Web Service together
Set a breakpoint inside the service module and press F5. It should then break with source.
Set a breakpoint in the desktop client and step into a web method.
Using a Windows CE 4.20 SDK with VS2005 and VS2008
by mark on Nov.23, 2010, under WinCE
I have had the requirement to use a windows CE SDK with Visual Studio 2005 and 2008. This is desirable because they have better/newer ARM compilers, as well as being able to integrate a combined Native/.NET solution in 1 place for a single step build.
The hint on how to do this came after playing with Qt. Qt Comes with a program (continue reading…)
Git Tricks and Tips
by mark on Nov.19, 2010, under Nifty Hacks, linux
Maintaining Vendor Branches
For the case where you have a vendor tarball or zip source bundle, these are effectively managed in a branch.
If the vendor releases a new version, the update process is:
git co vendor
mkdir zzz
mv * zzz/
mv .* zzz/
mv zzz/.git .
rm -rf zzz
git commit -a
Now you can merge or rebase your development tree to the new vendor release.
Some useful Git links.
Refs:
http://cheat.errtheblog.com/s/git
http://sourceware.org/frysk/build/git-fu.html
http://sandofsky.com/blog/git-workflow.html
No Sound in Limited User Account
by mark on Sep.17, 2010, under Windows
Recently I needed to do a repair install on Windows XP, after which sound was no longer working on limited user accounts. After extensive searching I realized no one had a solution. The device driver was ok and operating and sound was working fine on administrator capable accounts.
The strange thing is that the Realtek HD sound app worked Ok on the LUA. I concluded from this that the software enumerator was at fault, specifically the registry keys that would have to be read for the software enumerator to read its current list.
Use regedit to change the permissions of the tree on currentcontrolset to fix this issue. Log in again and its all good.
Mapping special names to multiple USB serial adapters
by mark on Apr.17, 2010, under Solar, linux
The watts clever envi has a USB serial adapter which is a Prolific pl2303. When inserted it is assigned /dev/ttyUSB0 by udev, among a few other symlinks. I have now obtained an RS485 serial adapter on ebay for A$13.98 delivered which uses the exact same chip, which makes it indistiguishable from the envi’s port. What I needed was a way to guarantee uniqueness regardless of the enumeration order on boot or random hot plugin. Naturally, this is for the Aurora GCI which will be installed when they become available in May.
Researching udev a bit, I found /lib/udev/rules.d/60-persistent-serial.rules (mine is a debian system). This file shows how the standard symlinks are done. Since each USB port is unique, I should be able to use that uniqueness to map another symlink to the device.
Firstly plug in the device in the chosen USB port and issue
udevadm info --query=all --name=/dev/ttyUSB1
This shows a heap of stuff but mainly we are interested in
P: /devices/pci0000:00/0000:00:1a.0/usb2/2-1/2-1:1.0/ttyUSB1/tty/ttyUSB1
Create a file in /etc/udev/rules.d/70-persistent-serial.rules which contains
#see /lib/udev/rules.d/60-persistent-serial.rules
ACTION!=”add|change”, GOTO=”persistent_serial_end”
SUBSYSTEM!=”tty”, GOTO=”persistent_serial_end”
KERNEL!=”ttyUSB[0-9]*|ttyACM[0-9]*”, GOTO=”persistent_serial_end”IMPORT=”usb_id –export %p”
#IMPORT=”path_id %p”ENV{ID_SERIAL}==”", GOTO=”persistent_serial_end”
# usb nearest ethernet connector
ENV{DEVPATH}==”*usb2/2-2/2-2:1.0*”, SYMLINK+=”serial/by-name/envi”
#bottom front connector
ENV{DEVPATH}==”*usb7/7-1/7-1:1.0*”, SYMLINK+=”serial/by-name/rs485″
# usb below nearest ethernet connector
ENV{DEVPATH}==”*usb2/2-1/2-1:1.0*”, SYMLINK+=”serial/by-name/rs485″LABEL=”persistent_serial_end”
Replug and voila you get /dev/serial/by-name/rs485 which will always be the correct device.
Now I just have to run the wire to where the GCI will be installed.
Funny Characters for gcc/g++ errors and warnings
by mark on Apr.01, 2010, under linux
I have found that on some linux systems when you compile with gcc and g++ the error messages have funny characters like
test.c: In function â:
test.c:6: warning: unused variable â
This is due to the default locale being set to something other than the default.
in /etc/default/locale you will have a line like
LANG="en_AU.UTF-8"
add
LC_CTYPE=C
Restart the shell and compile again and the errors are now meaningful.
test.c: In function 'main':
test.c:6: warning: unused variable 'x'
Naturally you could set it in the local shell for the session, but then you would have to do it every time.
Migrating Windows User Ids
by mark on Mar.12, 2010, under Windows
There are times when domains on windows change and thus your user id changes. However, you may have lots of files owned by you that are not in your user dir. Migrating these user ids to you new one, I’ve found, is not too difficult after all.
All you need is a tool from microsoft called subinacl.
Download and install the msi. Install path is
C:\Program Files\Windows Resource Kits\Tools\subinacl.exe
So use this for the command name below.
First find your old userid. Use a file you know you used to own. E.g. the projects directory.
Subinacl /file c:\projects /display
Copy and paste yours for use in the commands below
Now for the commands. Do for all drives if you have multiple disks.
The lines below are for me of course so sub in your cut S-xxx and new user id
Subinacl /subdir c:\ /accountmig=S-x-x-xx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxx=newdomain\username
also the primary group, which can be found up the top of the display dump.
Subinacl /subdir c:\ "/accountmig=S-x-x-xx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxx=newdomain\Domain Users"
all registry keys
Subinacl /subkeyreg HKEY_CURRENT_USER /accountmig=S-x-x-xx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxx=newdomain\username
Subinacl /subkeyreg HKEY_LOCAL_MACHINE /accountmig=S-x-x-xx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxx=newdomain\username
Subinacl /subkeyreg HKEY_CLASSES_ROOT /accountmig=S-x-x-xx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxx=newdomain\username
(none found, so optional)
and the groups
Subinacl /subkeyreg HKEY_CURRENT_USER "/accountmig=S-x-x-xx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxx=newdomain\Domain Users"
Subinacl /subkeyreg HKEY_LOCAL_MACHINE "/accountmig=S-x-x-xx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxx=newdomain\Domain Users"
Subinacl /subkeyreg HKEY_CLASSES_ROOT "/accountmig=S-x-x-xx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxx=newdomain\Domain Users"
After you are happy
Subinacl /subdir c:\ /suppresssid=S-x-x-xx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxx
Subinacl /subkeyreg HKEY_CURRENT_USER /suppresssid=S-x-x-xx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxx
Subinacl /subkeyreg HKEY_LOCAL_MACHINE /suppresssid=S-x-x-xx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxx
When you are finished, everything you used to own you will own again.
WordPress Install Direct Filesystem Hack
by mark on Mar.05, 2010, under Wordpress
I use
chgrp -R www-data wp-content
chown -R g+w wp-content
To make this work with wordpress, edit wp-admin/includes/file.php in function get_filesystem_method() and comment out
if ( getmyuid() == fileowner($temp_file) )
to
#if ( getmyuid() == fileowner($temp_file) )
If the test file can be written, who cares if it is not owned by the webserver.
You will have to reapply this edit every time wordpress core is updated.
Using WinCE5.0 drivers on WinCE4.2
by mark on Feb.09, 2010, under WinCE
Since wince 4.2 is quite old and not that well supported by OEM device manufacturers, it is often hard or impossible to get drivers for wince4.2 for these devices.
However the API into coredll and other parts of the wince system libraries is, if not identical, then almost identical.
I had an instance recently where I needed to make a USB wifi device work with wince4.2. After doing some research, I chose a ralink 2471W based device. However it came with a wince5 driver. Binary only of course.
Looking at the driver dll, all the imported functions were available except 1 in the ndis.dll, that being NdisQueryPacket. In wince4.2, this fucntion is provided by a #define, but in wince5 it is a instantiated function.
The solution is to compile the following code to an obj, and use the lib32 to add it to ndislib.lib in the private tree.
// local modded copy of ndis.h
#include "ndis.h"
#include <pkfuncs.h>
VOID
NdisQueryPacket(
IN PNDIS_PACKET _Packet,
OUT PUINT _PhysicalBufferCount OPTIONAL,
OUT PUINT _BufferCount OPTIONAL,
OUT PNDIS_BUFFER * _FirstBuffer OPTIONAL,
OUT PUINT _TotalPacketLength OPTIONAL
)
{
NdisQueryPacketDef(_Packet, _PhysicalBufferCount, _BufferCount, _FirstBuffer, _TotalPacketLength);
}
Also add the export definition to the end of ndis.def so that it becomes exported when ndis.dll is built with the system.
Finally, remember to put these 2 files back in the private tree where you got them from.
Now when the system is rebuilt with platform builder, the new ndis.dll will contain this extra function, thus allowing the USB wifi driver to function perfectly without modification.