473,799 Members | 3,053 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Server Error in '/' Application - Novice

Hi there,

I am trying to call a C# web service from an aspx page, I have the asmx
file, a user control file ascx and the aspx file. I have verified that the
web service is returning correct values from the service, however when I try
to load the aspx page it falls over in a cruumbling heap! Could someone tell
me what I am doing wrong as I know that I am close to getting this thing
working.

Thanks in advance for your answer

Sean
Error messages and source code below ------------------------------
Compilation Error
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.

Compiler Error Message: CS0246: The type or namespace name 'Service1' could
not be found (are you missing a using directive or an assembly reference?)

Source Error:
Line 7: private void Button1_Click(o bject sender, System.EventArg s e)
Line 8: {
Line 9: Service1 currSvc = new Service1();
Line 10: double dRate = currSvc.Convers ionRate(currFro m.CurrencyCode,
currTo.Currency Code);
Line 11: if (dRate < 0)

Source File: e:\inetpub\wwwr oot\Currency1\c urrconv.aspx Line: 9


!--- aspx page

private void Button1_Click(o bject sender, System.EventArg s e)
{
Service1 currSvc = new Service1();
double dRate = currSvc.Convers ionRate(currFro m.CurrencyCode,
currTo.Currency Code);
if (dRate < 0)
lblConversion.T ext = "Error Occured";
else
lblConversion.T ext = "" + txtAmount.Text + " " + currFrom.Curren cyCode +
"(s) =" + Convert.ToStrin g(dRate * Convert.ToDoubl e(txtAmount.Tex t)) + " " +
currTo.Currency Code;

}

!--------------- web service
<%@ WebService Language="c#" Class="Currency NS.Service1" %>
using System;
using System.Web;
using System.Web.Serv ices;
using System.Net;
using System.IO;
using System.Text;
namespace CurrencyNS
{
[WebService]
public class Service1 : System.Web.Serv ices.WebService
{
[WebMethod]
public double ConversionRate( string From, string To)
{
HttpWebRequest req;
HttpWebResponse res;
StreamReader sr;
string strResult;
string fullpath;
char[] separator = {','} ;
double dRate=-1;

fullpath = "http://finance.yahoo.c om/d/quotes.csv?s=" + From + To +
"=X&f=sl1d1t1c1 ohgv&e=.csv";

try
{
req = (HttpWebRequest ) WebRequest.Crea te(fullpath);
res = (HttpWebRespons e) req.GetResponse ();
sr = new StreamReader(re s.GetResponseSt ream(), Encoding.ASCII) ;
strResult = sr.ReadLine();
sr.Close();
string[] temp = strResult.Split (separator) ;

if(temp.Length >1)
{
string strRate = temp[1];
//We only show the relevant portions .
dRate = Convert.ToDoubl e(strRate);

}
}
catch(Exception )
{
dRate = -1;
}
return dRate;
}
}

}
Nov 18 '05 #1
2 1739
SSW
try instantiating Service1 as below in Button1_Click(o bject sender,
System.EventArg s e) as below.

CurrencyNS.Serv ice1 currSvc = new CurrencyNS.Serv ice1();

Ur code will look some thing like...

private void Button1_Click(o bject sender, System.EventArg s e)
{
CurrencyNS.Serv ice1 currSvc = new CurrencyNS.Serv ice1();
double dRate = currSvc.Convers ionRate(currFro m.CurrencyCode,
currTo.Currency Code);
if (dRate < 0)
lblConversion.T ext = "Error Occured";
else
lblConversion.T ext = "" + txtAmount.Text + " " + currFrom.Curren cyCode
+
"(s) =" + Convert.ToStrin g(dRate * Convert.ToDoubl e(txtAmount.Tex t)) +
" " +
currTo.Currency Code;
}

HTH

sswalia
MCSD, MCAD, OCA
"sean" <se********@sho psmart.com.au> wrote in message
news:e1******** ******@TK2MSFTN GP12.phx.gbl...
Hi there,

I am trying to call a C# web service from an aspx page, I have the asmx
file, a user control file ascx and the aspx file. I have verified that the
web service is returning correct values from the service, however when I try to load the aspx page it falls over in a cruumbling heap! Could someone tell me what I am doing wrong as I know that I am close to getting this thing
working.

Thanks in advance for your answer

Sean
Error messages and source code below ------------------------------
Compilation Error
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.

Compiler Error Message: CS0246: The type or namespace name 'Service1' could not be found (are you missing a using directive or an assembly reference?)

Source Error:
Line 7: private void Button1_Click(o bject sender, System.EventArg s e)
Line 8: {
Line 9: Service1 currSvc = new Service1();
Line 10: double dRate = currSvc.Convers ionRate(currFro m.CurrencyCode,
currTo.Currency Code);
Line 11: if (dRate < 0)

Source File: e:\inetpub\wwwr oot\Currency1\c urrconv.aspx Line: 9


!--- aspx page

private void Button1_Click(o bject sender, System.EventArg s e)
{
Service1 currSvc = new Service1();
double dRate = currSvc.Convers ionRate(currFro m.CurrencyCode,
currTo.Currency Code);
if (dRate < 0)
lblConversion.T ext = "Error Occured";
else
lblConversion.T ext = "" + txtAmount.Text + " " + currFrom.Curren cyCode +
"(s) =" + Convert.ToStrin g(dRate * Convert.ToDoubl e(txtAmount.Tex t)) + " " + currTo.Currency Code;

}

!--------------- web service
<%@ WebService Language="c#" Class="Currency NS.Service1" %>
using System;
using System.Web;
using System.Web.Serv ices;
using System.Net;
using System.IO;
using System.Text;
namespace CurrencyNS
{
[WebService]
public class Service1 : System.Web.Serv ices.WebService
{
[WebMethod]
public double ConversionRate( string From, string To)
{
HttpWebRequest req;
HttpWebResponse res;
StreamReader sr;
string strResult;
string fullpath;
char[] separator = {','} ;
double dRate=-1;

fullpath = "http://finance.yahoo.c om/d/quotes.csv?s=" + From + To +
"=X&f=sl1d1t1c1 ohgv&e=.csv";

try
{
req = (HttpWebRequest ) WebRequest.Crea te(fullpath);
res = (HttpWebRespons e) req.GetResponse ();
sr = new StreamReader(re s.GetResponseSt ream(), Encoding.ASCII) ;
strResult = sr.ReadLine();
sr.Close();
string[] temp = strResult.Split (separator) ;

if(temp.Length >1)
{
string strRate = temp[1];
//We only show the relevant portions .
dRate = Convert.ToDoubl e(strRate);

}
}
catch(Exception )
{
dRate = -1;
}
return dRate;
}
}

}

Nov 18 '05 #2
Hi there,

I tried to add the code as you recommended CurrencyNS.Serv ice1 currSvc = new
CurrencyNS.Serv ice1(); the program still give me an error. I have pasted the
code from the aspx page into the post, could you tell me if I am missing
something?

Sean

!----------------------------------------------

<%@ Import Namespace="Syst em.Drawing" %>

<%@ Register TagPrefix="uc1" TagName="CurrCo des" Src="currcodes. ascx" %>
<script Language="C#" runat="server">
private void Button1_Click(o bject sender, System.EventArg s e)
{
CurrencyNS.Serv ice1 currSvc = new CurrencyNS.Serv ice1();
double dRate = currSvc.Convers ionRate(currFro m.CurrencyCode,
currTo.Currency Code);
if (dRate < 0)
lblConversion.T ext = "Error Occured";
else
lblConversion.T ext = "" + txtAmount.Text + " " + currFrom.Curren cyCode +
"(s) =" + Convert.ToStrin g(dRate * Convert.ToDoubl e(txtAmount.Tex t)) + " " +
currTo.Currency Code;

}
</script>
<html>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0 ">
<form id="Form1" method="post" runat="server">
<table style="WIDTH: 685px; HEIGHT: 160px">
<tr>
<td colspan="2" align="left"><a sp:Label id="Label4" runat="server"
Font-Bold="True">Cur rency Conversion Tool</asp:Label></td>
</tr>
<tr>
<td style="WIDTH: 269px"><asp:Lab el id="Label1" runat="server"
Width="193px">C onvert From:</asp:Label></td>
<td><uc1:CurrCo des id="currFrom" runat="server"> </uc1:CurrCodes></td>
</tr>
<tr>
<td style="WIDTH: 269px"><asp:Lab el id="Label2" runat="server"
Width="177px">C onvert To:</asp:Label></td>
<td><uc1:CurrCo des id="currTo" runat="server"> </uc1:CurrCodes></td>
</tr>
<tr>
<td style="WIDTH: 269px"><asp:Lab el id="Label3" runat="server"
Width="155px">A mount:</asp:Label></td>
<td><asp:TextBo x id="txtAmount" runat="server"> </asp:TextBox></td>
</tr>
<tr>
<td colspan="2" align="middle"> <asp:Button id="Button1" runat="server"
Text="Convert" OnClick="Button 1_Click"></asp:Button></td>
</tr>
<tr>
<td colspan="2" align="middle"> <asp:Label id="lblConversi on" runat="server"
Width="451px"></asp:Label></td>
</tr>
</table>
</form>
</body>
</html>

"SSW" <fr************ @hotmail.com> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
try instantiating Service1 as below in Button1_Click(o bject sender,
System.EventArg s e) as below.

CurrencyNS.Serv ice1 currSvc = new CurrencyNS.Serv ice1();

Ur code will look some thing like...

private void Button1_Click(o bject sender, System.EventArg s e)
{
CurrencyNS.Serv ice1 currSvc = new CurrencyNS.Serv ice1();
double dRate = currSvc.Convers ionRate(currFro m.CurrencyCode,
currTo.Currency Code);
if (dRate < 0)
lblConversion.T ext = "Error Occured";
else
lblConversion.T ext = "" + txtAmount.Text + " " + currFrom.Curren cyCode +
"(s) =" + Convert.ToStrin g(dRate * Convert.ToDoubl e(txtAmount.Tex t)) + " " +
currTo.Currency Code;
}

HTH

sswalia
MCSD, MCAD, OCA
"sean" <se********@sho psmart.com.au> wrote in message
news:e1******** ******@TK2MSFTN GP12.phx.gbl...
Hi there,

I am trying to call a C# web service from an aspx page, I have the asmx
file, a user control file ascx and the aspx file. I have verified that the web service is returning correct values from the service, however when I try
to load the aspx page it falls over in a cruumbling heap! Could someone

tell
me what I am doing wrong as I know that I am close to getting this thing
working.

Thanks in advance for your answer

Sean
Error messages and source code below ------------------------------
Compilation Error
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.

Compiler Error Message: CS0246: The type or namespace name 'Service1'

could
not be found (are you missing a using directive or an assembly reference?)
Source Error:
Line 7: private void Button1_Click(o bject sender, System.EventArg s e)
Line 8: {
Line 9: Service1 currSvc = new Service1();
Line 10: double dRate = currSvc.Convers ionRate(currFro m.CurrencyCode,
currTo.Currency Code);
Line 11: if (dRate < 0)

Source File: e:\inetpub\wwwr oot\Currency1\c urrconv.aspx Line: 9


!--- aspx page

private void Button1_Click(o bject sender, System.EventArg s e)
{
Service1 currSvc = new Service1();
double dRate = currSvc.Convers ionRate(currFro m.CurrencyCode,
currTo.Currency Code);
if (dRate < 0)
lblConversion.T ext = "Error Occured";
else
lblConversion.T ext = "" + txtAmount.Text + " " + currFrom.Curren cyCode +
"(s) =" + Convert.ToStrin g(dRate * Convert.ToDoubl e(txtAmount.Tex t)) + "

" +
currTo.Currency Code;

}

!--------------- web service
<%@ WebService Language="c#" Class="Currency NS.Service1" %>
using System;
using System.Web;
using System.Web.Serv ices;
using System.Net;
using System.IO;
using System.Text;
namespace CurrencyNS
{
[WebService]
public class Service1 : System.Web.Serv ices.WebService
{
[WebMethod]
public double ConversionRate( string From, string To)
{
HttpWebRequest req;
HttpWebResponse res;
StreamReader sr;
string strResult;
string fullpath;
char[] separator = {','} ;
double dRate=-1;

fullpath = "http://finance.yahoo.c om/d/quotes.csv?s=" + From + To +
"=X&f=sl1d1t1c1 ohgv&e=.csv";

try
{
req = (HttpWebRequest ) WebRequest.Crea te(fullpath);
res = (HttpWebRespons e) req.GetResponse ();
sr = new StreamReader(re s.GetResponseSt ream(), Encoding.ASCII) ;
strResult = sr.ReadLine();
sr.Close();
string[] temp = strResult.Split (separator) ;

if(temp.Length >1)
{
string strRate = temp[1];
//We only show the relevant portions .
dRate = Convert.ToDoubl e(strRate);

}
}
catch(Exception )
{
dRate = -1;
}
return dRate;
}
}

}


Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3723
by: Novice | last post by:
Hey all, I'm trying to write a proxy server so that I can capture all data sent from my web browser to any web server and then capture the response from the server and send that back to the browser. However, I've encountered a strange problem where the browser will not load the data sent to it from my proxy server. I'm successfully able to capture the data sent from the browser, then I'm able to capture the data sent back from the web...
0
870
by: sean | last post by:
Hi I am trying to execute an ms access stored query, I keep getting an error when I try to execute the code.I know that I am missing some declarations in my script, I am just not sure on the syntax. Sean error -----------------------------------
16
2311
by: Paul S. Natanson | last post by:
What is a Null Reference error and how do I fix it? My newly installed VB.Net2003 gives me a "Microsoft Development Environment" error message box EVERY time I try to run/start ANY project - even very simple ones. The error says: "An unhandled exception of type 'System.NullReferenceException' occurred in
17
5104
by: Jon B | last post by:
Hi All! I have a ASP.NET 2.0 site that works on the Windows 2000 Server. However, when I tried to view this site on my local Windows XP machine, I get "Server Unavailable". If I switch the Windows XP IIS back to ASP.NET 1.1 then I get the Configuration Error (which is understandable because I'm trying to run an ASP.NET 2 site with 1.1 framework). I can however view other ASP.NET 1.1 sites on my local Windows XP machine. It's only the...
4
1291
by: kaosyeti | last post by:
hey... i know NOTHING about sql server, .net framework or probably anything else on sql monster. i am a novice access user, self-taught for about 9 months now and have only a basic understanding of vba. that being said, i need some help...8) i have a web site that i used to routinely visit for my job that performs calculations for monthly car payments based on about 20 user-entered fields. the problem is that about 3 months ago, it...
1
1552
by: G.Fink.Nottle | last post by:
Hello, Being a bit of a SQL Server novice, need some advice with the following situation. Server A and Server B have SQLServer 2000 based databases. The vendor of the application/system has implemented their own replication process to ensure the 2 databases are in sync. However, there is no clustering with virtual IP addresses implemented. So to an external client/db, it is 2 identical databases with the same name on 2 distinct...
3
2010
by: Jason Richmeier | last post by:
I looked for a more appropriate newsgroup for this question but I didn't see much of anything (something more specific to Windows Media Services). I have a server with Windows Media Services. When I try to establish an ASP ..NET application and open a page in this application, an attempt is made to open the page using Media Player (I am guessing that the server thinks the page should be served as a streaming media clip). Is there a way...
3
4550
by: quest007 | last post by:
Hi! This might be a very simple query for all those working on Coldfusion but difficult for novice like me. I have to fetch data from the SQL Server database which is on a remote server. Can someone help me with the code that I need to write in the <CFQUERY> tag. I have written the code as: <cfquery name="qry_fetch_user" datasource="234.208.90.15" dbname="myDatabaseName" > If I execute this, it displays the error: CFML Runtime Error -...
2
1159
by: Tom | last post by:
I am a novice .NET developer, using Web Dev. 2005 Express version. I found some code dor doing CAPTCHA verification and it works great on my local machine. I FTP all files to my web server and when I run the default.aspx I get the error below...The hosting company (Verio) got rid of the web.config file and the page ran. Problem is now the CAPTCHA image is not displaying...and when I added the System.Windows.Forms namespace to display a...
0
9538
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10473
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10249
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10219
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9068
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5461
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5584
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4138
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3755
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.