D
dvestal
I have a very strange error; an ASP page invokes a method through .NET
remoting which returns an exception as an output parameter.
Unfortunately, no matter what exception the method returns, it appears
as a different one ("Cannot find the assembly") to the ASP page.
To clarify, I have an interface class called called IGetBoardInfo,
which provides the interface for one method.
I have a Windows service that exposes (through remoting) a class called
GetBoardInfo, which implements the interface. It uses a class library
called SubComponent, which can throw custom exceptions.
Finally, an ASP webpage instantiates the GetBoardInfo class and calls
its method. When it does, the GetBoardInfo class calls SubComponent,
which throws a SubComponentException, which is returned via output
parameter back to the ASP page. The problem is, which the ASP page
tries to display the exception's message, this is the exception that
appears:
"Cannot find the assembly 'SubComponent', Version=1.0.1.2,
Culture=neutral, PublicKeyToken=null."
This is not the exception that was actually thrown. How is the real
exception getting obscured, and this other exception being shown
instead?
Here is some much-simplified code that illustrates what I'm talking
about:
The interface class is specified like this:
namespace TE.Service.IGetBoardInfo
{
[Serializable()]
public struct BoardInfo
{
public long m_ID;
public long m_siteNumber;
}
public interface IBoardInfo
{
BoardInfo[] GetBoardInfo(out Exception o_exception);
}
}
The service itself is called GetBoardInfoSvc, and uses a C# class
library called SubComponent.
public class BoardInfoRpcServer : MarshalByRefObject, IBoardInfo
{
public BoardInfo[] GetBoardInfo(out Exception o_exception)
{
o_exception = null;
BoardInfo[] info = null;
try
{
// this line throws a SubComponentException
info = SubComponentNamespace.SubComponent.GetBoards();
}
catch(Exception e)
{
o_exception = e;
info = null;
}
return info;
}
}
The webpage has code that looks like this:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
ystem.EventArgs) Handles MyBase.Load
Dim url as String = "tcp://myComputerName:555/GetBoardInfo.rpc"
Dim obj As IBoardInfo = Activator.GetObject(GetType(IBoardInfo), url)
Dim exBoardInfo As Exception
Dim strBoards() As BoardInfo = obj.GetBoardInfo(exBoardInfo)
' At this point, exBoardInfo is "Cannot find the assembly
'SubComponent'",
' which is not the exception that was originally thrown.
End Sub
remoting which returns an exception as an output parameter.
Unfortunately, no matter what exception the method returns, it appears
as a different one ("Cannot find the assembly") to the ASP page.
To clarify, I have an interface class called called IGetBoardInfo,
which provides the interface for one method.
I have a Windows service that exposes (through remoting) a class called
GetBoardInfo, which implements the interface. It uses a class library
called SubComponent, which can throw custom exceptions.
Finally, an ASP webpage instantiates the GetBoardInfo class and calls
its method. When it does, the GetBoardInfo class calls SubComponent,
which throws a SubComponentException, which is returned via output
parameter back to the ASP page. The problem is, which the ASP page
tries to display the exception's message, this is the exception that
appears:
"Cannot find the assembly 'SubComponent', Version=1.0.1.2,
Culture=neutral, PublicKeyToken=null."
This is not the exception that was actually thrown. How is the real
exception getting obscured, and this other exception being shown
instead?
Here is some much-simplified code that illustrates what I'm talking
about:
The interface class is specified like this:
namespace TE.Service.IGetBoardInfo
{
[Serializable()]
public struct BoardInfo
{
public long m_ID;
public long m_siteNumber;
}
public interface IBoardInfo
{
BoardInfo[] GetBoardInfo(out Exception o_exception);
}
}
The service itself is called GetBoardInfoSvc, and uses a C# class
library called SubComponent.
public class BoardInfoRpcServer : MarshalByRefObject, IBoardInfo
{
public BoardInfo[] GetBoardInfo(out Exception o_exception)
{
o_exception = null;
BoardInfo[] info = null;
try
{
// this line throws a SubComponentException
info = SubComponentNamespace.SubComponent.GetBoards();
}
catch(Exception e)
{
o_exception = e;
info = null;
}
return info;
}
}
The webpage has code that looks like this:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
ystem.EventArgs) Handles MyBase.Load
Dim url as String = "tcp://myComputerName:555/GetBoardInfo.rpc"
Dim obj As IBoardInfo = Activator.GetObject(GetType(IBoardInfo), url)
Dim exBoardInfo As Exception
Dim strBoards() As BoardInfo = obj.GetBoardInfo(exBoardInfo)
' At this point, exBoardInfo is "Cannot find the assembly
'SubComponent'",
' which is not the exception that was originally thrown.
End Sub