 |
 | Another Silverlight upgrade headache - Hashtable [modified] |  | devvvy | 11hrs 55mins ago |
|
 |
I've got a util class which contains a non-Generic Hashtable.
class Person {
protected Hashtable _lstProperties;
public Hashtable Properties { get { return _lstProperties; } set { _lstProperties = value; } } }
And property really is a template class ...
class Property<T> { ... }
And Silverlight stipulates that every collection be System.Collections.Generic - this means even if I hand out the source code, it can't be consumed from Silverlight.
Is Silverlight Team basically saying there'll be no need for collection of unknown types in future? That everything SHOULD be know in compile time? They actually call Hashtable OBSOLETE? Anyone has email to silverlight and WPF team?
|
|
|
|
 |
 | Can't reference a Silverlight library from say Console/Winform HelloWorld? |  | devvvy | 23:10 15 Feb '09 |
|
 |
duplication of development effort - example UtilLib.RegularExpressionUtil
Since I can use my good old lib from Silverlight by adding a reference to it, I'd have to basically copy and paste RegularExpresionUtil.cs from project UtilLib to SilverlightUtilLib. This is very error prone as this is not the only class. So I thought, hey, I can still add reference to "SilverlightUtilLib" from "UtilLib"!
So I thought okay all i need to do is to put those common classes in SilverlightUtilLib. Then UtilLib to add reference to "SilverlightUtilLib", which would be consumed by my infamous Winform/console Hello World.
In SilverlightUtilLib
public class RegularExpressionUtil { public virtual bool IsEmail(string strText) { ... } }
UtilLib references SiliverlightUtilLib
public class RegularExpressionUtil { ... public override bool IsEmail(strnig strText) { ... different implementation ... } ... }
So far so good. Solution get built successfully however running time error saying cannot load System library, see below.
void main(string[] args) { ... if(Util.RegularExpressionUtil.IsEmail(strText)) // Runtime error saying "Could not load file or assembly 'System, Version=2.0.5.0, Culture=neutral ..." { Conole.WriteLine("Yes"); } ... // make another try call direct to base implementation in SilverlightUtil also failed with same error message if(SilverlightUtil.RegularExpressionUtil.IsEmail(strText)) { Conole.WriteLine("Yes"); }
So, this tells me while you can reference a Silverlight lib from a non-silverlight lib library, Silverlight uses a different "System" and you'll run into runtime error.
This brings me to my questions: 1. Is my understanding right? Silverlight and non-silverlight apps references difference "System" so you cannot call silverlight lib from non-silverlight library (if so I think M$ team should put appropriate restriction "Add Reference" dialog) 2. How would you make available many library function in UtilLib to SilverlightUtilLib? duplicating individual files is very error prone and labor intensive. (For your information I plan to make available DAO through WCF but basic function like string utility... seems like the only way is for me to copy and paste...)
I really don't like the copy and paste approach.
dev
|
|
|
|
 |
|
 |
I'm not sure about this particular case, but generally for things I need to share between .NET 3.5 and Silverlight .NET (for example, business objects), I use common source code shared by two projects - one targeting the Silverlight .NET framework, and one targeting .NET 3.5 framework. That way the source is in only one place.
Check the namespaces and classes used by your code - if they are implemented in both frameworks then you can use this approach.
Mark
Mark Salsbery Microsoft MVP - Visual C++
|
|
|
|
 |
|
|
 |
|
 |
Thanks to that this is exactly the kind of information I was looking for, good stuff!
dev
|
|
|
|
 |
|
 |
One final hurdle
class Person {
protected Hashtable _lstProperties;
public Hashtable Properties { get { return _lstProperties; } set { _lstProperties = value; } } }
And property really is a template class ...
class Property <T> { ... }
And Silverlight stipulates that every collection be System.Collections.Generic - this means even if I hand out the source code, it can't be consumed from Silverlight.
<div class="ForumMod">modified on Monday, February 16, 2009 8:35 PM</div>
|
|
|
|
 |
 | DataSet --> Pass from ASP.NET to Silverlight? |  | devvvy | 18:26 14 Feb '09 |
|
 |
hello
Mid way through my horror trying to port old library to Silverlight. One question
Can I pass, say, a DataSet/DataTable, from ASP.NET to Silverlight? If I could then I don't need to rewrite DAO I had...
Also is only way to access database from silverlight is through LinQ? I can't even use DbProviderFactory in my Silverlight lib! (world upside down)
Thanks
dev
|
|
|
|
 |
|
 |
In short, is there a way for me to grab a List from my hosting ASP.NET project, then pass it to Silverlight xap so I don't need to rewrite my DAO layer?!
My DAO done in combination of ADO.NET (not linq) and NHibernate.
My hunch feeling is - sockets?! But that's a lot of client-server traffic!! Can we feed xap/Silverlight with List BEFORE it's sent out to client instead of round tripping via socket (not to mention this architecture seems ugly!)
This article[^] showed how to pass data between ASP.NET and silverlight by way of QueryString but that's only suitable for VERY SIMPLE objects.
dev
modified on Saturday, February 14, 2009 11:48 PM
|
|
|
|
 |
|
 |
You can still use your conventional data access but you need to do so via a web service or via WCF. In my app. at work I started off using LINQ but later switched to conventional ADO. But I placed it all in a WCF service.
Kevin
|
|
|
|
 |
|
 |
Thanks yes. I am about to explore option Web Service+Silverlight. Socket is out of option because that'd make it an intranet solution (which is not our goal).
I'm still doing a lot of catch up, trying to figure out what WCF brings up and why I should use it instead of good old Web Service
dev
|
|
|
|
 |
|
 |
devvvy wrote: why I should use it instead of good old Web Service
One resaon is "In most cases WCF is significantly more performant (25%-50%) faster."
See here: Silverlight-enabled WCF Services versus ASMX Web Services[^]
However, there is nothing to stop you using Web Services if that's what you're comfortable with. It's what my current client is using at work because they're familiar with it. Nonetheless the knowledge of WCF required for Silverlight is no more complex than what is required for web services. There's also a Visual Studio template for a Silverlight-enabled WCF service that does the plumbing for you.
Eventually you will need to move to WCF regardless of what you choose now as that is MS's preferred technology moving forward.
Btw, the best intro I've seen to WCF is Michele Bustamante's Learning WCF. The first chapter is available online and you can learn a lot just from that chapter.
Kevin
|
|
|
|
 |
|
 |
I know I can consume C# Web Service from a Java client - what about WCF? Is there anything proprietary...etc?
I already scanned through couple articles just now, seems like you can host WCF service on any Visual Studio project type, from Winform to console to WPF. Same can be said for client. Is that right?
dev
|
|
|
|
 |
|
 |
devvvy wrote: I know I can consume C# Web Service from a Java client - what about WCF? Is there anything proprietary...etc?
Since WCF is a superset of Web Services, you should be able to do it from a Java client, but I have no experience of it.
Kevin
|
|
|
|
 |
|
|
 |
|
 |
Does anyone know when Programming Silverlight 2 [^] is released?
Amazon says 1 Feb but not yet released (Amazon UK doesn't even list it!). I've emailed each author but had no response thus far.
Kevin
|
|
|
|
 |
|
 |
there're plenty of resources on the web, good tutorial too but seems like they failed to mentioned horror in porting old dotnet lib to Silverlight....
a. NHibernate, log4net b. ISerializable and remoting (hum... why if they support socket!) c. System.Data.Common (DbProviderFactory no long avail and combined with (a) seems like I need to rewrite DAO, great!) d. App.config becomes App.xaml (I guess this is alright not too much changes) e. System.Collection - everything in typed collection! f. System.IO and file/directory access (Okay this makes sense)
dev
|
|
|
|
 |
|
 |
I know there are plenty of resources but I'm interested in this book based on
1. Jesse Liberty's Silverlight tutorial at the main Silverlight site is good. 2. I like him as an author.
I did have a brief look at Silverlight 2 in Action but it didn't seem very accessible.
Anyway, I've since found out that, as I suspected, it will become Programming Silverlight 3 and will now appear late in the year.
Re: your list, put it all behind WCF and you should be good to go.
Kevin
|
|
|
|
 |
|
 |
yes - i think WCF or good old web service will just do! No need to rewrite DAO layer.
dev
|
|
|
|
 |
 | good old .net C# class lib to used in silverlight app/lib? |  | devvvy | 22:06 13 Feb '09 |
|
 |
hello
I've got some .net C# class lib to used in silverlight app/lib? Problem is you can only add reference to other Silverlight lib from within a silverlight lib/app.
And also, how can you use nhibernate/log4net/spring from Silverlight?
Thanks
dev
|
|
|
|
 |
|
 |
devvvy wrote: I've got some .net C# class lib to used in silverlight app/lib
I guess you'll need to WCF-enable or Web-Service enable the class lib.
devvvy wrote: how can you use nhibernate/log4net/spring from Silverlight?
Don't know about NHibernate. But re: logging, there's an open source project called CLog that covers this. I've bookmarked it but not looked into it yet.
Clog[^]
Clog - Client Logging, Silverlight Edition[^]
Kevin
|
|
|
|
 |
|
 |
gosh ... I really feel like world upside down today
a. NHibernate, log4net b. ISerializable and remoting c. System.Data.Common (Combined with (a) this means I need to rewrite all DAO! I am impressed at the thoughts given to backward compatibility!) d. App.config e. System.Collection - everything in typed collection! (why now!) f. System.IO and file/directory access (okay this makes sense)
Migration to silverlight proves to be
dev
|
|
|
|
 |
|
 |
You're not going to be able to use anything except libraries targeting the Silverlight .NET framework.
Also remember Silverlight apps run with strict security restrictions so even things like writing to local storage (with the exception of Isolated Storage) is not possible.
Mark
Mark Salsbery Microsoft MVP - Visual C++
|
|
|
|
 |
 | Silverlight ScaleMode does not work (solved) [modified] |  | Kevin McFarlane | 23:29 12 Feb '09 |
|
 |
When I set ScaleMode="Stretch" or ScaleMode="Zoom" as in this article
Silverlight Tip of the Day #81 – How to Scale your Silverlight Control[^]
the control just disappears with no error messages. Any ideas?
Update: I've gotten to the bottom of this now. I created a new app. and it worked. It turns out that in my existing apps. my user controls were missing width and height that had been removed for other reasons. These are also necessary if you use transforms such as ScaleTransform or TranslateTransform. In my previous experiments I had specified the width and height in code but this won't work for the ScaleMode setting. It needs to see them in the XAML I think.
Last modified: 2hrs 16mins after originally posted --
|
|
|
|
 |
 | Resizing of Silverlight content according to screen resolution |  | Kevin McFarlane | 10:50 12 Feb '09 |
|
 |
I've been trying to solve this problem without success for a couple of days. I discovered this post
How About Some Code? Simple Scaled Resizing In Silverlight 2 Beta 1[^]
This is really about resizing the content as the browser resizes within the same screen resolution. But I thought it would be a useful place to start. The problem is that it breaks down when I switch down from 1280 x 1024 to 1024 x 768, e.g., text no longer fits, etc. Is there a way of automatically resizing fonts for different screen resolutions or do I have no choice but to apply a scale factor to each conrol individually?
Kevin
|
|
|
|
 |
 | Global.asax in Silverlight? |  | devvvy | 5:18 12 Feb '09 |
|
 |
Global.asax in Silverlight? I see there's a web.config (to my delight actually, just installed Silverlight it's my first try) but where would you put global init code in a silverlight app?
Thanks!
dev
|
|
|
|
 |