Showing posts with label Microsoft. Show all posts
Showing posts with label Microsoft. Show all posts

Wednesday, December 23, 2009

Visual Studio 2008: Application Cannot Start

 

I got this annoying error, every time I tried to run my VS2008 SP1 in Administrator mode (which is needed to avoid the “Failed to map the path '/'.” when running an EPiServer site in visual studios web server). Some google searches brought to outdated microsoft material – but luckily also to Alex Riley’s helpful post: https://www.21concepts.com/Blog/EntryId/10/Visual-Studio-2005-2008-The-application-cannot-start.aspx.

On my win7 x64, it turned out (thanks procmon) that my visual studio was looking for C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\dte80a.olb – and once I copied that from C:\Program Files (x86)\Common Files\microsoft shared\MSEnv all was well.

Thursday, September 3, 2009

HTTP Error 500.19 – Internal Server Error

A couple of times I have now run into this wonderful error after setting up a new EPiServer CMS site on a newly installed machine. However, I don’t think it’s specific to EPiServer CMS – but can occur in any asp.net application. The error message looks like this:

The requested page cannot be accessed because the related configuration data for the page is invalid.

As with many other microsoft errors, this is completely misleading (unless you’ve been messing up your configuration data – but this is a newly installed site).

The error message tries to clarify itself further:

Module
IIS Web Core

Notification
BeginRequest

Handler
Not yet determined

Error Code
0x80070021

Config Error
This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault="Deny"), or set explicitly by a location tag with overrideMode="Deny" or the legacy allowOverride="false".

Config File
\\?\C:\EPiServer\Sites\MyEPiServerSite3\web.config

 

By now, you are probably half way into your web.config, and trying to remember where that mystical machine.config is located. You might even have started to go through all directories on your machine in the search for another web.config thats somehome conflicting. Stop looking. It’s not conflicting. And relax – you didn’t do anything wrong…yet.

One of 2 things have likely happened:

1) IIS was installed after ASP.NET, and it’s not really sure what to do with ASP.NET code. Solution: In a command prompt run aspnet_regiis. It’s typically found in “%windows%\Microsoft.Net\Framework\v2.0.50727\aspnet_regiis –i”. Note that you need to run it as Administrator on Vista and Windows 7. In fact, running this can be a cure for many initial web server errors on newly installed asp.net applications.

2) You are running Windows 7 or Windows Server 2008 and you selected the default install of IIS7.5. For reasons known only to Microsoft, they decided that ASP.NET shouldn’t be included in a default installation. My personal theory is that the guy who made that wise call is probably the same guy who decided to remove the ability to drag files onto a command-prompt in Vista. And before that was the mastermind behind the “Copy File” feature in any earlier version of Windows. But I digress :-) Solution in this case is easy – Open Control Panel | Programs | Turn Windows Features on and off, find IIS and enable ASP.NET:

image

Hit “Ok”, wait for half an hour and then see your web application spring to life. Enjoy!

Friday, October 24, 2008

PDC 2008 - Here I Come

Travel time again. Destination Los Angeles. There I'll spend the next week learning everything that Microsoft will try to teach me - and probably then some.
See you all at the parties! I'll be the guy in a gray t-shirt, with a laptop and a high-tech phone. If you find me, I'll buy you a beer or something!

Wednesday, January 23, 2008

WebResource.axd gives 404

My colleague, Michael Knudsen, has been struggling with a customer & partner for several hours now with an annoying problem on an EPiServer 4.62 site just moved to a production server. Finally, after browsing through half the web and getting valuable feedback from most supporters / developers known to man, a simple solution was discovered.

To save other people the agony he's gone through he persuaded me to post the solution here...

 

Problem symptoms:

When clicking on a button in a webform the following javascript error occurs: Webform_Postbackoptions is undefined. A little simple debugging later it turns out that the page in fact did get a 404 when requesting a web resource (javascript) from the server - which is where the method is defined.

