Skip to main content

Microsoft Silverlight

From a Silverlight Web C# project ...call a VB class subRSS Feed

(0)

ScCrow
ScCrow

Member

Member

44 points

107 Posts

From a Silverlight Web C# project ...call a VB class sub

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.beadle
philip.b...

Member

Member

500 points

104 Posts

Re: From a Silverlight Web C# project ...call a VB class sub

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.

Philip Beadle (DotNetNuke Trustee)

My Blog

My DNN Blog

(If this has answered your question, Mark as Answer)

Yi-Lun Luo - MSFT
Yi-Lun L...

All-Star

All-Star

25052 points

2,747 Posts

Re: From a Silverlight Web C# project ...call a VB class sub

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.

shanaolanxing - I'll transfer to the Windows Azure team, and will have limited time to participate in the Silverlight forum. Apologize if I don't answer your questions in time.

ScCrow
ScCrow

Member

Member

44 points

107 Posts

Re: From a Silverlight Web C# project ...call a VB class sub

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.

philip.beadle
philip.b...

Member

Member

500 points

104 Posts

Re: From a Silverlight Web C# project ...call a VB class sub

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.

Philip Beadle (DotNetNuke Trustee)

My Blog

My DNN Blog

(If this has answered your question, Mark as Answer)
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities