| |
Symptoms
When opening a solution with a web project in Visual Studio, you receive the following error in a popup dialog:
System.Runtime.InteropServices.COMException
Cause
Apparently, this is an issue with IIS configuration. I'm not quite sure why we get such a useless error message, tho. Very annoying. If you're not sure you're seeing this with a web project, load the solution and, when the error pops up, look at the status bar. You should see a "loading" message with the path of the problematic solution.
Resolution
- Ignore the errors and let the solution load
- In the Solution Explorer, right-click on the project that failed to load, click Edit <project file>
- Scroll down to the bottom of the file and look for <UseIIS>True</UseIIS> (located at \Project\ProjectExtensions\VisualStudio\FlavorProperties\WebProjectProperties\UseIIS)
- Repace True with False
- Save and close the project file
- In the Solution Explorer, right-click on the project, click Reload Project
More Information
- Applies to: Visual Studio 2005, 2008
Mon
Aug
18
2008
ZoomIt
If you're using Windows and aren't using ZoomIt, you're missing something. We all run into those scenarios where we see an image, but it's not quite as big as we'd like. For those situations, Microsoft gives us ZoomIt. There's not a whole lot to explain here. Download it, run it, and press Ctrl+1 to zoom in. From there, move your mouse around to reposition the view and press up and down to zoom in and out further. There are also options for drawing, typing, and even a timer. These are for presentations and I don't use them much, but I'm sure others find them more useful. If you haven't tried it before, ZoomIt is definitely worth at least trying once. You can even run it from the web to stay up-to-date with the latest release.

I'm a month and a half late, but the Resharper nightly builds are back! I guess I stopped checking after not seeing any movement for a while. I'm glad to see some activity, tho. This is the most beneficial add-in to Visual Studio I've seen; especially as a productivity geek. What I've been most surprised about is the overall quality of the nightly builds in the past 6 months. Simply outstanding. If you're asking yourself whether to give it a shot or not, I say go for it. You're likely to run into minor issues, but if my experiences are indicative of how well they manage their day-to-day development, this is a team with a very tight ship. I always grab the latest and try to update a few times a week, depending on what I'm in the middle of. If you're not quite as confident as I am, grab a "works here" release. I'm sure you'll see how great this tool is in relatively short time. An absolute must-have for all code-focused developers.

Microsoft has officially posted a Surface order form. Not quite the user friendly experience I had hoped for, but I can't say I'm surprised. The order form is split into three sections: commercial hardware, development hardware and software, and services, which includes installation, maintenance, warranty, and shipping costs.
- Commercial Hardware: $12,500
- Development Hardware & Software: $15,000
I have to say I was surprised to see the dev version being more than the unit itself. I guess I say this because I heard there are local development tools you'll install on a development machine, not a Surface machine. I guess I shouldn't be too surprised. It'll be interesting to see if/how this takes off. I did get to play with a unit last month, but haven't had a chance to really post my thoughts. They're popping up all over the place, tho, so I think more and more people will be getting a chance to play with them.
Speaking of which, if you're in the San Jose area and/or plan on going to the IDesign WCF Master Class in October, I will most likely be showing it to some people then. That's assuming the unit is still there, but I'm sure it will be. I just hope they put some more apps on it. It'd be nice to see something new.
To summarize my experience on it, I'd say that it was nice, but there's still something left to be desired. There's a lot of potential, tho. One of the biggest things is going to be showing people how they can use it. Some people have the vision it takes to see how this will enhance their apps, but others need to see something a little closer to what they're doing to get that understanding. I do think this is going to be a great platform, tho. We just need to see lower costs, a great (not good, but great) API, and a more accessible API. If this remains a niche, I don't see it going far. This is something Microsoft needs to make every developer feel like s/he has access to. Unfortunately, that may take ~3-5 years.

