Skip to main content
Home Forums General Silverlight Getting Started From a Silverlight Web C# project ...call a VB class sub
4 replies. Latest Post by philip.beadle on November 6, 2008.
(0)
ScCrow
Member
44 points
107 Posts
11-02-2008 4:59 PM |
Im looking at rebuilding an old project in Silverlight that was originally written in VB as a windows application. Just to make it a bit harder...I saild, lets do it in C# and Silverlight. But at some point, it just wasnt worth it the conversion effort.
Then I noticed that I can create a VB class. This gets added to a folder Solution Items. I could put most of the worker subs there since they are already working and not have to start completely over.
I put in a test sub compiled and no errors. The problem is that I cant seem to find how to reference the Vb subs from my C# code behind pages. I dont see that there is any reference to add.
Sooo .. can be done? way off base? forget it? Bite the bullit and convert it? Just start over and do it in VB?
or (.best ) heres what you need to do
philip.b...
500 points
104 Posts
11-03-2008 12:05 AM |
The way to do it I reckon is add a Silverlight Class Library to your project in VB. Then add your VB code there and then reference the project from your C# Silverlight app.
Yi-Lun L...
All-Star
25052 points
2,747 Posts
11-04-2008 12:23 AM |
Hello, there's no way to reuse assemblies between Silverlight and desktop .NET. The CLR are completely different. Trying to reference a Silverlight assembly in a desktop application may cause a lot of runtime problems. If you're using the same language, you can share the source code but not the assembly. If you're using different languages, you have to create two different projects.
11-06-2008 1:34 PM |
I created the Solution as a SilverLIght C# project. Then I did an Add on the solution and selected new Item, then VB Class.
Seems to me that this should be available to the remainder of of the solution. If this is creating a .desktop .NET., then its mis-leading at best since this is a SilverLight Solution.
So in the long run, I guess the question is how does one create and execute a VB sub from the vbClass a C# project in Silverlight. Or maybe you just cant. Maybe I need to create a Class LIbrary. I have not tried that yet since I thought the other would work.
This has become a non issue for me. I have moved everything over to a VB solution instead of C#. Still, I would like to know the answer. It would be nice to have a class library that could be called from either VB or C#.
Regardless, thanks for the reply.
11-06-2008 5:36 PM |
Teu but you can add build directives to the class that will exclude the parts of the class that wont build against the Silverlight CLR. You still need to rebuild the assembly though against both .Net and Sivlerlight .Net.