silverlight Application can not use wcf namespace - c#

I have a Silverlight application with a web application to test it,
there are two WCF services I created on my web application.
I can add reference all my services in my Silverlight application but when I want to use one of my data contracts ,I can not add my service namespace to the Silverlight application:
ex: I have a person class in my WCF service(reference name)
WCF service.person = new wcfservice.person();
Error:
The type or namespace name 'WCF service' could not be found (are you
missing a using directive or an assembly reference?)

I can add reference all my services in my Silverlight application but
when I want to use one of my data contracts...
You can't bring in the namespace because it exists in an assembly which has been complied in a different CLR. But that doesn't mean one can't work with the defined class. By bringing the target class(es) into the Silverlight project via the use of a linked file one can safely work around the CLR differences.
A linked file is built in both projects, the original and the linked, but only resides in one location; hence changes made to it are reflected in both projects.
In the Silverlight project add the target file(s) and then choose:
That way you can use the class within the namespace as such, for it is compiled into the Siliverlight programs scope; but any changes made to the file are also reflected in the Silverlight app.

Related

Xamarin Forms, using WCF Service Error

Currently I have Xamarin.Forms application which use service reference WCF, SellerCloud API which is on "http://ws.timezone123.com/SCService.asmx".
Referencing SCService I receive two compile exceptions
"The type or namespace name 'XmlElement' does not exist in the namespace 'System.Xml' (are you missing an assembly reference?)" and "The type or namespace name 'schema' could not be found (are you missing a using directive or an assembly reference?)".
http://prntscr.com/g5sgf1
Currently library, from which I am trying to reference service is Portal Class Library with Target Framework "Profile7".
Can you suggest what I can do in that case to make it work?
Thanks
How did you add the service reference to PCL?
You are trying to consume ASMX web service( XML web service with SOAP protocol). As i can see your screenshot ,you added a connected service (typically used for azure app services) not a Web reference. In order to consume ASMX service you need to add a Web reference.
Problem is, web reference is not available in PCL .But it is available in platform specific projects(right click the droid or Ios project --->Add--->Web Reference).
If you add web reference correctly it will generate proxies within your platform specif projects.Then you need to access generated web methods through Dependency service in your PCL.Please check following documentation for further idea
https://developer.xamarin.com/guides/cross-platform/application_fundamentals/web_services/#asmx
Following question is some what similar to your problem
Is there any supported way to call asmx web services from cross-platform Xamarin code?

Can't find namespace in Global

I have the job of getting a legacy project working again. This project was done many years ago using Silverlight and C# Class Library's.
The error I am getting is to do with a namespace inside the project file called Silverlight.Business:
Code
using Tcx = global::MapTools.Xml;
Error:
The type or namespace name "MapTools" could not be found in the global namespace (are you missing an assembly reference?)
MapTools is a C# Class Library and Silverlight.Business is a Silverlight Library. Due to this I can't add a reference to MapTools inside the Silverlight project file.
The silverlight project does have a WCF RIA Service's Link but that does not connect to anything.
I am now wondering how the person that wrote the code has managed to call that namespace? I have tried researching how to add the MapTools.dll to the Global namespace but have not found anything.
Anyone have any ideas?
To do that there should be an some tool been used .
We had used in our projects a Portable library which allowed us to communicate through cross type of projects , below is the link :
https://msdn.microsoft.com/library/gg597391(v=vs.100).aspx

How to invoke or start an asp.net web service (asmx) from another project in C#

How do I invoke or start a asp.net web service (asmx) from another project in C#. The another project can be a console application. I am not asking to consume the web service (which I am doing in Java) but how to start the web service in C# but from a different project.
I already tried including the webservice project in my console application project and also added a reference to the webservice project, included the namespace but I get an error,
The type 'System.Web.Services.WebService' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Web.Services, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
I am trying to invoke the webservice by creating an instant of the webservice class which I guess is already a wrong way.
Thanks in advance!
You are going to want to add a web reference.
How to: Add a Reference to a Web Service
Then you are going to want to set multiple projects to start. This will allow you to debug both.
How to: Set Multiple Startup Projects

Add project as reference to another project

I have two projects in the same solution.
One is an ASP.NET MVC 2 Empty Web Application,
the other is a Console Application.
In the first project i create a database with EF and a class to access the database.
What I want to do is add the first project as a reference to the console app project so i can use this class
I included it as a reference already it appears at the References, and after is include a using directive at the top of my console app i can even use code assistance. But when i compile i always get the error:
The type or namespace name 'DBModel' could not be found (are you missing a using directive or an assembly reference?)
How can i compile my projects?
Sincerely,
Zoli
From your description, if I'm getting it right,
That's often the case when you have different target .NET framework (Project properties, Application, Target Framework) - i.e. one is e.g. .NET 4.0 Client Profile - and the lib you're referencing is just .NET 4.0.
It's also possible that you're missing a reference to the Entity Framework in your Console application.
See this post for more info: http://www.dotnetcurry.com/ShowArticle.aspx?ID=617 (just below the middle, step 3).

Namespace in Referenced Project Present in Autocomplete Before Building, but Causes Compile Error After Building

I have a class library project which uses a namespace (e.g., "Cosmos.Creator.Util"). I then create a solution and windows forms application to test the library. From the windows form application, I add a reference to the library. So now I have two projects open in visual studio, a class library and a windows forms project. The forms project references the library.
When I edit my form's code, code autocompletion works correctly for the namespace that I use in the library. E.g., if I type "using Cosmos." I get autocomplete options like "Creator". But now if I build my solution, all of the "Cosmos" are red-underlined with the compile error: "The type or namespace name "Cosmos" could not be found (are you missing a using directive or an assembly reference?)".
For the purposes of the form application test, I placed my library code into a folder CosmosFormExample\Cosmos. When I check the reference from the form application, the reference is to CosmosFormExample\Cosmos\bin\Debug\Cosmos.dll, so that looks okay. I looked at the GUID referenced in the solution file and it matches the GUID of the project file Cosmos.csproj.
What has happened? How has the build caused my forms application to forget about the Cosmos namespace, despite the fact that it is still referencing the library project? Thanks much in advance.
Are you using VS2010 & .NET 4? If so you're probably using .NET 4 Client Profile instead of full fledged .NET 4. Go to project properties and check your Target Framework.
for more info: http://msdn.microsoft.com/en-us/library/cc656912.aspx
you need to check the framework you are using and the framework yout library was compiled for...

Categories

Resources