Search This Blog

Monday, June 25, 2012

Getting started with WCF - A Security Issue

Most of the free documentation I've been reading on WCF starts with a first "Hello World" application you try and create with WCF wherein you set up a contract, service, and host and then develop a client to call that host which returns a simple text string (e.g., "Hello WCF").

Most of this free documentation came out when WCF was first introduced, before the introduction of the Vista OS and Windows 7, and implicitly assumes that you're coding under credentials with admin rights on your machine.

The first roadblock I ran into, then, was a security access violation with an error message that read like:

"HTTP could not register URL http://+:800/.  Your process does not have access rights to this namespace (see http://go.microsoft.com/fwlink/?LinkID=70353 for details).

Having run into this sort of issue before my immediate response was to try running the binaries under my machine's sysadmin account, but it still didn't work.

It turns out that listening on an HTTP port is considered a restricted operation in MS post-XP OS's, so if you want to do this using your standard dev account you'll need to explicitly elevate its rights to include listening on specific HTTP ports.  The NETSH command to do this for me was:

netsh http add urlacl url=http://+:8000/user=graperpc\dgraper

You can then check the current status of listening rights by entering:

netsh http show urlacl

Friday, April 27, 2012

Extremely slow response with a VS2010 solution

I copied a solution from my dev environment into a production environment and noted an extreme decrease in responsiveness ... e.g., a five second delay between a keypress and its appearing on the screen; 30 seconds plus to go from designer view to code view, etc.

The solution was pretty simple (although it destroys all my breakpoints) -- delete the SUO file for the project so that VS2010 has to build a new one.  Once that was done, performance was normal.

Tuesday, March 6, 2012

Converting everything in a file to lowercase with GVIM

To do it as a "replace":

:%s/[A-Z]/\L&/g

The obverse (to convert all to uppercase):

:%s/[A-Z]/\U&/g

Or, simply type:

ggVGu

Friday, November 4, 2011

Error 1001. The specified service has been marked for deletion

During windows services development there are periods during the final deployment process where I'm installing and uninstalling services pretty rapidly on a server and I occasionally run into this message: "Error 1001. The specified service has been marked for deletion." This error message will cancel the installation and, if you Google around for cures to this problem, the general consensus is to reboot the system.

The systems I work on require extensive permissions from a lot of people/departments to reboot, bringing development to a halt, so I found an easier way to get around the problem. It turns out that the error message is actually complaining that "services.msc" is currently open (in my case, I've left the server manager app open to list current service statuses), so stopping this process (again in my case, simply closing server manager) allows the service to be installed.

Thursday, September 22, 2011

Glitch in setting up a setup-deployment project for 64-bit apps in Visual Studio 2010

I have a windows service that was originally developed for 32-bit machines that I converted to 64-bit. The original setup/deployment project would not compile properly, though, and I would get this error message when attempting a build under Visual Studio 2010:

"File '64bitWindowsService.exe' of project output 'Primary output from 64bitWindowsService (Active)' targeting 'AMD64' is not compatible with the project's target platform 'x86'"

Getting past this problem was easy: Examine the properties of the setup project and change its "TargetPlatform" setting from 'x86' to 'x64'"

The setup/deployment project would then build OK but when I would try and do an install thru Visual Studio (by right-clicking on the project and selecting 'Install') I'd get another error message:

Error 1001: Exception occurred while initializing the installation: System.BadImageFormatException: Could not load file or assembly 'file:///C:\Program Files\Microsoft\Setup1\64bitWindowsService.exe' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Here the solution came from resetting the "Platform Target" of the windows service from "x64" to "Any CPU" (right click the windows service project, select "Properties", and click on the "Build" tab). Once that is set it seems to build and install OK.

Friday, August 26, 2011

Removing a Visual Studio 2010 solution from TFS source control

A Google search on this brought up a lot of intimidating-looking solutions requiring text-editing the ".sln" file, but a simpler and easier solution was available in the VS2010 interface itself.

- Select the solution in the Solution Explorer
- Click on the "File" menu item
- Click on "Source Control"
- Click on "Change Source Control"

Select the solution from the datagrid, then click on "Unbind"

Monday, August 1, 2011

Images and CSS missing from IIS7 website





I'm moving a website from IIS6 running on a Windows 2003 server to IIS7 running on a Windows 2008 server and was having a fairly smooth time of it until I first tried to view the default web page from the local host. It looked like only the controls specifically updated by ASP.NET were being shown -- all the static content, including images, were missing and and the css files were clearly not applying any formatting.

The problem was straightforward and could be traced to my installion of IIS7: compared to IIS6, IIS 7 offers such a higher level of control and granularity in its installation that I neglected to specifically enable "static content" in the web server. I'd assumed, and you know what happens when you assume.

By going into control panel and asking to add "Windows Features," and then updating the web server role, the missing option presented itself pretty clearly as "not installed." After installing it, the website worked pretty much as it did before.

































x