473,390 Members | 1,042 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,390 software developers and data experts.

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(object sender, System.EventArgs e)
Line 8: {
Line 9: Service1 currSvc = new Service1();
Line 10: double dRate = currSvc.ConversionRate(currFrom.CurrencyCode,
currTo.CurrencyCode);
Line 11: if (dRate < 0)

Source File: e:\inetpub\wwwroot\Currency1\currconv.aspx Line: 9


!--- aspx page

private void Button1_Click(object sender, System.EventArgs e)
{
Service1 currSvc = new Service1();
double dRate = currSvc.ConversionRate(currFrom.CurrencyCode,
currTo.CurrencyCode);
if (dRate < 0)
lblConversion.Text = "Error Occured";
else
lblConversion.Text = "" + txtAmount.Text + " " + currFrom.CurrencyCode +
"(s) =" + Convert.ToString(dRate * Convert.ToDouble(txtAmount.Text)) + " " +
currTo.CurrencyCode;

}

!--------------- web service
<%@ WebService Language="c#" Class="CurrencyNS.Service1" %>
using System;
using System.Web;
using System.Web.Services;
using System.Net;
using System.IO;
using System.Text;
namespace CurrencyNS
{
[WebService]
public class Service1 : System.Web.Services.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.com/d/quotes.csv?s=" + From + To +
"=X&f=sl1d1t1c1ohgv&e=.csv";

try
{
req = (HttpWebRequest) WebRequest.Create(fullpath);
res = (HttpWebResponse) req.GetResponse();
sr = new StreamReader(res.GetResponseStream(), 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.ToDouble(strRate);

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

}
Nov 18 '05 #1
2 1722
SSW
try instantiating Service1 as below in Button1_Click(object sender,
System.EventArgs e) as below.

CurrencyNS.Service1 currSvc = new CurrencyNS.Service1();

Ur code will look some thing like...

private void Button1_Click(object sender, System.EventArgs e)
{
CurrencyNS.Service1 currSvc = new CurrencyNS.Service1();
double dRate = currSvc.ConversionRate(currFrom.CurrencyCode,
currTo.CurrencyCode);
if (dRate < 0)
lblConversion.Text = "Error Occured";
else
lblConversion.Text = "" + txtAmount.Text + " " + currFrom.CurrencyCode
+
"(s) =" + Convert.ToString(dRate * Convert.ToDouble(txtAmount.Text)) +
" " +
currTo.CurrencyCode;
}

HTH

sswalia
MCSD, MCAD, OCA
"sean" <se********@shopsmart.com.au> wrote in message
news:e1**************@TK2MSFTNGP12.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(object sender, System.EventArgs e)
Line 8: {
Line 9: Service1 currSvc = new Service1();
Line 10: double dRate = currSvc.ConversionRate(currFrom.CurrencyCode,
currTo.CurrencyCode);
Line 11: if (dRate < 0)

Source File: e:\inetpub\wwwroot\Currency1\currconv.aspx Line: 9


!--- aspx page

private void Button1_Click(object sender, System.EventArgs e)
{
Service1 currSvc = new Service1();
double dRate = currSvc.ConversionRate(currFrom.CurrencyCode,
currTo.CurrencyCode);
if (dRate < 0)
lblConversion.Text = "Error Occured";
else
lblConversion.Text = "" + txtAmount.Text + " " + currFrom.CurrencyCode +
"(s) =" + Convert.ToString(dRate * Convert.ToDouble(txtAmount.Text)) + " " + currTo.CurrencyCode;

}

!--------------- web service
<%@ WebService Language="c#" Class="CurrencyNS.Service1" %>
using System;
using System.Web;
using System.Web.Services;
using System.Net;
using System.IO;
using System.Text;
namespace CurrencyNS
{
[WebService]
public class Service1 : System.Web.Services.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.com/d/quotes.csv?s=" + From + To +
"=X&f=sl1d1t1c1ohgv&e=.csv";

try
{
req = (HttpWebRequest) WebRequest.Create(fullpath);
res = (HttpWebResponse) req.GetResponse();
sr = new StreamReader(res.GetResponseStream(), 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.ToDouble(strRate);

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

}

Nov 18 '05 #2
Hi there,

I tried to add the code as you recommended CurrencyNS.Service1 currSvc = new
CurrencyNS.Service1(); 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="System.Drawing" %>

<%@ Register TagPrefix="uc1" TagName="CurrCodes" Src="currcodes.ascx" %>
<script Language="C#" runat="server">
private void Button1_Click(object sender, System.EventArgs e)
{
CurrencyNS.Service1 currSvc = new CurrencyNS.Service1();
double dRate = currSvc.ConversionRate(currFrom.CurrencyCode,
currTo.CurrencyCode);
if (dRate < 0)
lblConversion.Text = "Error Occured";
else
lblConversion.Text = "" + txtAmount.Text + " " + currFrom.CurrencyCode +
"(s) =" + Convert.ToString(dRate * Convert.ToDouble(txtAmount.Text)) + " " +
currTo.CurrencyCode;

}
</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"><asp:Label id="Label4" runat="server"
Font-Bold="True">Currency Conversion Tool</asp:Label></td>
</tr>
<tr>
<td style="WIDTH: 269px"><asp:Label id="Label1" runat="server"
Width="193px">Convert From:</asp:Label></td>
<td><uc1:CurrCodes id="currFrom" runat="server"></uc1:CurrCodes></td>
</tr>
<tr>
<td style="WIDTH: 269px"><asp:Label id="Label2" runat="server"
Width="177px">Convert To:</asp:Label></td>
<td><uc1:CurrCodes id="currTo" runat="server"></uc1:CurrCodes></td>
</tr>
<tr>
<td style="WIDTH: 269px"><asp:Label id="Label3" runat="server"
Width="155px">Amount:</asp:Label></td>
<td><asp:TextBox id="txtAmount" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td colspan="2" align="middle"><asp:Button id="Button1" runat="server"
Text="Convert" OnClick="Button1_Click"></asp:Button></td>
</tr>
<tr>
<td colspan="2" align="middle"><asp:Label id="lblConversion" runat="server"
Width="451px"></asp:Label></td>
</tr>
</table>
</form>
</body>
</html>

"SSW" <fr************@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
try instantiating Service1 as below in Button1_Click(object sender,
System.EventArgs e) as below.

CurrencyNS.Service1 currSvc = new CurrencyNS.Service1();

Ur code will look some thing like...

private void Button1_Click(object sender, System.EventArgs e)
{
CurrencyNS.Service1 currSvc = new CurrencyNS.Service1();
double dRate = currSvc.ConversionRate(currFrom.CurrencyCode,
currTo.CurrencyCode);
if (dRate < 0)
lblConversion.Text = "Error Occured";
else
lblConversion.Text = "" + txtAmount.Text + " " + currFrom.CurrencyCode +
"(s) =" + Convert.ToString(dRate * Convert.ToDouble(txtAmount.Text)) + " " +
currTo.CurrencyCode;
}

HTH

sswalia
MCSD, MCAD, OCA
"sean" <se********@shopsmart.com.au> wrote in message
news:e1**************@TK2MSFTNGP12.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(object sender, System.EventArgs e)
Line 8: {
Line 9: Service1 currSvc = new Service1();
Line 10: double dRate = currSvc.ConversionRate(currFrom.CurrencyCode,
currTo.CurrencyCode);
Line 11: if (dRate < 0)

Source File: e:\inetpub\wwwroot\Currency1\currconv.aspx Line: 9


!--- aspx page

private void Button1_Click(object sender, System.EventArgs e)
{
Service1 currSvc = new Service1();
double dRate = currSvc.ConversionRate(currFrom.CurrencyCode,
currTo.CurrencyCode);
if (dRate < 0)
lblConversion.Text = "Error Occured";
else
lblConversion.Text = "" + txtAmount.Text + " " + currFrom.CurrencyCode +
"(s) =" + Convert.ToString(dRate * Convert.ToDouble(txtAmount.Text)) + "

" +
currTo.CurrencyCode;

}

!--------------- web service
<%@ WebService Language="c#" Class="CurrencyNS.Service1" %>
using System;
using System.Web;
using System.Web.Services;
using System.Net;
using System.IO;
using System.Text;
namespace CurrencyNS
{
[WebService]
public class Service1 : System.Web.Services.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.com/d/quotes.csv?s=" + From + To +
"=X&f=sl1d1t1c1ohgv&e=.csv";

try
{
req = (HttpWebRequest) WebRequest.Create(fullpath);
res = (HttpWebResponse) req.GetResponse();
sr = new StreamReader(res.GetResponseStream(), 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.ToDouble(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
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...
0
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...
16
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 -...
17
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...
4
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...
1
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...
3
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. ...
3
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...
2
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
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...

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.