Web service reference changed when upgrading project from VS2008 to VS2010

Posted Thursday, June 10, 2010 3:00 PM | Feedback (0), Filed Under .NET Web Visual Studio Buggs Visual Studio 2010 Web Services

When we recently upgraded our project from VS 2008 to VS 2010 everything went just fine. The project was converted and the conversion log didn't report any errors. Two days ago we deployed our web application to the production servers, that's when the problems started to show up.
The application couldn't connect to several services. The error was that the Web Reference URL to the services had been changed from https to http. We hadn’t caught this error in our test environment because the https restriction was not there in that environment.
WsHttpsToHttp

So if you have converted a project from Visual Studio 2008 to Visual Studio 2010 and you have any web service references that goes to a https endpoint, be sure to check that it hasn’t been changed to https.

I have filed a bug report to the Visual Studio team at Microsoft, so if you get the same problem go there and vote it up, then maybe we can get a solution to it sooner then later.

EPiServer Community cache notification

Posted Thursday, June 03, 2010 8:08 AM | Feedback (0), Filed Under .NET developement EPiServer Cache notification EPiServer Community

Yesterday we ran into an odd problem with our load balancers. To give you some history, we use EPiServer Community to handle users and store user attributes. The application works in both http and https depending on where on the site you are at the moment.

You can imagine the look on our faces 
huu

We had just deployed our application to a load balanced test environment when the application started to act strange. The problem was that when we saved attributes to a users profile in http the attributes where not updated when going into a part of the site that ran under https. At first we thought that our services where badly configured. As it turned out, we where being sent to different servers depending on the protocol we where using, if we used http we where served by server 1 but when we went to a https page we were served by server 2! The load balancer that should have used sticky sessions was obviously not doing it’s work. But that is a hole other can of worms. That lead us into suspecting that there was a cache not being invalidated correctly. We used the EPiServerRemoteEventsListener tool to check if the  EPiServer Cache notification was running as it should. And it did.

After some digging we found that the episerver.common.config file is the key to all caching goodness. The key parts are the cache section. This section should look the same in all servers that are going to be part of the cache notification network.

<episerver.common>
  <siteHosts>
    <add name="Default" hostUrl="*" connectionStringName="EPiServerCommon" />
  </siteHosts>
  <sites>
    <site hostName="Default">
      <cache defaultProvider="EPiServerCacheExpirationProvider">
        <providers>
          <add name="EPiServerCacheExpirationProvider" type="EPiServer.Common.Cache.CacheExpirationProvider, EPiServer.Common.Cache" />
        </providers>
      </cache>

As all other major bugs, we found ours in a very small but significant part of the configuration

<replication>
  <subscriber serverName="WebServer1" siteName="MySite" port="4123" alternatePort="4321" broadcastAddress="10.130.251.255" />
</replication>

Server 2

<replication>
  <subscriber serverName="WebServer2" siteName="MySite" port="4123" alternatePort="4321" broadcastAddress="10.130.251.255" />
</replication>

It turns out that we had the same value for serverName in all servers. The name is as it says the actual DNS name of the server as you would have called it if you where to remote into it. In the other hand, the siteName attribute should be set to the same value in all servers, the same for port, alternatePort and broadcastAdress,  which by the way we couldn’t find any documentation on whether we could change it to another address, the same goes for EPiServers own cache notification.

Anyway after changing this setting the app started to work as expected. We where still being redirected to different servers on protocol basis but the cache was being invalidated correctly at both servers.

Visual Studio hangs when opening certain files

Posted Sunday, January 17, 2010 11:33 PM | Feedback (1), Filed Under Web Visual Studio Buggs Tips

Today I’ve restarted Visual Studio 2008 some 8 or 9 times, oh, did I say restarted, I meant killed the devenv.exe process. The reason of this is that on every one of those occasions I was opening a .aspx or .master file in my web project, when Visual Studio suddenly freezes and stops responding.
I could explain how I felt but it wouldn’t be suitable for minors reading this.

Since I have never experienced this before and my laptop has an SSD drive my first thought was that some memory banks where getting corrupted. I threw away that thought when I, without any problems could open the same file in Notepad++ and gVim. So it was back to MS.
I finally found an old post from 2009 that hinted that a component installed called "Microsoft Visual Studio Web authoring Component"  could be the crook behind all evil. I actually don’t have a clue of what good this component does, if any, for me it was most bad.

