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.");
}
}
}
} 5 2643
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
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.
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
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...
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...
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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...
|
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...
|
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:
...
|
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...
|
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.
...
|
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....
|
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...
|
by: DJRhino |
last post by:
Was curious if anyone else was having this same issue or not....
I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
|
by: Aliciasmith |
last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
|
by: tracyyun |
last post by:
Hello everyone,
I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
|
by: giovanniandrean |
last post by:
The energy model is structured as follows and uses excel sheets to give input data:
1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM)
Please note that the UK and Europe revert to winter time on...
|
by: nia12 |
last post by:
Hi there,
I am very new to Access so apologies if any of this is obvious/not clear.
I am creating a data collection tool for health care employees to complete. It consists of a number of...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
|
by: isladogs |
last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, Mike...
| |