Nothing new here. I just wanted to save this code snippet because it's popped up a few times in the past year and I have to go find it over and over. At least this will make it a little easier for me. This is by no means an authoritative reference -- it's simply what I have used. If you know of something I'm missing, please let me know.
First, you'll need to import the Win32 LogonUser() function:
using System.Runtime.InteropServices;
[DllImport("advapi32.dll", SetLastError=true)]
public static extern bool LogonUser(string lpszUsername, string lpszDomain, string lpszPassword, int dwLogonType, int dwLogonProvider, out IntPtr phToken);
The only question you probably have is about the logon type and provider parameters. The only provider I know of is the default, 0, which uses "negotiate" (Kerberos, then NTLM) for Windows XP/Server 2003 and later machines. Windows 2000 defaults to NTLM. If you don't know the difference, let me know and I'll explain that in more detail. Here are a list of logon types:
- Interactive (2) -- Intended for interactive use (duh) with something like terminal server or executing a remote shell. This type caches credentials for disconnected operations.
- Network (3) -- Intended for high performance servers to authenticate plain-text passwords.
- Batch (4) -- Intended for batch servers, which act on behalf of the user without his/her direct intervention. Typically used to process many plain-text auth attempts at a time.
- Service (5) -- Intended for service accounts, which have the "service" privilege enabled -- don't ask me what that is because I don't know.
- Unlock (7) -- Intended for GINA DLLs (whatever that is) that will interactively use the machine. This type includes some auditing.
- Clear Text (8) -- Intended for double-hop impersonation scenarios where credentials will be sent to the target server to allow it to also impersonate the user. As I understand it, this is what IIS "Basic" authentication uses. To perform a double-hop, you'll actually have to do a few other things. I won't get into that here, but let me know if that'd be of interest.
- New Credentials (9) -- Clones current credentials and uses new credentials for outbound connections. Supposedly, this doesn't work with the default provider -- it requires the WINNT50 provider, whatever that is.
The following is a list of the supported providers. I don't know anything about the non-default ones, but figured I'd list them for completeness..
- Default (0) -- "Negotiate" (Kerberos, then NTLM) for Windows XP/Server 2003 and later; NTLM for Windows
- NT 3.5 (1)
- NT 4.0 (2)
- NT 5.0 (3) -- Required for the "new credentials" logon type.
Next, well... just use it. As you can see, the last parameter in the LogonUser() function is an out parameter for a token which represents the user. This is key. All you need to do is initialize a WindowsIdentity instance with this token and you're well on your way.
using System.Security.Principal;
public static WindowsIdentity GetIdentity(string domain, string userName, string password)
{
IntPtr token;
bool success = LogonUser(userName, domain, password, 2, 0, out token);
return (success) ? new WindowsIdentity(token) : null;
}
Pretty simple. Of course, we still aren't there, yet. Now that you have the identity, you most likely want to impersonate it. Luckily, this is a simple 2-liner... well, technically two 1-liners. I should also say that, if you want to do impersonation with an already-obtained WindowsIdentity (and you don't have a password), you'll start here.
ImpersonationContext context = GetIdentity("mydomain", "me", "mypassword").Impersonate();
context.Undo();
That's it. Enjoy!
I just found something very useful in Visual Studio 2008 a few days ago. I've been using MSTest for about 2 years, now, and one thing I liked initially was the wizard that would generate test stubs for you. I liked that it gave you somewhere to start. After using it more and more, I began to hate it, tho. I guess the problem is I'm anal about how my code looks and I end up changing everything. So, I started generating the classes myself. The only problem with this approach is the private member accessor the wizard generates is no longer there. Not desirable, but there's an easy fix: run thru the wizard quickly and delete the methods. At least, that was until a few days ago. In VS08, all you need to do is open the file of the desired class, right click the background, select the Create Private Accessor menu item, and then pick the test project to add it to. VS has so many menu items, it's easy to overlook the really useful ones, so I figured this one was worth sharing. Hopefully, Sara Ford is listening.