Anyway I uninstalled the Microsoft Visual Studio Web authoring Component and my headache was gone.

!!! The bundled mysql.rb driver has been removed from Rails

Posted Monday, January 11, 2010 12:43 AM | Feedback (5), Filed Under Ruby Rails MySql

So I’m trying to get the Rails rake db:migrate command to work and just getting the same output each time

“!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql."

After tearing my hair, installing and reinstalling the MySQL 2.8.1 gem goggling for answers for an hour I finally found the answer that helped me. The in the reply from by Hao Zhao, he pointed out that the 2.2.2 version of Rails does not support the MySQL 5.x client!

The solution to this is this:

  1. Download an older version of the MySQL client library from  http://instantrails.rubyforge.org/svn/trunk/InstantRails-win/InstantRails/mysql/bin/libmySQL.dll
  2. Copy the downloaded file to c:\Your Ruby install folder\bin


That’s it! I could go mad right now but I’m too happy to finally have found this.

In my case I didn’t have that file at all, thus the “mysql.rb driver has been removed” warning. !It’s not the gem that is missing, it’s the driver! Bad rails bad!
I hope this can help some others in despair.

Btw my system is a Windows 7 x64 with MySQL 5.1, Rrails 2.3.4 and mysql-2.8.1-x86-mswin32.gem

SQL Server Manager select and kill process query

Posted Wednesday, November 25, 2009 3:16 PM | Feedback (2),

Who is hogging the database process? This question can be hard to answer if you don’t have the right tools to view the Activity monitor. I got recently this problem.

SQL is an amazing language and MS SQL server can give you answers to about anything threw SQL queries. The query that answered my questions was this:

SELECT db_name(dbid) as DatabaseName, count(dbid) as NoOfConnections,
loginame as LoginName
FROM sys.sysprocesses
WHERE dbid > 0
GROUP BY dbid, loginame

this query will show you a table over the databases, the number of active connections and the logins that are using them. After that you can run another query to kill all connections to a specific database like so:

DECLARE @DatabaseName nvarchar(50)
SET @DatabaseName = N'myDatabaseName'
--SET @DatabaseName = DB_NAME()

DECLARE @SQL varchar(max)
SET @SQL = ''

SELECT @SQL = @SQL + 'Kill ' + Convert(varchar, SPId) + ';'
FROM MASTER..SysProcesses
WHERE DBId = DB_ID(@DatabaseName) AND SPId <> @@SPId

-- SELECT @SQL
EXEC(@SQL)
DEALLOCATE my_cursor

There are some other tricks at http://www.kodyaz.com/articles/kill-all-processes-of-a-database.aspx.

Create GUID tool for Visual Studio

Posted Tuesday, September 29, 2009 9:32 PM | Feedback (2), Filed Under .NET developement Visual Studio

@rewdboy a coworker had a small problem earlier today, he just couldn't find the good old Create GUID application that is packaged with Visual Studio.

The tool has not been removed from the IDE it’s still there. It depends on what development type you have chosen. You may remember the first time you start Visual Studio after installing it prompts you asking what type of development you are planning to do. There are six choices, the one that I know has the Create GUID tool is the Visual C"# Development Settings, If you went with Web Development Settings you are missing this feature.

Import and Export Settings Wizard

There are two ways of getting hold of this nice tool. The first one is to reset all your IDE to the C# Development settings.

To do this just go to Tools -> Import and Export settings and then mark the Reset all settings radio button in the wizard after that you can chose between the settings above.

This may be ok if you have just installed Visual Studio. But if you have been working with it for some time and have customized and tweaked it to perfection you may want to go for the second approach.

And that is to just add the command button to your toolbar. This is probably the preferred way to do this. But it’s not that intuitive. Here is how:

It’s just as you normally would add a tool to the toolbox Tools –> Customize

Tools-Customize

Then we come to the not so intuitive part. The Create GUID tool is hidden as External Command 1. Just drag the control to your toolbar and voala! 
Why they have chosen to hide it this way we may never know. But now you know how to get it.

Tools Customize Commands 

Highlight current line Visual Studio custom theme

Posted Friday, September 18, 2009 4:12 PM | Feedback (1), Filed Under .NET developement Refactoring ReSharper

A nice feature of ReSharper, besides all refactoring goodness, is the ability to highlight the current line. That is the line where the caret is, is highlighted. This makes it so much easier to get back and find where you last left off or where the search result is when searching around in Visual Studio.

