locked
Sharing Code Between a C# and a VB Project RRS feed

  • Question

  • I have two projects: one in C# and one in VB.  The c# project needs to use a widget in the VB project, but it needs to pass in a collection of business objects which are defined in the C# project.

    What's the best way to accomplish this?

    Thanks.

    Tuesday, February 1, 2011 8:31 PM

Answers

  • You'll need to make a third project (in VB.NET or C# - your choice)  that has the definition for the business objects.  Both the C# and the VB.NET project can add this as a reference, and it should work properly.

     

     


    Reed Copsey, Jr. - http://reedcopsey.com
    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    • Proposed as answer by Yves.Z Thursday, February 3, 2011 6:07 AM
    • Marked as answer by Yves.Z Sunday, February 20, 2011 6:47 PM
    Tuesday, February 1, 2011 8:47 PM
  • C# and VB can share objects without issue the beauty of CLR.  Create a DLL in either c# or VB doesnt matter, and put your business object classes in there.  Then just reference the DLL in both projects.
    • Marked as answer by Yves.Z Sunday, February 20, 2011 6:47 PM
    Tuesday, February 1, 2011 8:58 PM

All replies

  • You'll need to make a third project (in VB.NET or C# - your choice)  that has the definition for the business objects.  Both the C# and the VB.NET project can add this as a reference, and it should work properly.

     

     


    Reed Copsey, Jr. - http://reedcopsey.com
    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    • Proposed as answer by Yves.Z Thursday, February 3, 2011 6:07 AM
    • Marked as answer by Yves.Z Sunday, February 20, 2011 6:47 PM
    Tuesday, February 1, 2011 8:47 PM
  • C# and VB can share objects without issue the beauty of CLR.  Create a DLL in either c# or VB doesnt matter, and put your business object classes in there.  Then just reference the DLL in both projects.
    • Marked as answer by Yves.Z Sunday, February 20, 2011 6:47 PM
    Tuesday, February 1, 2011 8:58 PM
  •  

    Hi Araron Edwards,

    We are marking this issue as "Answered". If you have any new findings or concerns, please feel free to unmark the issue.

     

    Best regards


    Yves Zhang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Sunday, February 20, 2011 6:47 PM