473,406 Members | 2,956 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,406 software developers and data experts.

C# interface restrictions / remoting

Hi there,

Quick one about interfaces in c#. It seems that it is illegal to
declare types within an interface.

I was quite used to doing this in VB.net where the interface can define
a
clients remoting interface and object model.

eg..

Public Interface ISelectionEngine

Function GetProductData(ByVal ChannelID As String) As XmlDocument

<Serializable()> _
Class ApplicantIncomeType
Public IncomeBasic As Decimal
Public IncomeBonus As Decimal
Public IncomeCommission As Decimal
Public IncomeOvertime As Decimal
Public StartDate As DateTime
Public EndDate As DateTime
End Class

<Serializable()> _
Enum ArrearPeriodConstants
ZeroTo6months
SevenTo12months
ThirteenTo24
End Enum

<Serializable()> _
Class NoProductFoundException
Inherits Exception
Public Sub New(ByVal sMessage As String)
MyBase.New(sMessage)
End Sub
Protected Sub New(ByVal info As SerializationInfo, ByVal
context As StreamingContext)
MyBase.New(info, context)
End Sub
End Class

End Interface

This will compile in vb.net...

I guess I could code the interface assembly in vb.net , but what is the
correct way to expose types across the remoting boundary in c#.

BTW this is a server activated object remoting configuration.

Thanks in advance,

Matthew

Nov 17 '05 #1
2 2818
Why do you particularly need it to be a nested type?

In C#, if you want to define types to be used across a remoting boundary,
the normal practice is to declare the relevant type at the same scope as the
interface:

using System;
using System.Runtime.Serialization;
using System.Xml;

public interface ISelectionEngine
{
XmlDocument GetProductData(string ChannelID);
}

[Serializable]
public class ApplicantIncomeType
{
public decimal IncomeBasic;
public decimal IncomeBonus;
public decimal IncomeCommission;
public decimal IncomeOvertime;
public DateTime StartDate;
public DateTime EndDate;
}

[Serializable]
public enum ArrearPeriodConstants
{
ZeroTo6months,
SevenTo12months,
ThirteenTo24
}

[Serializable]
public class NoProductFoundException : Exception
{
public NoProductFoundException(string sMessage)
: base(sMessage)
{ }
protected NoProductFoundException(SerializationInfo info,
StreamingContext context) : base(info, context)
{ }
}

If you're using the interface for remoting, then you'll also be able to use
these other types across the same remoting interface. Remoting really
doesn't care where the types are defined so long as it's able to access
them. Making them nested types doesn't add anything. I've successfully
used types defined in the above manner across remoting boundaries in the
past. It never even occurred to me that I might want the types to be
nested.

So the usual practice would be to compile that source code into a seperate
DLL that is present on both the client and the server end of your
connection. You'll then be able to use the same types on either side. The
fact that the types aren't nested won't change anything.
--
Ian Griffiths - http://www.interact-sw.co.uk/iangblog/
<ma****************@hotmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Hi there,

Quick one about interfaces in c#. It seems that it is illegal to
declare types within an interface.

I was quite used to doing this in VB.net where the interface can define
a
clients remoting interface and object model.

eg..

Public Interface ISelectionEngine

Function GetProductData(ByVal ChannelID As String) As XmlDocument

<Serializable()> _
Class ApplicantIncomeType
Public IncomeBasic As Decimal
Public IncomeBonus As Decimal
Public IncomeCommission As Decimal
Public IncomeOvertime As Decimal
Public StartDate As DateTime
Public EndDate As DateTime
End Class

<Serializable()> _
Enum ArrearPeriodConstants
ZeroTo6months
SevenTo12months
ThirteenTo24
End Enum

<Serializable()> _
Class NoProductFoundException
Inherits Exception
Public Sub New(ByVal sMessage As String)
MyBase.New(sMessage)
End Sub
Protected Sub New(ByVal info As SerializationInfo, ByVal
context As StreamingContext)
MyBase.New(info, context)
End Sub
End Class

End Interface

This will compile in vb.net...

I guess I could code the interface assembly in vb.net , but what is the
correct way to expose types across the remoting boundary in c#.

BTW this is a server activated object remoting configuration.

Thanks in advance,

Matthew

Nov 17 '05 #2
I had tentatively come to that conclusion. Thanks very much for
confirming it.

Nov 17 '05 #3

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

Similar topics

1
by: Tom | last post by:
I have a question.. I am using remoting but on my client side I chose to use an interface. As a result I was wondering if its still possible to place the configuration details into a xml config...
7
by: Erik TL | last post by:
Hi How does one return a varible, value, or object from a window service in .net? How do I expose the service methods? A link, code, or anything is wellcome, because I'm going bonkers! ...
0
by: moitra | last post by:
We have a series of processes which have been running w/o problem for a year. Suddenly! we started getting this error which looks like stemming from DTC - "No such interface supported". The errors...
1
by: Larry Page | last post by:
Greetings, I'm using remoting to execute commands on a remote machine. My original testing used basic console client and server apps containing a common interface, which I built as a seperate...
3
by: aitzi | last post by:
Hi to all! We are designing a dll that needs to send some information periodically to a possible interface application that is listening to these messages. The information, which consist on a...
1
by: Bry | last post by:
I have the following code which creates a remoting server component TcpChannel server = new TcpChannel(37921); ChannelServices.RegisterChannel(server, true);...
0
by: Junoti | last post by:
I've read several posts out there that state that setting typeFilterLevel="Full" on the client and/or server will correct this issue, however I'm still unable to get around it. I can successfully...
10
by: viashino | last post by:
Hi, I have written a Console Application that is doing different things, like checking the status of different network Hosts. I would like to implement a WebInterface to show such status, and...
1
by: =?Utf-8?B?TUJ1cnNpbGw=?= | last post by:
This works without any problems: Code Snippet string uri = "tcp://localhost:8000/CAOFactory"; cf = (CustomerInterfaces.ICAOFactory)Activator.GetObject(typeof(CustomerInterfaces.ICAOFactory),...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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,...
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
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,...

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.