using class library in silverlight project

130 Views Asked by At

Currently I am working on a project with the Silverlight technology based on a 3tiers architecture (DataFormation, BusnessFormation, Chalenge) including:

  • DataFormation: is a project of type class library
  • BusnessFormation: is a project of type class library
  • EChalenge: is a presentation layer in silverlight realize

The problem I encountered, and I still can not solve it is to create a web service that will allow me to call the class in the Library "SqliChalenge" layer (the layer presentation, carried out in Silverlight).

Attached a screenshot of the project architecture + capture the error I encountered when I try to add references.

enter image description here

1

There are 1 best solutions below

0
On

I suspect your problem results from the fact that your Silverlight project can only reference class libraries that are built against the Silverlight .NET Framework subset. (see Alex Andersons comment)

I don't think it is possible (meaning officially supported) to transform an existing standard class library project into a Silverlight class libary project.

If you inspect the .csproj files you'll notice the differences:

Standard C# class library project

...
<PropertyGroup>
  <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
  <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
  <ProjectGuid>{DFDAE6D4-0A0A-42C6-915F-31973E630AC9}</ProjectGuid>
  <OutputType>Library</OutputType>
  <AppDesignerFolder>Properties</AppDesignerFolder>
  <RootNamespace>ClassLibrary1</RootNamespace>
  <AssemblyName>ClassLibrary1</AssemblyName>
  <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
  <FileAlignment>512</FileAlignment>
</PropertyGroup>
...

Silverlight class library project:

...
<PropertyGroup>
  <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
  <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
  <ProductVersion>8.0.50727</ProductVersion>
  <SchemaVersion>2.0</SchemaVersion>
  <ProjectGuid>{F5D0D210-C435-46C6-909A-1DE3BB3DEE3B}</ProjectGuid>
  <ProjectTypeGuids>{A1591282-1198-4647-A2B1-27E5FF5F6F3B};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
  <OutputType>Library</OutputType>
  <AppDesignerFolder>Properties</AppDesignerFolder>
  <RootNamespace>SilverlightClassLibrary1</RootNamespace>
  <AssemblyName>SilverlightClassLibrary1</AssemblyName>
  <TargetFrameworkIdentifier>Silverlight</TargetFrameworkIdentifier>
  <TargetFrameworkVersion>v5.0</TargetFrameworkVersion>
  <SilverlightVersion>$(TargetFrameworkVersion)</SilverlightVersion>
  <SilverlightApplication>false</SilverlightApplication>
  <ValidateXaml>true</ValidateXaml>
  <ThrowErrorsInValidation>true</ThrowErrorsInValidation>
</PropertyGroup>

Try adding a Silverlight class libary project to your solution and reference it from your Silverlight presentation layer project.

If the reference works, just copy over your code from Business and Data layer projects.