<script src="/WebResource.axd?d=14ZW9Y1So0D_eFk6_pguuw2&amp;t=633359999849186250" type="text/javascript"></script>

If you don't know what webresources does there's a good intro here. This problem had us all stunned for a while - lots of theories going through our heads...."It must be a web.config problem - some handlers are interfering with each others", "Perhaps asp.net isn't properly installed on the server", "But it's working on my machine", "Is this using AJAX?", "Can't we just put the dev. server where it works into production", etc. were some of the thoughts going through our heads as the problem took over our common sense.

 

Solution:

Uncheck this checkbox in IIS:

 

 

un-checked_wildcard

Monday, March 19, 2007

J# to the Rescue

I've always wondered what the purpose of J# was. I mean, Java and C# are quite similar, so I'd suppose that if people (for some weird reason) would prefer to code Java (instead of drinking it), they'd do so purely because they wanted to work within the java environment and the java VM. If they eventually decided to overcome their Microsoft fears and turn to the .NET framework, C# would seem like a natural choice. So it has indeed been puzzling my mind why J# is included with Visual Studio.
But today I found a use for it, and it really saved my day!
The next programming assignment (after the Connect 4 game) in the AI class I'm attending was handed out today and even though the assignment looks fairly interesting (implementation of DPLL algorithm to check satisfiable of Boolean expressions in CNF form) the source code that we are supposed to base our solution on was pure old-fashioned java. Of course, we are free to choose which language to solve the task with, but if we choose anything else than Java we'll have quite a programming task ahead of us, just making the code-base that we're supposed to extend on. After first considering learning java I was happy to remember that there might be another way out :-)
With shaking hands and a heart beating way too fast I started VS2005 and created a J# Class Library project. Then I copied the original source java code into newly created .jsl files with identical file names (copy+paste). As you probably can imagine the excitement was overwhelming when I tried to build for the first, but surprisingly there was only very few compiler errors...
A java HashMapSet that I discovered should be changed to an ArrayList in .NET, a couple of framework methods where Mocca (sorry, Java) used wrong casing, and finally a method that appeared to have been renamed in .NET, and I was good to go.
All that was left to do then, was to create a C# project in the same solution, reference the J#-library and I was good to go - well almost. In order to inherit one of the java-classes and override the methods we're supposed to implement we also needed to reference "vjslib" in our c# project in order to recognize the parameters to the methods we were overriding.

All in all I was very happily surprised to find that J# actually cured my pain.

Now we (me, Thomas and Peter) just need to actually solve the programming assignment we were given :-)

Thursday, March 15, 2007

Performance: ArrayList vs List<>

Quite recently I was trying to optimize/cleanup some .net 2.0 code that had recently been moved from framework 1.1. Naturally various old fashioned Arraylists was scattered over most of the code, and I began the tedious work of tidying up and using generic lists.
As I was doing this I began to wonder how big a performance difference there actually is with various list types, and I decided to investigate this.
The three list types I decided to check were these:

  • ArrayList. Leftover from .net 1.0, basically a dynamically growing array of objects. Everything has to be boxed to an object in order to use this.
  • List<>. The generic List in 2.0. For valuetypes, this doesn't box them, but stores them quite effiecently.
  • Normal arrays. For comparison.

So far I've only decided to test adding/setting the values. I expect similar measurements can be made with regards to removing, accessing and finding. Later on it might also be interesting to look at searching and sorting.
I decided to compare how the ArrayList and ListType does, when adding strings, integers and finally when adding strings after the list has been initialized to the expected size. Just for fun I also tested how the ArrayList performed in framework 1.1.

For the integer tests I added the number 42 to the collections, and for the string tests I added "42".
These are the results I got(times are in ms, running on my laptop):


