0

I receive this error when trying to run the client.

The type 'StringPro.IMyString' is defined in an assembly that is not referenced.

This error comes from, StringProClient from file Program.cs and underlines in blue the following first line of code:

StringProProxy.StringProProxy proxy = new StringProProxy.StringProProxy();

The solution has 4 projects inside:

StringPro - Class Library that contains the service's interface(IMyString.cs) and the implementation class(MyString.cs)

StringProHost - Console Application that has Program.cs inside which defines Uri, ServiceHost, Endpoint, ServiceMetadataBehaviour, HttpGetEnabled, host.Description.Behaviours, calls host.Open() and displays in console information about when the service was started

StringProProxy - I believe it's a Class Library project since it has only StringProProxy.cs which defines the service's proxy

StringProClient - Console Application which instantiates the service's proxy inside, call the service's functions and displays results.

EDIT: The service host launches fine. It's the client that won't build and run because of the mentioned error.

Bob
  • 1,355
  • 5
  • 19
  • 38

2 Answers2

2

If a project is using a type that was declared in other assembly, this assembly must be referenced - this is basically what your error is telling you.

In your case, I'm guessing that StringProClient is referecing StringProProxy, but it is also using types declared in StringPro project (to be exact: IMyString interface/class), without referencing it. You should make sure, that StringProClient references both, StringProProxy and StringPro.

Marcin Deptuła
  • 11,789
  • 2
  • 33
  • 41
  • Not usre if worked. Now I tried to run them and got: `Could not find default endpoint element that references contract 'StringPro.IMyString' in the ServiceModel client configuration section.` – Bob Feb 12 '12 at 16:49
  • @Bob Well, this is completely different error. Previous one was a generic c# compiler one, now you have WCF one. You can check other SO.com question for it. For example this one: http://stackoverflow.com/questions/352654/could-not-find-default-endpoint-element – Marcin Deptuła Feb 12 '12 at 16:53
  • How do I run both Host and Client from one Visual Studio instance. Because if I run Host I can't run the Client since it disables the project viewer. If I try to run StringPro it won't run since it is a Class Library. – Bob Feb 12 '12 at 17:03
  • @Bob http://stackoverflow.com/questions/3850019/running-two-projects-at-once-in-visual-studio . You can also open project viewer after running first project, and r-click it and select Start instance. Those problems can be googled and are not relevant to your main question, it's a good practice to stick to one problem / topic in comments. – Marcin Deptuła Feb 12 '12 at 17:08
  • My bad. I found the solution but it wouldn't let me edit the previous comment for some reason. Thanks for the help. – Bob Feb 12 '12 at 17:21
0

Such problem mostly arises with the issues like namespace only. Kindly check your references as well as namespaces again.

Pratik
  • 161
  • 4
  • 13