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

Interfaces in a separate assembly...remoting

Hello, I'm hoping someone might be able to help me out. I'm creating a
shared assembly with my interface definitions similar to the following.
When I try to compile the RemotingInterface, everything works. When I
go to compile the RemotingServer assembly, I receive the following
error message. I've included all my references, so I'm almost positive
that's not the issue. Shouldn't this be possible without having to
implement HelloMessage in the RemotingInterface assembly?

Error 2 'RemotingServer.SampleService' does not implement interface
member
'RemotingInterface.ISampleService.HelloWorld(Remot ingInterface.IHelloMessage)'

namespace RemotingInterface
{
public interface IHelloMessage
{
string Message
{
get;
set;
}
}
public interface ISampleService
{
//If I have HelloMessage defined in the same assembly, I change
//IHelloMessage to HelloMessage and
everything works fine.
IHelloMessage HelloWorld(IHelloMessage
message);
}
}

Now, in my server assembly, I have the following:
namespace RemotingServer
{
public class SampleService : MarshalByRefObject, ISampleService
{
//This method declaration throws:
//'ISampleService.HelloWorld' in
explicit interface declaration is not a member of interface
//Shouldn't RemotingServer.HelloMessage
is RemotingInterface.IHelloMessage return true?
HelloMessage
ISampleService.HelloWorld(HelloMessage message)
{
HelloMessage response = new HelloMessage();

return response;
}
}

public class HelloMessage : IHelloMessage
{
public string Message
{
get
{
return "Hello";
}
set
{
throw new Exception("The method or operation is not implemented.");
}
}
}
}

Nov 22 '06 #1
5 2658
HelloMessage ISampleService.HelloWorld(HelloMessage message) {
HelloMessage response = new HelloMessage();
return response;
}

Shouldn't that be IHelloMessage at the start? Otherwise it (as stated)
doesn't meet the interface definition. It doesn't matter that HelloMessage :
IHelloMessage; the signature must match.

Marc
Nov 22 '06 #2
Yeah, IHelloMessage works. So if I have properties that return
interface types, I have to go through the exercise of casting each one
to its specific type, i.e.

public interface SomeInterface
{
IAnotherInterface SomeProperty
{
get;set;
}
}

And then in my implementation, I would do something like:

SpecificImplementation _var =
(SpecificImplementation)IAnotherInterface.SomeProp erty
Is this correct? Thanks for the help, I appreciate it.

Nov 22 '06 #3
Well, only if you care about the bits in the specific implementation ;-p
Most of what you need may be (or perhaps /should be/) available in
IAnotherInterface. After all, if you are binding to a specific
implementation, why bother with an interface at all?

In /some/ circumstances, a generic interface may be appropriate... so you
could have

public interface ISomeInterface<Twhere T : IAnotherInterface {
T SomeProperty {get; set;}
}

However, this is again blurring the abstraction that interfaces are meant to
provide, so treat with caution. However, if you know that something
implements IAnotherInterface<SomeImplementation>, then you can call
SomeImplementation result = i.SomeProperty;

Marc
Nov 22 '06 #4
Marc,
Thanks for your help. I completely forgot that I could do

SomeImplementation result = i.SomeProperty;

The reason for defining the interfaces to begin with, was to be able to
use the shared assembly in remoting...which I understood was the method
to use.

Thanks again...

Nov 22 '06 #5
You don't "Have to" use Interfaces for Remoting, as long as both client and
server have a reference to the same assembly (so they know "what" to remote).
However, using an Interface does make things more extensible.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Junoti" wrote:
Marc,
Thanks for your help. I completely forgot that I could do

SomeImplementation result = i.SomeProperty;

The reason for defining the interfaces to begin with, was to be able to
use the shared assembly in remoting...which I understood was the method
to use.

Thanks again...

Nov 22 '06 #6

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

Similar topics

4
by: Robert Zurer | last post by:
I notice that Microsoft puts their interfaces and classes in the same assembly. For example System.Data contains OleDbConnection and IDbConnection etc. I have found it useful to keep my...
2
by: Richard Lewis Haggard | last post by:
I know this is a really simple thing but it is not intuitively obvious on how to do this the first time. I've created a remote server which lives in an EXE. This compiles. I've create a client...
8
by: Richard Bell | last post by:
I have a class in a seperate dll which I want to remote. I have referenced the class and registered it using a simple exe. I can connect to the class's interface using Activator.GetObject and call...
1
by: Bob | last post by:
In ASP.NET 1.1, I had a class library with a bunch of base classes for all my projects. One of the base class is a base page class. In .NET 2.0, how can I compile a master page into a separate...
7
by: Frank | last post by:
I'm running into trouble and I hope someone can help. I have two assemblies. The first defines a base class and a series of distinct classes based on the base class. Something similar too: ...
1
by: Sergei Shelukhin | last post by:
Hi. We have a resource assembly that is separate and is used by a class library assembly, a web app, web service set (all in separate projects). Windows app is also potentially possible. First...
0
by: hoots | last post by:
I've got this code which is running from an SSIS script component, it fails with a FileIOPermission error when making a call to CreateInstanceFromAndUnwrap, any help would be much appreciated. ...
5
by: | last post by:
I am having problems with casting or converting a class to to an interface from which it derives. I'm certain that it's due to how it's being loaded, but I'm not sure how to get past the problem....
1
by: Padu | last post by:
Hi All, In WCF, up to now, I've been using the default pattern of creating an IService.cs that holds both and for the composite types that must be returned by the service operations. It...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
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...

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.