473,404 Members | 2,178 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

web service consumer compiler error "type or namespace...could not be found"

I have experience with Windows programming but I am new to Web programming and I am trying to create a web service. I am doing this with Notepad and the .NET SDK. I have recently built a Windows Server 2003 machine and activated IIS. I am using the default directory structure ("inetpub\wwwroot") for the default web site. In trying to learn web service programming I have tried using multiple examples on the Web to create Web services this way. But I get a compiler error every time similar to the one below...

Expand|Select|Wrap|Line Numbers
  1. Server Error in '/ws1' Application.
  2. --------------------------------------------------------------------------------
  3.  
  4. Compilation Error 
  5. Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 
  6.  
  7. Compiler Error Message: CS0246: The type or namespace name 'FirstService' could not be found (are you missing a using directive or an assembly reference?)
  8.  
  9. Source Error:
  10.  
  11.  
  12.  
  13. Line 1:    <%@ Page Language="C#" %>
  14. Line 2:  <%@ Import Namespace="FirstService" %>
  15. Line 3:    <script runat="server">
  16. Line 4:    void runSrvice_Click(Object sender, EventArgs e)
  17.  
  18.  
  19. Source File: c:\inetpub\wwwroot\ws1\WebApp.aspx    Line: 2
  20.  
  21. ...
  22.  
  23. Version Information: Microsoft .NET Framework Version:1.1.4322.2443; ASP.NET Version:1.1.4322.2407 
Here are the steps I am going through to create a web service. This particular one is an example from a codeguru.com article.
  1. I have created the "FirstService.asmx" file and put it into the folder "wwwroot\ws1" on the server.
  2. I have created the "WebApp.aspx" file and put it into the folder "wwwroot\ws1" on the server.
  3. I used wsdl.exe to create "FirstService.cs", using "http://myserver/ws1/FirstService.asmx?wsdl".
  4. I used csc.exe to create "FirstService.dll" using "FirstService.cs".
  5. I copied the DLL to the server. I had no "bin" folder in the "wwwroot" folder, so I created it myself. I put the DLL in there but it didn't work. I have also tried putting the DLL into the "wwwroot/ws1" folder, as well as creating a "wwwroot/ws1/bin" folder and putting the DLL there. I have also tried right-clicking on "ws1" in IIS, clicking "Properties", then clicking the "Create" button so the folder icon turns into an icon that looks like a gear.

No matter where I put the DLL file, or where I create a "bin" folder, I keep getting the compiler error. Why is this happening?

I have tried different examples from the Web, but here is the code for one of them...

FirstService.asmx
Expand|Select|Wrap|Line Numbers
  1.   <%@ WebService language="C" class="FirstService" %>
  2.  
  3.   using System;
  4.   using System.Web.Services;
  5.   using System.Xml.Serialization;
  6.  
  7.   [WebService(Namespace="http://myserver/ws1/")]
  8.   public class FirstService : WebService
  9.   {
  10.       [WebMethod]
  11.       public int Add(int a, int b)
  12.       {
  13.           return a + b;
  14.       }
  15.  
  16.       [WebMethod]
  17.       public String SayHello()
  18.       {
  19.           return "Hello World";
  20.       }
  21.   }
  22.  
WebApp.aspx
Expand|Select|Wrap|Line Numbers
  1.   <%@ Page Language="C#" %>
  2.   <script runat="server">
  3.   void runSrvice_Click(Object sender, EventArgs e)
  4.   {
  5.       FirstService mySvc = new FirstService();
  6.       Label1.Text = mySvc.SayHello();
  7.       Label2.Text = mySvc.Add(Int32.Parse(txtNum1.Text),
  8.                     Int32.Parse(txtNum2.Text)).ToString();
  9.   }
  10.   </script>
  11.   <html>
  12.   <head>
  13.   </head>
  14.   <body>
  15.   <form runat="server">
  16.     <p>
  17.         <em>First Number to Add </em>:
  18.         <asp:TextBox id="txtNum1" runat="server"
  19.              Width="43px">4</asp:TextBox>
  20.     </p>
  21.     <p>
  22.         <em>Second Number To Add </em>:
  23.         <asp:TextBox id="txtNum2" runat="server"
  24.              Width="44px">5</asp:TextBox>
  25.     </p>
  26.     <p>
  27.         <strong><u>Web Service Result -</u></strong>
  28.     </p>
  29.     <p>
  30.         <em>Hello world Service</em> :
  31.         <asp:Label id="Label1" runat="server"
  32.              Font-Underline="True">Label</asp:Label>
  33.     </p>
  34.     <p>
  35.         <em>Add Service</em> :
  36.         & <asp:Label id="Label2" runat="server"
  37.                Font-Underline="True">Label</asp:Label>
  38.     </p>
  39.     <p align="left">
  40.         <asp:Button id="runSrvice" onclick="runSrvice_Click"
  41.              runat="server" Text="Execute"></asp:Button>
  42.     </p>
  43.   </form>
  44.   </body>
  45.   </html>
  46.  
May 19 '10 #1
1 3596
Frinavale
9,735 Expert Mod 8TB
I don't really know what to suggest as a way to fix this....
Have you seen this MSDN walkthrough for Creating an XML Web Service Using C++ and the CLR?
May 19 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Sundial Services | last post by:
I recently brought an old application out of mothballs and launched it under PHP5, only to get this message: Fatal Error: Class '1' not found It was clearly somehow an /execution/ time...
3
by: hazz | last post by:
Is Activator.CreateInstance(t,BindingFlags.Public | BindingFlags.InvokeMethod | BindingFlags.CreateInstance, null, args, null) appropriate given the following; ...
3
by: Lowell | last post by:
Windows XP SP2 + Symantec AV + VS 2003 with .NET Framework 1.1 IIS won't load or run existing ASP.NET applications and VS can't create or load web projects (HTTP/1.1 500 Server Error). Event...
2
by: PKuhne | last post by:
When pasting this code from the MS small Business Accounting Beta Concepts manual: DIM skdAssembly as = .LoadFrom(installpath.ToString()) the IDE shows : "Type 'Assembly' not defined" and...
1
by: Brian Begy | last post by:
Anyone seen this? "Type mismatch could be due to the mixing of a file reference with a project reference " We have solution we are trying to upgrade to VS 2005. We have about 10 projects in...
0
by: sebnunes | last post by:
Hi all, I have a strange behavior here. I'm debugging a web page. When I set a breakpoint in the file the debugger hits the breakpoint but if I try run further the page crashes and The error...
0
by: veaux | last post by:
I see a few references to the above error, but haven't found why it may be happening in my case. Have an Access 2003 DB and am trying to import a text file into a new table. I'm just using the text...
2
by: yawnmoth | last post by:
When I visit the following webpage: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Test</title> </head> <body> <div id="demo">this is a test...</div>
0
by: RCM | last post by:
I am really eager to quit the Microsoft world and get into LAMP. For the immediate future I can't do the Apache part, so I am at least trying to get PHP up and running under IIS to learn it. I...
8
by: charli | last post by:
Error 3265, "Item cannot be found in the collection corresponding to the requested name or ordinal" code programatically opens a query using ADOX and changed the sql Dim cat As New...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.