Items 1 mil 2 mil 4 mil 8 mil
ArrayList Add (int) 1.1 200 500 1121 3000
ArrayList Add (int) 150 450 1100 2600
ArrayList Add (string) 1.1 40 150 250 530
ArrayList Add (string) 70 150 290 630
ArrayList Add (string) PreSize 20 60 110 230
List Add (int)
30 50 120 230
List Add (string)
60 120 280 520
List Add (string) PreSize 20 50 100 200
Array (int) Set 10 20 30 60
Array (string) Set 20 30 70 170

Graphically the data looks something like this:


The conclusions I draw from this is as follows:
  • Always use arrays or List's when possible, when working with valuetypes. ArrayLists are naughty. The big overhead is probably due to the boxing that takes place (an Int32 object has to be created for every number, and a reference to it is stored in the ArrayList).
  • When working with reference-type data (like strings) it's typically not worth the effort to change it to Lists unless you are dealing with really big amounts of data. The List is only around 110 ms faster than the arraylist when dealing with 8 mil. items and both seem to scale linearly.
  • When possible it really does help a lot to initialize your list or ArrayList to the expected size. It makes the performance approach that of a normal array.
  • When Microsoft claims that they've improved performance a great deal for collection-types in framework 2.0, it's only true for the "new" types like List. There's almost no difference in ArrayList performance!

Tuesday, March 6, 2007

MOSS vs EPiServer

Here's another reason for always making sure your feed-reader is up to speed. Today I had almost missed this great post by Patrick Tisseghem because I had forgotten to update the url to his feed. Luckily I got tipped off (thanks, Jesper!).
I already know EPiServer quite well - due to my attachement to the "MondoSearch for EPiServer" project. And just a week ago I spend all day getting an intriguing presentation of our other product suite Ontolica's upcoming version for MOSS. As you can imagine I read Patricks post carefully - it's always interesting to get his view on things. And the geek-cruise does sound like a lot of fun (Hint, Hint)!

Wednesday, February 28, 2007

Loaderlock hell!

I recently installed VSTS and I'm still trying to learn my way around it.
One thing I noticed when using it was that I kept getting a "Loaderlock" MDA (Managed Debugging Assistant) whenever I tried to run a piece of interop'in code in debug mode. This was getting quite annoying, and it didn't seem like there was any problem in the code - rather in Visual Studio.
Naturally I started googling the problem and I found several places saying that all I had to do was to go to the "Debug | Exceptions" and turn off Loaderlock for the Managed Debugging Assistants (true, there was also a ton of other advices, like modifying the registry or installing vs service packs, but none of them seemed to do the trick). Unfortunatly my visual studio does not have "Exceptions" in the debug menu - or so it would seem....
Luckily my friend Moshe came to the rescue and found out that even though there's no menu-item called "Exceptions" in the debug menu, the Customize dialog will proof that there's supposed to be. And when we investigate further we found the keyboard shortcut to open it: CTRL+ALT+E.
After using this shortcut I was finally able to turn off the MDA that was annoying me in the first place. I wonder what actually caused it...

Thursday, February 15, 2007

Improving MOSS Search

One of my colleagues, Lars Fastrup, has started a really nice blog around all the work our Ontolica team is doing in relation to improve the usability and functionality in MOSS 2007.
Recently Lars posted some really nice screenshots of the upcoming version of Ontolica, that'll probably wake the interest with most experienced MOSS users!
His announcement of a lightweight version of Ontolica introducing wildcards as a long-lost search feature in MOSS has certainly made quite a buzz already through many a weblog.

Well done, Lars and welcome to the blogging sphere :-)

Friday, January 26, 2007

On-the-fly conversion of MSOffice to raw text