If you have ReSharper it’s easy to do this. Just go to ReSharper’s options menu ReSharper –> Options. And from there go to the Editor menu and select “Highlight current line”

image

If you have a customized color theme like I do, then you can change the default highlight color by going into Visual Studio’s own Options menu, Tools –> Options, and then change the Item background color for the ReSharper Current Line.

image

Here is the result for my theme.

image

By the way if you like this theme you can download it from here. It also contains the Dina font by Jørgen Ibsen. A font that is made for readability. The theme is a modded version of Oren Ellenbogen's Dark Scheme.

Enjoy!

Plans are useless, but planning is indispensable

Posted Friday, September 11, 2009 10:41 AM | Feedback (2), Filed Under developement

This is just a short post but with a big statement made by Dwight D. Eisenhower:

“I have always found that plans are useless, but planning is indispensable.”

This statement was valid in that time and is still relevant. We as developers know that there are only three things that are certain in life, death, taxes and changing requirements.

So to remind me I’ve made a small desktop background with this wise words. Grab a copy if you like it.

Plans_are_useless_thumb

Disable Development Web Server when attatching to process

Posted Tuesday, September 01, 2009 11:07 AM | Feedback (3), Filed Under .NET developement

After I reinstalled my computer to use Windows 7 my Visual Studio 2008 began to start the Cassini development server included in Visual Studio 2008.
This has been annoying me for quite some time, not that it’s any problem just that it gets started by default without me asking for it.

So I went and disabled it. I did it by formatting the ProjectName.csproj.user file. This file is meant to work as the web.config and machine.config files, where the machine.config has all settings but they are overridden by the settings that match in the web.config file, where the csproj.user being the equivalent to the web.config file. 
The way to do it It’s not that intuitive, it may be easier ways but here is a step by step of how I did it.

To do this from Visual Studio you first have to unload your project to be able to look at your project file.

UnloadProject

Then go way to the bottom of the file until you find the <WebProjectProperties> </WebProjectProperties> element. Copy the contents of it.

Open your ProjectName.csproj.user file, this is only needed if you are working in a project shared by several developers and don’t want them to get your settings also.

Paste the part that you copyed from the ProjectName.csproj file into the corresponding <WebProjectProperties> </WebProjectProperties> element. In my case it’s the

<AlwaysStartWebServerOnDebug>False</AlwaysStartWebServerOnDebug>
<EnableWcfTestClientForSVC>False</EnableWcfTestClientForSVC>
<UseIIS>False</UseIIS>
<AutoAssignPort>False</AutoAssignPort>
<DevelopmentServerPort></DevelopmentServerPort>
<DevelopmentServerVPath></DevelopmentServerVPath>
<IISUrl></IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>True</UseCustomServer>
<CustomServerUrl>http://localhost/</CustomServerUrl>

The part to take notice of here is the <AlwaysStartWebServerOnDebug>False</AlwaysStartWebServerOnDebug>. Here you want the value to be set to False.
If that doesn’t work try setting the <UseCustomServer> to True and point at your localhost url or the path you have set as your host name.

There are other ways people have done this but from the projects property window, but that window does not have the setting for disabling the dev. server while debugging.

image

Is page in Edit mode

Posted Monday, August 31, 2009 2:40 PM | Feedback (0), Filed Under .NET C# developement EPiServer

I’m writing an account registering control. This control needs to show the user how to register for a new account. But when modifying this control the pages editors must be able to see the hole flow. So I went looking for a smart way to display the control in two ways depending on the context it’s being viewed in. I found Jacob Khan’s blog post in EPiServer labs that seemed nice but I didn’t get it to work.

The thing I ended doing was to get the id from the query string, and parsing it to a PageReference to check if it contains a workID. The ID in the QueryString has both the pages ID and the current version being edited, for example 1563_1234 where 1563 is the pages ID and 1234 is the current version.

If the QueryString contains a work page ID it means that I'm currently looking at a draft, not the published page, hence I´m in Edit mode.

When getting the WorkID of a PageData object that's published you will get 0 as a result, and that's what I'm testing against.

Here is the code

public bool IsPageInEditMode
{
    get
    {
        PageReference pageVersionReference = PageReference.Parse(Request.QueryString["id"]);
        if (pageVersionReference.WorkID > 0)
            return true;
        return false;
    }
}
Technorati-taggar: ,