Lately I've been getting the error message :
error MSB4018: Microsoft.Build.Shared.InternalErrorException: MSB0001: Internal MSBuild Error: xsd.exe unexpectedly not a rooted path
... while I've been building a project that uses that task in a pre-build step to generate code from XSDs. After googling around a little bit, I found the solution on this page. The gist of it was that xsd.exe wasn't in the PATH variable, and therefore Visual Studio couldn't find it. If anybody else has this problem, add this folder to your PATH:
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools
... or your system's equivalent, wherever the XSD.exe tool is stored on your system.
Tuesday, March 05, 2013
Monday, February 11, 2013
Debugging multiple processes and following the children in Eclipse Juno
I guess Eclipse has made it much easier in recent versions of Eclipse and CDT to debug multiple processes and have the debugger follow children. It was actually easier than I had thought it would be to get this functionality in Eclipse Juno. To do so, follow these steps:
- Create your debug configuration, pointing to the project and program you require.
- Ensure that you setup your LD_LIBRARY_PATH in your environment variables as necessary.
- (and here's the really important part) In the Debug Configuration, go to the 'Debugger' tab. You should see a groupbox called 'Debugger Options' containing (at least) two tabs: 'Main' and 'Shared Libraries'. On the 'Main' tab, ensure that you have 'Non-stop mode' and 'Automatically debug forked processes'. In order to get these abilities, you'll need to have both non-stop gdb and multi-process gdb
- As a side note, you may need to also have your debug configuration pointed to a custom gdbinit command file with the following line:
- set follow-fork-mode child
Labels:
cdt,
children,
debbugger,
debug,
debugging,
eclipse,
fork,
gdb,
juno,
multi-process,
multiprocess,
parent
Wednesday, February 06, 2013
Using key gestures with parameterized Commands in WPF is "broken"
Ok, it's not actually broken, it just doesn't work the way I wanted (or expected). Apparently, there's a very good article on why they don't work the way I expected. To be clear, the way I expected them to work was:
- Define the command as a static RoutedUICommand and set the keyboard / mouse gestures I wanted on the command's InputGestures collection.
- Use said command in MenuItems, Buttons etc.
- Automatically have keyboard / mouse bindings setup everywhere (including the nice shortcut text on menu items in context menus / menu bar menus)
Friday, February 01, 2013
Getting the proper Includes to show up in the project explorer in Eclipse with CDT with a cross-compiling project
I finally learned how, and it's thanks to an awesome question posted on stackoverflow.com .
Thursday, January 24, 2013
"Network is unreachable" on an embedded box
We've been working extensively with embedded boxes lately trying to migrate our platform over. One of the programs we've been trying to migrate today was a simple announcer program that sends out a UDP broadcast. On our first go, the program wouldn't work, saying that the "Network is unreachable" when doing a 'perror' after the call to 'sendto'. After much experimentation with various network binding flags, etc, which took the whole day, I went into overtime trying to figure out the problem. Eventually, I got to the point where I inspected the routing tables of the embedded system and was shocked to find .... there was no routing table entry for the default gateway, i.e. 0.0.0.0 destination IP. I'm actually kind of ashamed of how long it took me to find this, but in my defense, I was dealing with a wild mixture of systems and had done a lot of network reconfiguration with the systems and some of the stuff was handled automatically for me by my Ubuntu box, which gave me some inconsistent results at times when experimenting. For my own future reference, here's how I solved the problem:
- Run 'route -n'
- Ensure there's an entry that looks like the following :
- Destination: 0.0.0.0 Gateway: [the desired gateway, e.g. 192.168.10.1] Genmask: 0.0.0.0 Flags: UG, Metric: 0, Ref: 0, Use: 0, Iface: eth0 (or eth2, or whatever you may have)
- If the above entry doesn't exist, add it with the following command:
- sudo route add -net 0.0.0.0 netmask 0.0.0.0 gw 192.168.10.1 dev eth0
Friday, January 18, 2013
Synchronizing with a remote SVN repository
We recently had a double hard-drive failure on our RAID 5 on our main server at work, and we lost our stuff. Our primary backup method of that system had completely failed due to the incompetence of some of the staff in our parent company that was completely beyond our control. It's only by the grace of the fact that our IT guy had an extra weekly backup that we were able to recover as much as we were. That said, it brought to light the need to have our own extra backups of our source code because we can't rely on the people we're supposed to be able to rely on to do the backups for us. We're now going to be creating our own copies of the SVN server on a semi-daily basis, and I've found instructions on how to do it on this awesome StackOverflow post. I'm just sorry I didn't know about this sooner.
Cross-compiling libexpat (and other libraries)
So, lately I've been trying to cross-compile libexpat for a new board with a different architecture from what we typically use at work, and I've been having one heck of a time, until I finally got help online from my question at stackoverflow. Turns out, I just needed to be more specific about my host architecture in the configure command:
./configure --host=arm-none-linux --enable-shared CC=arm-none-linux-gnueabi-gcc CXX=arm-none-linux-gnueabi-g++ AR=arm-none-linux-gnueabi-ar RANLIB=arm-none-linux-gnueabi-ranlib STRIP=arm-none-linux-gnueabi-strip
I'm going to try similar recompilation with other libraries so that I can improve the functionality of our older systems as well.
./configure --host=arm-none-linux --enable-shared CC=arm-none-linux-gnueabi-gcc CXX=arm-none-linux-gnueabi-g++ AR=arm-none-linux-gnueabi-ar RANLIB=arm-none-linux-gnueabi-ranlib STRIP=arm-none-linux-gnueabi-strip
I'm going to try similar recompilation with other libraries so that I can improve the functionality of our older systems as well.
Tuesday, January 15, 2013
Journey to robust Windows Services
Because I have the need for it in several projects, I'm going to be working with Windows Services implemented with .NET quite a bit in the next little while. That said, I'd like to refer to some resources for working with Windows Services:
- The MSDN page on creating windows services
- The MSDN page on debugging a Windows Service
- The MSDN page on installing and uninstalling Windows Services
Also, there are some issues that I ran into while working on my first service. I had originally planned to expose a WCF endpoint through WS-HTTP, however, I can into an unpleasant exception when I tried to do so: AddressAccessDeniedException. Apparently, the cause of this is the fact that http bindings are reserved for processes run as administrators. Fool me once, shame on me. In light of that fact, I'm switching over to using net.tcp for my local Windows Service-hosted WCF service. I'll post more here as I learn it.
Adding the Network Service account to the permissions for a file/folder/registry key etc
I'm currently developing a Windows Service that's to be run under the Network Service account (owing to the fact that it requires substantial network access). I'm just starting to learn how to program Windows Services, so this is very new to me. I just started developing a simple service to start, and when I followed the instructions on this MSDN page, I was surprised when, after trying to start my service, I got the error 005: Permission denied. I later found out that I needed to give the network service account to the folder from which the service was running, i.e. the debug output folder of my project. Doing this isn't as simple as setting the permissions for other users. To add the network service account to the permissions list in Windows 7, do the following :
- Right click on the folder containing the service you want to debug, and go to Properties
- Go to the Security tab, and under the box marked "Group or user names", click on Edit ...
- Under the window that pops up, you'll see another box marked "Group or user names". Underneath that box, click on Add ...
- In the "Select Users or Groups" dialog that pops up, click on the Advanced... button at the bottom left.
- In the advance "Select Users or Groups" dialog that pops up, click on Find Now to find all the users, groups and built in security principals.
- Once the search results are populated, scroll down and select "NETWORK SERVICE" (not "NETWORK") and click on Ok, then Ok again in the Select Users or Groups dialog.
- One you're back to the Permissions window, ensure that you give the Network Service account Full Control over the folder in the Permissions box, then click Ok.
- Click Ok one last time to close the properties for your folder, and you're done.
Sunday, January 06, 2013
Wpf2WinRT: Bindings are not the same!
I've just learned something new about the bindings system in WinRT: they're not the same as Bindings in WPF. Check out the MSDN page for WinRT BindingMode, and you'll see that they're missing a value from WPF: OneWayToSource.
Migrating from WPF to Windows 8
As part of the ongoing development efforts at my company, I'm always researching the latest technologies and developments. My latest endeavour is researching Windows 8 and doing technical feasibility work to find out if it's right for us. On that front, I'm learning how to develop for the Windows 8 runtime in C#. I've got a lot of experience in WPF, and our current Line-Of-Business application is written in WPF, so I'm used to certain things, things which I'm finding no longer hold true in WinRT programming. For example, how resources such as strings are accessed in XAML. For WPF, if I wanted the internationalized string for a label, I'd do something like this :
<Label Text="{x:Static resources:Messages.UserName}"/>
However, the x:Static XAML extension no longer exists. Instead, you have to follow the *very different* ways of accessing string resources on this MSDN document, because the means of accessing resources for a WinRT application are both simpler (in some ways) and more robust, if a little bit confusing at first.
For string (and even other resources, such as images) internationalization in WinRT, what you do is this:
1. Create a folder path for your strings: \Strings\en-US
2. Under the aforementioned folder, create a resources file named Resources.resw (not that it's not .resx, as with previous .NET applications written in Windows Forms, WPF and ASP.NET)
3. Add a new string with the Name "ApplicationName.Text". The ".Text" suffix is very important; you'll see why in a minute.
4. In your XAML, create a TextBox like this:
<TextBlock x:Uid="ApplicationName" Text="" />
The Uid attribute is used for associating controls with resources, according to the MSDN link provided above, and the .Text suffix in the resource Name column, specifies the property to which the resource is linked.
Honestly, I'm not sure I like the way this is going, but if it reduces code clutter, I'm willing to at least give this a try. We'll see how this pans out.
Wednesday, December 19, 2012
Finding the public key and public key token of an assembly for use with InternalsVisibleTo
It seems like one of the most common problems out there when it comes to testing and dealing with strongly-named assemblies is getting the public key and the public key token of a CLR assembly when you want to create test projects for that assembly. The quick and easy way:
1. Ensure that 'sn.exe' is in your path. If it's not, it's usually in the Windows SDK directory, typically in a folder like : C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\sn.exe
2. Open up a command window, and navigate to the directory containing the snk you're signing your assemblies with.
3. sn -p my.snk Public.snk
4. sn -tp Public.snk
...and voila, the program will print out the public key and public key token to the screen for you. The reminder I found this at was here. After you've found the public key, you'll want to paste a line similar to the following in the AssemblyInfo.cs file of the project whose internals you wish to expose:
[assembly: InternalsVisibleTo("MyCompany.ProjectName.Tests,
PublicKey=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")]
Changing the default URI of a WCF web service
I recently returned to one of my previous employers since they lured me away with a better employment offer than I was currently receiving. I'm now placed on a large scale project to revamp our equipment and our software, and improve our software services to the point where we have absolute control and communication with our software out in the field. To that end, I'm presently writing a service that our field personnel's laptops will use to communicate with our home office. I've decided to implement the service in WCF since I've got experience with it and it will be the quickest route to getting a working service deployed. There are other reasons for the choice, but we won't go into those at the moment. One of the things I had forgotten about was the best practice of changing the default namespace of the service away from tempuri.org. I found an article here to remind me of how to do it, so hopefully others will be able to find it as well.
Sunday, September 16, 2012
Previews with a DataContext in WPF
Both the company I currently work for and the previous company I worked for use WPF extensively in some of their products. I recently ran across an incredibly helpful bit of functionality that aids in designing controls and forms on this blog. The TL;DR is that it lets you specify the data context that's supposed to be associated with a window / control, and lets you preview the control at design time using design data. This is useful because it lets you get an idea of what the control is going to look like with real data, and can be especially helpful when trying to size controls on a form, or seeing what lists are going to look like, and will be a real time saver because it means you no longer have to compile and start the application in order to view styles on things like DataTemplates.
Sunday, June 26, 2011
Deleting more Subversion folders
Further to my previous post on deleting subversion folders with powershell, I recently had the need to do the same in bash on linux. Here's a useful little command :
find . -name .svn -exec rm -rf {} \;
Wednesday, October 13, 2010
Determining what ports Tomcat is running on
I've recently had problems connecting to a Tomcat server setup by another developer. In order to troubleshoot these problems, I wanted to use netstat to see what ports were being bound to, but apparently server sockets don't come up by default. If you really want to see what server sockets are in use on your machine, use the following :
The undocumented 't' option will cause netstat to show server sockets.
netstat -lntp
The undocumented 't' option will cause netstat to show server sockets.
Friday, October 01, 2010
Event models in Silverlight vs WPF
To really understand the event model in Microsoft's Silverlight / WPF frameworks, you need to start off with a proper mental model. You can think of the root XML element in a XAML object as being at ground level. Each successive child XML element goes deeper into the ground. With that in mind, there's two terms that are used in both of these frameworks to describe how event handlers propagate between objects : Bubbling and Tunneling. With Tunneling, event handlers start at the root XML element, and "tunnel" deeper into the "earth" (your control stack) until they get to the original source of the element, which is your controls. With Bubbling, event handlers start at the original source of the element (your control which initiated the event), and then "bubble up" to the root control. We use the earth analogy because the terminology goes hand in hand with gravity : tunnelling follows gravity, like digging into the earth, and bubbling goes against gravity, like a bubble coming up to the surface from the bottom of the ocean. I never really had a clear mental model of the Silverlight / WPF event models until right now.
With all that said, there are some differences between Silverlight and WPF that turn out to be very important when it comes to implementing your event handlers, and maintaining compatibility between the two. The biggest difference is that WPF supports both Bubbling and Tunneling events, whereas Silverlights supports only Bubbling events. Keep this in mind if you're designing desktop applications that you might want to port over to web applications at some point
With all that said, there are some differences between Silverlight and WPF that turn out to be very important when it comes to implementing your event handlers, and maintaining compatibility between the two. The biggest difference is that WPF supports both Bubbling and Tunneling events, whereas Silverlights supports only Bubbling events. Keep this in mind if you're designing desktop applications that you might want to port over to web applications at some point
Thursday, September 30, 2010
Holy crap, a Windows ramdisk program that works
In the past, I've had a bit of experience trying to install and run ramdisks in Windows XP, but I never found anything really good. Microsoft provided a ramdisk driver for Windows 2000 that one could get working in XP, but it wasn't really useful because it only provided a maximum of 32 MB of storage (Why ?!). I decided to revisit the issue of ramdisks at work today for Windows 7 because I wanted a way to speed up Visual Studio's caching and other operations (and Eclipse, but that's another matter). After searching around some more, I found a program called ImDisk. The installation is dead easy (if a little lacking in the notification department to tell you it's successfully installed). What's even better, you can make disks of arbitrary size, have it simulate various kinds of devices, and you can setup multiple ramdisks. The only catch is that you have to start the service in Administrator mode, and it's a bit more than trivial, though it is easy using the following steps :
1. Start -> All Programs -> Accessories -> Command Prompt -> Right-click -> Run as administrator
2. sc config imdisk start= auto (note the space between start= and auto, this got me the first time)
3. net start imdisk
4. Open up Control Panel -> ImDisk Virtual Disk Driver
... and have at it!
1. Start -> All Programs -> Accessories -> Command Prompt -> Right-click -> Run as administrator
2. sc config imdisk start= auto (note the space between start= and auto, this got me the first time)
3. net start imdisk
4. Open up Control Panel -> ImDisk Virtual Disk Driver
... and have at it!
Friday, September 17, 2010
Editing your file system mappings for TFS paths
So, as you may or may not know, when using Microsoft Team Foundation Server for version control, TFS maps remote project paths into local file system patmhs for checkout, etc. As I learned today, there are times when you check out the wrong path, and/or map it to the wrong path in the file system. If you ever need to modify or just nuke your file system mappings in TFS, here's how you go about doing it :
Once you've selected your workspace in the dialog that comes up (you'll likely only have one anyway), click on :
... and then select the folder to file system mappings that you want to remove, or create whatever new file system mappings you want right there.
Team Explorer -> Source Control (double click) -> Workspaces (dropdown) -> Workspaces ...
Once you've selected your workspace in the dialog that comes up (you'll likely only have one anyway), click on :
Edit ... -> Working Folders
... and then select the folder to file system mappings that you want to remove, or create whatever new file system mappings you want right there.
Starting a new job ... and a new philosophy
Ok, so I've left my previous employer and started at a new job. This means new domains of knowledge, new tools, and new people. My new employer is a Microsoft-exclusive shop, for almost every aspect of their software. If you've read this blog in any significant amount in the past, you'll know that I'm really not a Microsoft fan. In fact, I hate almost everything that's ever come out of Redmond, because for the most part it's deficient in how it's been engineered, and not as usable as other products out on the market (or even a lot of open source products). Therefore, the tone of this blog is probably going to change somewhat, and I'll be ranting and raving like a lunatic on things I'm learning about dealing with Microsoft products more often. It's going to be interesting.
Subscribe to:
Posts (Atom)