I've talked about my desire for a keyboard layout standard, especially with respect to laptops. Heck, I've even tossed the idea of buying a MacBook out the window because of their horrible keyboard. For me, this is the first thing I look at when considering a new laptop. Since last year, when I bought my first Lenovo, I've been griping about the ridiculous Fn key, which is on the wrong side of the Ctrl key. That's not my only complaint, but it's the biggest one. The next is the Esc key that's above F1, which causes me to press F1 occasionally. There's a few more, but I'll spare you. Luckily, Lenovo fans have a small glimmer of hope: Lenovo keyboard layout survey. This was recently mentioned on the Lenovo Design Matters blog . Go, go, GO!!! Unfortunately, this doesn't explicitly ask about the Fn key, but I definitely left a comment about it. Please take the survey, but if you contribute to them screwing up the 3x2 Insert/Delete, Home/End, Page Up/Down keys, I'm coming after you.


I hate self-promotional posts, which is why I never announced my move from Geeks w/ Blogs to my personal server and why I never moved to MSDN blogs, but I feel like this one at least serves a purpose for other bloggers...
I'm doing something I've been meaning to do for a while: update the URL of my feeds. I use FeedBurner, which has been nice, but I've always hated using a FeedBurner URL. I thought about creating a reverse proxy to do it, but never felt the sheer need to spend the time to do that. Luckily, FeedBurner has done the work for me. I'm not sure if this is a new service or not, but I have to thank Scott Watermasysk for pointing me to FeedBurner MyBrand. This feature allows you to specify a custom domain for your feeds. While not the complete flexibility I'd like, it at least gives me the ability to maintain a controlled domain name in case I ever decide to self-host my feed.
With this, the following are my new feed URLs:
I'm probably going to be scrapping my feedback and ratings blogs. Feedback is too tedious because I have too many ideas and ratings gets annoying because I put everything in Netflix and sometimes IMDB. I'm looking for a good platform to support this type of blog, but haven't found one, yet. I'll probably just create some mashup using Netflix's feed.
Here's some "Yellow Submarine" talk about the Xbox... by the way, if you didn't catch that reference, then you're missing out on Mac Break Weekly , which is entertaining to all. But, I digress... The Xbox 360 has been dropping its price over the past few months, it seems like. I look at this and think about how long it's been since there's been a serious upgrade and I have to wonder if we might be seeing the very typical price drop before a new release. I have absolutely 0 knowledge about anything related to the Xbox and don't even own one, but I do admit that I'd be very intrigued by a new platform... probably enough to actually go out and buy one, which means a lot to me since I'm not a gamer. We'll see. Supposedly there will be something coming out at E3.

David Kean mentions his thoughts on string handling and I have to say I completely disagree. He states that you should always return String.Empty instead of null. I hate this. An empty string and what equates to "no value," by definition, mean two different things. David, on the other hand, contends that the two should always be treated as the same. To be clear, I'm not saying the two should never be handled the same. On the contrary, I believe that's the norm... and rightfully so. With that, however, there are still cases where they need to be handled differently. Besides, the benefits you get from returning an empty string are immediately invalidated when considering consistency principles.
I'd even go as far as to say, returning empty strings promotes bad practices. Why? Because the developer then treats what is returned as a non-null value. While this isn't a problem, it typically goes further. The same developer will start assuming all methods that return strings act the same way. Let's not forget what they say about people who make assumptions... For this reason, I believe it's a good practice to always use String.IsNullOrEmpty() to validate string values, no matter what you think/know is returned.
I could list a number of what-if scenarios depicting why this is so important, but I won't. It should be pretty clear. Let's face it, we've all fallen victim to a null reference exception, which is essentially what happens when you assume a variable has a value. Clarify your assumptions with good exception handling.
Lastly, one other reason I like null over empty strings is because it uses less memory. Yes, this is very trivial, but it's true. The bottom line is that, whether you return null or empty string, you have to treat it as if it were null. For this reason alone, I believe it's cleaner to simply use null. Using empty strings is a hack, in my mind, unless it really means something different than "no value."
|
|
|
|