.NET (296) administrative (41) Ajax (42) AngularJS (2) ASP.NET (144) bicycle (2) books (180) browser (8) C# (134) cars (1) chess (28) CodePlex (10) Coma (8) database (47) deployment (3) Entity Framework (2) essay (112) flash/shockwave (2) flex (1) food (3) friend (2) game (20) idea (5) IIS (8) javascript (82) LInQ (2) Linux (6) management (4) manga (42) misc (672) mobile (1) movies (91) MsAccess (1) murder (2) music (64) mysql (1) news (100) permanent (1) personal (68) PHP (1) physics (2) picture (307) places (12) politics (13) programming (504) rant (120) religion (3) science (43) Sharepoint (3) software (58) space (1) T4 (2) technology (11) Test Driven Development (4) translation (2) VB (2) video (97) Visual Studio (44) web design (46) Windows API (8) Windows Forms (3) Windows Server (5) WPF/Silverlight (63) XML (11)

Tuesday, July 04, 2006

Transforming inline webservice code into codebehind

I somehow managed to add to one of my Visual Studio 2005 Web Projects a webservice that had the code written "inline" meaning the <%@ WebService Language="C#" Class="WService"%> tag, followed by the C# code. While Visual Studio has a decent Intellisense functionality in asmx files, ReSharper doesn't. So I felt the need to move the code into a codebehind file. You would think that adding the Codebehind="WService.amsx.cs" would be enough. No, it isn't! As the codebehind model for VS is to have the codebehind in a compiled dll, an error like "Cannot create type WService" will annoy the hell out of you. The solution is to add the cs file into the App_Code directory.
<%@ WebService Language="C#" Class="WService" Codebehind="~/App_Code/WService.asmx.cs"%>

No comments: