[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.webservices

Error - Exception of type System.InvalidCastException was thrown !!!!

Marek Nowak

1/6/2003 12:48:00 PM

Hi all,

I going mad with this problem

I have file: kalk.asmx
-----------------------------------------------------------------------
<%@ WebService language="VB" class="KALK" %>

Imports System
Imports System.Web.Services
Imports System.Xml.Serialization

Public Class KALK

<WebMethod> Public Function Dodawanie(a As Integer, b As Integer) As
Integer
Return a + b
End Function

End Class
----------------------------------------------------------------------------
------

I generate VB (i add in this file: NameSpace Kalkulator) and DLL files

and i have file: kalk.aspx

----------------------------------------------------------------------------
--
<%@ Page Language="VB" %>
<script runat="server">

sub Page_Load(obj as object, e as eventargs)

dim objCalc as new Kalkulator.KALK()

lblMessage.Text = objCalc.Dodawanie(1,5)
end sub

</script>
<html>
<head>
</head>
<body>
1 + 5 = : <asp:Label id="lblMessage" runat="server"></asp:Label>
</body>
</html>
----------------------------------------------------------------------------
---------

when i run this file (kalk.aspx) i have error

Exception of type System.InvalidCastException was thrown.

error is in this line:
dim objCalc as new Kalkulator.KALK()

where is the problem??
please help me!!!!!!!!!!!

When i strat it on webmatrix is run ok

Thanks a lot!!!
Marek Nowak




1 Answer

Saurabh Nandu [MVP]

1/7/2003 7:06:00 AM

0

Try importing the Namespace in the ASPX file (shown below). And also ensure
the proxy Dll is placed in the BIN directory..

<%@ Page Language="VB" %>
<%@ Import Namespace="Kalkulator" %>
<script runat="server">

sub Page_Load(obj as object, e as eventargs)

dim objCalc as new Kalkulator.KALK()

lblMessage.Text = objCalc.Dodawanie(1,5)
end sub

</script>
<html>
<head>
</head>
<body>
1 + 5 = : <asp:Label id="lblMessage" runat="server"></asp:Label>
</body>
</html>


--
Regards,
Saurabh Nandu
Microsoft MVP | MCP | Author
www.MasterCSharp.com
Master C#, the easy way...