So, this is what I needed the HTTPModule for: a HTTPModule that on the fly converts office (and other weird formats) to text/html. I can imagine several scenarios where this can come in useful (but I'll keep all the great ideas to myself for now).
The POC is something like this: a user requests a non-HTML document (office, pdf, etc) located on a website with "convert=true" in the querystring (http://myserver/test.doc?convert=true). Then the document is automatically converted to text and returned.

In order to do this we'll use ifilters, and to easily access them from C# I found this neat little library by Eyal Post on codeproject.

The code for my module is here:


using System;
using System.Web;
using EPocalipse.IFilter;
using System.IO;

namespace Allan.Tools
{
public class IFilterModule : IHttpModule
{

public void Init(System.Web.HttpApplication application)
{
application.AuthorizeRequest +=
new EventHandler(this.Application_AuthorizeRequest);
}


private void Application_AuthorizeRequest(object sender, System.EventArgs e)
{
HttpApplication app = ((HttpApplication)(sender));
HttpContext context = app.Context;

if (context.Request.QueryString["convert"] != null)
{
TextReader tr = new FilterReader(context.Request.PhysicalPath);
string s = tr.ReadToEnd();
tr.Close();
context.Response.Write(s);
context.Response.End();
}
}


public void Dispose()
{
}
}
}


In order to build it, download Eyal's library and reference it in the project. Then after building the module include it in your web.config like this:



<httpModules>
<add type="Allan.Tools.IFilterModule,IFilterHTTPModuleTest" name="IFilterModule"/>
</httpModules>


Enjoy!

Thursday, January 25, 2007

Update: The Poker Challenge

I now have some more exciting details to share on the upcoming Poker challenge (although dates are still unknown).

I decided to change the strategy a bit and instead of a web-service solution (sorry, microsoft buzz word dept.) go with a more object oriented approach.
Those of you who participated in Microsoft's .NET Terrarium might recognize the path I'm planning...
I will on this blog release a poker library, which includes all the classes needed for a nice game of poker (Texas Hold'em). It'll have Card class, Game class (for keeping track of players and betting), CardCollection (that can calculate what kind of a hand you have), etc. It will even have a Player class - but this is where you come in! That class will be abstract. So, the challenge is to use make your own Player class, inheriting from the base Player class, then code the behavior that makes your poker player the best in the bunch. While developing your player you can try it using a small test-stub I'll include, and when done you simply upload the dll to a website (details follow later). Then, we'll hold match(es), monitor them online real-time (hopefully) and find a winner!
Still havn't heard from anybody willing to sponsor any winnings - but there is still time.

Wednesday, January 24, 2007

Permissions. Can't live with them, can't remove them

Here's an annoying little problem that has been pestering my life for a good day or so. On a newly installed win2k3 server with SQL Express 2005 I was trying to install the Sitecore Demo-site "Printers Inc.". Since the demo-site uses attached databases to SQL Express 2005 it was supposedly fairly easy to install: unpack a zip file, setup IIS, set the right login/password for your connectionstring in a config file.
All done, and try to open the site, but get greeted with this message:

Server Error in '/' Application.

Unable to open the physical file "D:\sites\Sitecore\MySite\Databases\sc53Master_Data.mdf". Operating system error 5: "5(Access is denied.)".
An attempt to attach an auto-named database for file D:\sites\Sitecore\MySite\Databases\sc53Master_Data.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.


Okay...Looks like a permissions thing I thought...So I hurry and give ASPNET and NETWORK SERVICE users full rights on the entire site, and set it to propagate rights to children (security, who needs it anyway?!). Still the same problem....At this point I actually start reading the error message more carefully..Oh, it actually suggest 3 possible error scenarios...well - let me see: It's on a local disk, so forget about the UNC thing. A visit to SQL Server management studio proofs that there's no database with the same name (why would there be? it's a brand new server). And I had just made sure that the permissions were right.
At this point I naturally went to the no.1 problem-fix with microsoft products - but even a full reboot didn't seem to do the trick...Now what?! Checked with the local SQL-server wizards and our sysadmin guru....posted the problem on SDN5 Forum...still no luck.
After wasting too much time I (we) reached the point of desperation where you try out stuff that just doesn't make sense in trying to solve this problem - like setting up the SQL Express service to run as "Local System" instead of "Network Service". And what do you know - it paid off...all of a sudden everything worked splendidly. Still doesn't make sense to me - Network Service had full permissions for the databases....arggh.