Adding link to Web Reference from a Project - ChannelBase not found - silverlight

I am building a Silverlight app. As I have classes to be consumed by Silverlight and .NET modules, I have created a Silverlight project with all the classes in it and then, a .NET project linking('Add Link') to the classes in Silverlight project. This way, I have one class file compiled separately as Silverlight and .NET assemblies. I want to replicate the same for web service references. Meaning, I have web references in the Silverlight project. I am trying to 'Add Link' to reference.cs from Silverlight project into the .NET project. When I compile the .NET project, the ChannelBase class doesn't get resolved it seems due to disparity in definition of the class in Silverlight and .NET framework libraries. This results in compilation error stating unresolved ChannelBase. Sounds like a dead end to me. Do you see a way around this problem?

I'm afraid this is not possible. Both proxies are completely different: one of them is synchronous while the other one is not.
The best thing you can do is to share the service defined classes, not the whole proxy. Just create those classes beforehand, use "Add as link" to reuse them in both projects, and then when you add the service reference, mark the option "Reuse types in referenced assemblies".

Just in case someone else stumbles on this. I had a similar problem. I was generating the proxy using slsvcutil.exe and trying to compile it for .net and monotouch. I kept getting ChannelBase not found. Which made no sense at all. Finally I commented out the CookieContainer property in the proxy client class and low and behold the compile error went away and the proxy works for monotouch.

Related

NancyFX and adding another project as reference doesn't work

I created a nancyfx iis host solution from the nancyfx templates. I was wanting to put my domain in a separate project but found that adding that project to the nancyfx project resulted in a the yellow exclamation point beside of the reference and at compile time I was getting errors about the reference to the namespace.
I likely have overlooked something very simple but I can't figure out why this is happening. (I may be able to compile the domain project and add the dll reference but I prefer to just reference the project.)
This doesn't sound like a Nancy issue - are you sure both projects are targeting the same version of the .net framework?

Sorrow with Data Transfer Objects in Silverlight / WCF

I have a Silverlight app hosted in an Azure web role ASP project. The ASP project exposes a WCF service.
I would like to have one set of class definitions for the data types. Someone recommended making a third project (class library) and adding a reference to it from the SL and ASP. I started doing this, but the Silverlight project complained that you can only add references to Silverlight projects.
I then made a Silverlight class library and moved the data classes to it. However, I to add some .dll references, like to the Windows Azure storage client. Then the Silverlight class library tells me I can only add references to Silverlight 4-friendly .dlls, of which Windows Azure isn't one. Fantastic.
Is there something I can do to get around this, or am I stuck with a less elegant, redundant solution?
Multi-targeting is your best bet. There is an article explaining this in Visual Studio from Microsoft at:
http://msdn.microsoft.com/en-us/library/ff921092(PandP.20).aspx
Basically, you create both your Silverlight and standard .NET class libraries, each with a different name, and then include the same files into each. Usually the files are actually only in one of the class libraries and then soft linked in the second one.
The key is to ensure that the code in your files is compatible with both runtimes. If there needs to be separate implementation for some of your methods depending on the runtime then you need to separate these with pragmas (i.e. #ifdef SILVERLIGHT...).
If you're only doing data structures, however, there should be no issues as long as Silverlight supports the objects you are using.
See if using linked files as per this answer does the trick for you.

add reference to Silverlight project from other non silverlight project

I have Silverlight application using NHibernate as a ORM. I have projects for Data(mapp and entities), data access and Silverlight. I want to add to SL project reference to data access to execute methods, but SL can only get reference from other SL project.
How can I omit it? If I host data access project on WCF I could reference WCF to SL?
Please help ! :)
Yes, you can expose your data access assembly as a bunch of WCF services and then call them from the SL application.
There is also another way - make a Silverlight class library, and then add new linked files to it - those linked files being the class files from your data access assembly.
Here is a previous answer that explains the linking, although you should note that because your data access classes will now being using the Silverlight runtime you may not have access to all the System namespaces that you want (although you can pick and choose what files you want to add to the new project, and refactor the ones that don't work because of this).

WPF : Referencing Assembly with Forms Controls does not work?

I've got a Problem. I need to use some classes from another Library DLL, that has been written a year ago, in my WPF Project. Therefore I reference this Library in my Project. But when I want to rebuild my solution I always get some warnings that my assembly cannot be resolved because it uses some dependencys that do not match my targeted framework.
This is one of the Errors
The referenced assembly "istis.AcademyOne.ClassLibrary, Version=2.1.0.1, Culture=neutral, PublicKeyToken=fd9f6afaca722199, processorArchitecture=MSIL" could not be resolved because it has a dependency on "System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which is not in the currently targeted framework ".NETFramework,Version=v4.0,Profile=Client". Please remove references to assemblies not in the targeted framework or consider retargeting your project. A1RevisionControls
Does anyone know a workaround or a solution so I can keep the original DLL and use it in my WPF Application ?
EDIT : Ok I solved the Problem switching my Target Framework of my WPF Solution to .NET Framework 4.0 instead of Framework 4.0 Client Profile.
One method would be to put the old dll behind a WCF facade. Another option would be to include the old dll in a new project, and use some sort of inter-process communication like named pipes to talk between the two.
Or you could just share the class files with a new .Net 4 class project, and reference that new class library. This example and this example talk about doing it in Silverlight and/or WCF, but the principle is exactly the same.

Is the System.Web.Silverlight reference needed?

We are just getting into Silverlight development at my workplace. Somehow two of our dev machines have been configured differently. I noticed that one of them has access to System.Web.Silverlight in the reference list, and the other doesn't. Both can create and run Silverlight applications from scratch.
What does System.Web.Silverlight do? Is it a legacy reference? If we need it, where do we get it from?
This dll provided the ASP.NET Silverlight server control which was designed to make it easier to create the object tag needed to describe the silverlight plug-in.
This server-side control was removed as of Silverlight 3, you are now expected to build the object tag yourself.
So yes its legacy so you don't need it.
Anthony is correct. If you are having trouble after you upgrade your products to Silverlight 3 - or just want an example on how to insert your SL app in to a page, create a new SL3 project and check out the sample ASPX and HTML pages (which are pretty much the same as each other now...)

Resources