I was trying to add a reference to my non-silverlight Class Library and the VS 2008 IDE told me "You can only add project references to other Silverlight projects in the solution". Essentially I want to use some of my business objects in the silverlight
project I created, but don't really see a way to do this? Does this mean that you can never use any regular class libraries in your silverlight project? Is this because of the sandbox it runs in? What are some ways to get around this? Do you have to copy
all of the code from your class library to your silverlight class library? That seems pretty ridiculous. If anything the sandbox should do reference checking to make sure that everything will run safely in the sandbox. My BusObjects are just container objects,
so they don't open any database connections and are really just used to hold data.
My overall goal was to add this reference and use svcutil.exe to create my proxy class with references to my BusObject class library, so when I make my service calls, the proxy lets me return my real business objects, rather than proxy generated ones. This
all ties into how well silverlight will utilize the WCF I guess and I haven't really seen anyone discussing this yet.
This is one of the things that will make silverlight a really handy tool to port over existing data systems to rich GUIs on the web. Any thoughts?
I'm looking for a way as well to share a Class Library with both a Silverlight project as well as a Windows Forms application. I tried creating a Silverlight class library, because I thought that, since Silverlight uses a subset of the full .NET framework,
a Windows Forms application should be able to use this Silverlight Class Library. But that doesn't quite work.
I guess we could share the C# source files between the Silverlight project and the Full .NET project using the Link to file option when adding a C# file to the project...
You can't share assemblies between silverlight and the desktop clr as they are subtley different runtimes. Even if you use intrinsic types such as string, that is actually a binding to the system.string class in the respective runtime. Due to the string
typing of .net, it doesn't like trying to use one in the other.
Your solution of having 2 projects and sharing source between them is probably the cleanest.
The goal is to move from the hacked up json stack and support WCF as the web references stack for silverlight.
I am trying to do the same (add a C# class library reference to a silverlight project) where can I find this Link to File option?
dsdsico
I'm looking for a way as well to share a Class Library with both a Silverlight project as well as a Windows Forms application. I tried creating a Silverlight class library, because I thought that, since Silverlight uses a subset of the full .NET framework,
a Windows Forms application should be able to use this Silverlight Class Library. But that doesn't quite work.
I guess we could share the C# source files between the Silverlight project and the Full .NET project using the Link to file option when adding a C# file to the project...
Earlier i was using ASP.net and i have added my DashboardLibarary.dll ( contain both my business as well as DAL) and it was working fine.
Now i am traying to use silverlight in my web application, but getting the same error mentioned in first post while adding my .dll to silverlight project.
I have tried Thomas steps, and added my all bussiness classes (7 class) as link to silverlight project but after adding again those classes refere to other namespace like System.Data giving error.There are other namespace giving the same problem. However
it was working fine if i exclude my silverlight project from my Applicatation solution.
Error 37 The type or namespace name 'Data' does not exist in the namespace 'System' (are you missing an assembly reference?) C:\..\DashboardLibrary\Business\ComponentHelper.cs 2 14 SilverlightApplication1
Hope you understand my problem,
Waiting for your reply.
Thanks and Regards,
Avtar Sohi.
Please click on "Mark As Answer", if this answered your query partially or fully.
I am having this issue too. I tried to Link to File option and of course I can add as many files as links and use their source code, but when I have a regular .NET library that is referencing 10 other libraries (including the vital Enterprise Library), how
can I bring the source code along with all the references into my Silverlight applicaiton so I can just reuse what I have out there? This whole thing is radiculous. I know what causes the limitations, but I still don't see what the use of Silverlight is when
you can't reuse anything that you've done previously...
This is currently a big limitation, however Microsoft is working on a flow-down business entity framework (code name Alexandria) that will allows the business objects defined against the .NET runtime to be referenced from Silverlight.
This was presented at the PDC & various MDCs across the country last fall, but unfortunately there is no timeline announced for when it will be released.
The way I have handled this limitation is, I perform the majority of my business logic on the server (using the .NET objects) based on WCF service calls. The data resulting from this logic is returned using DataContract classes which I can then use to populate
local Silverlight business objects, which duplicate only that business logic that the UI itself needs to know about but have the same "shape" as the DataContract class.
It's not ideal, certainly, but it is working. I look forward to the flowdown business objects though too because duplicated code is never ideal.
--
Anye Mercy
AnyeDotNet.blogspot.com
Please "Mark as Answer" the posts that help you - this lets others know the problem has been solved and helps others having the same problem know which solution works. Thanks!
enantiomer2000
Member
47 Points
63 Posts
Silverlight project "add reference"
Sep 07, 2007 03:32 AM | LINK
Hello:
I was trying to add a reference to my non-silverlight Class Library and the VS 2008 IDE told me "You can only add project references to other Silverlight projects in the solution". Essentially I want to use some of my business objects in the silverlight project I created, but don't really see a way to do this? Does this mean that you can never use any regular class libraries in your silverlight project? Is this because of the sandbox it runs in? What are some ways to get around this? Do you have to copy all of the code from your class library to your silverlight class library? That seems pretty ridiculous. If anything the sandbox should do reference checking to make sure that everything will run safely in the sandbox. My BusObjects are just container objects, so they don't open any database connections and are really just used to hold data.
My overall goal was to add this reference and use svcutil.exe to create my proxy class with references to my BusObject class library, so when I make my service calls, the proxy lets me return my real business objects, rather than proxy generated ones. This all ties into how well silverlight will utilize the WCF I guess and I haven't really seen anyone discussing this yet.
This is one of the things that will make silverlight a really handy tool to port over existing data systems to rich GUIs on the web. Any thoughts?
enantiomer2000
Member
47 Points
63 Posts
Re: Silverlight project "add reference"
Sep 07, 2007 03:37 AM | LINK
I guess I should clarify that I am using VS 2008 Beta2 with silverlight 1.1 alpha refresh so everything should be the latest & greatest..
If nobody has any direct answers to that, my follow up question would be how much does MS plan on supporting WCF in Silverlight?
dsdsico
Member
108 Points
42 Posts
Re: Re: Silverlight project "add reference"
Sep 10, 2007 07:44 PM | LINK
I'm looking for a way as well to share a Class Library with both a Silverlight project as well as a Windows Forms application. I tried creating a Silverlight class library, because I thought that, since Silverlight uses a subset of the full .NET framework, a Windows Forms application should be able to use this Silverlight Class Library. But that doesn't quite work.
I guess we could share the C# source files between the Silverlight project and the Full .NET project using the Link to file option when adding a C# file to the project...
dsdsico
Member
108 Points
42 Posts
Re: Re: Re: Silverlight project "add reference"
Sep 10, 2007 07:51 PM | LINK
Yep that works. It's not as neat as sharing a class library, but at least we don't have to copy the C# source from one project to another.
samsp
Member
282 Points
96 Posts
Microsoft
Re: Re: Re: Silverlight project "add reference"
Sep 14, 2007 06:12 PM | LINK
You can't share assemblies between silverlight and the desktop clr as they are subtley different runtimes. Even if you use intrinsic types such as string, that is actually a binding to the system.string class in the respective runtime. Due to the string typing of .net, it doesn't like trying to use one in the other.
Your solution of having 2 projects and sharing source between them is probably the cleanest.
The goal is to move from the hacked up json stack and support WCF as the web references stack for silverlight.
Abbas1982
Member
12 Points
8 Posts
Re: Re: Silverlight project "add reference"
Sep 30, 2007 10:37 PM | LINK
I am trying to do the same (add a C# class library reference to a silverlight project) where can I find this Link to File option?
Thomas L
Member
2 Points
1 Post
Re: Re: Silverlight project "add reference"
Oct 17, 2007 11:04 AM | LINK
Provided that you have defined business object classes in another project in the solution; in your silverlight project, do this (file for file):
Hope this helps,
/Thomas L
avtar
Participant
777 Points
208 Posts
Re: Re: Silverlight project "add reference"
Jan 02, 2009 08:16 AM | LINK
Hi all,
I have the same problem.
Earlier i was using ASP.net and i have added my DashboardLibarary.dll ( contain both my business as well as DAL) and it was working fine.
Now i am traying to use silverlight in my web application, but getting the same error mentioned in first post while adding my .dll to silverlight project.
I have tried Thomas steps, and added my all bussiness classes (7 class) as link to silverlight project but after adding again those classes refere to other namespace like System.Data giving error.There are other namespace giving the same problem. However it was working fine if i exclude my silverlight project from my Applicatation solution.
Error 37 The type or namespace name 'Data' does not exist in the namespace 'System' (are you missing an assembly reference?) C:\..\DashboardLibrary\Business\ComponentHelper.cs 2 14 SilverlightApplication1
Hope you understand my problem,
Waiting for your reply.
Thanks and Regards,
Avtar Sohi.
kalinz11
Member
14 Points
7 Posts
Re: Re: Re: Silverlight project "add reference"
Feb 06, 2009 02:09 PM | LINK
I am having this issue too. I tried to Link to File option and of course I can add as many files as links and use their source code, but when I have a regular .NET library that is referencing 10 other libraries (including the vital Enterprise Library), how can I bring the source code along with all the references into my Silverlight applicaiton so I can just reuse what I have out there? This whole thing is radiculous. I know what causes the limitations, but I still don't see what the use of Silverlight is when you can't reuse anything that you've done previously...
anyeone
Participant
826 Points
199 Posts
Re: Silverlight project "add reference"
Feb 06, 2009 03:17 PM | LINK
This is currently a big limitation, however Microsoft is working on a flow-down business entity framework (code name Alexandria) that will allows the business objects defined against the .NET runtime to be referenced from Silverlight.
This was presented at the PDC & various MDCs across the country last fall, but unfortunately there is no timeline announced for when it will be released.
The way I have handled this limitation is, I perform the majority of my business logic on the server (using the .NET objects) based on WCF service calls. The data resulting from this logic is returned using DataContract classes which I can then use to populate local Silverlight business objects, which duplicate only that business logic that the UI itself needs to know about but have the same "shape" as the DataContract class.
It's not ideal, certainly, but it is working. I look forward to the flowdown business objects though too because duplicated code is never ideal.
Anye Mercy
AnyeDotNet.blogspot.com
Please "Mark as Answer" the posts that help you - this lets others know the problem has been solved and helps others having the same problem know which solution works. Thanks!