Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
| Search | Today's Posts | Mark Forums Read
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old August 16th, 2004, 09:41 AM
Authorized User
 
Join Date: Mar 2004
Location: Maumee, OH, USA.
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default Passing info between assemblies & projects

Does anyone know how you can pass information between projects and/or assemblies? For instance, if I had a global variable in project 1 is there a way project 2 can look to see what it is set as? The same goes for assemblies.
  #2 (permalink)  
Old August 16th, 2004, 12:05 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

If I may clarify something: A project is not a run-time entity. All code in a project is compiled into an assembly. An assembly is just an assembly of classes, it doesn't really have a run-time context.

I would recommend you pass the information to methods of the assembly's classes. You can't have a global variable in an assembly (you can create constants within the namespace covered by an assembly, but of course, those are global variables). You can create global fields in a class and set those or pass the data into methods. Apart from the fact that it really can't be done, designing a system that relies on totally global variables is kind of bad. It will make things very hard down the road when you are trying to track down where one of those variables is getting set. I'd heavily recommend re-thinking your design.
  #3 (permalink)  
Old August 16th, 2004, 12:23 PM
Authorized User
 
Join Date: Mar 2004
Location: Maumee, OH, USA.
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default

What I am really curious about doing is having projects that are in the same solution access the same object. For instance let's say I have a solution called Application. In the solution I have three projects, proj1,proj2,and proj3. I create an object in proj1 that has properties and methods. While coding proj2 is there anyway to access the object I created in proj1? Is passing it into proj2 an option? If so - how?

From your earlier post it sounds like it is not doable but I wanted to verify I understood correctly.
  #4 (permalink)  
Old August 16th, 2004, 12:38 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

The object has to live within some context. The "project" or even the application has no context. The first executing entity (such as a form or web page) has context. So an instance of an object could be global to a form and thus be accessible that way (by that and other forms). What you are explaining is too abstract.

If you are dealing with a single application (made of multiple projects) you could most certainly code functionality such that you can hand a class instance around when you call methods. This is done all the time starting with simple variables. What kind of projects make up your application? A single project can be a class library or an actual executable program so it would be a great help if you further explained what you are building, if indeed this is a practical discussion and not just a theoretical one.
  #5 (permalink)  
Old August 16th, 2004, 01:26 PM
Authorized User
 
Join Date: Mar 2004
Location: Maumee, OH, USA.
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This would be one application. Most if not all the projects would be VB.NET projects, perhaps a few class libraries.

An example might be where project1 contains a form, frmMain, and a class called cClient. This project is the default startup project and runs upon clicking the EXE. You can click a button on frmMain that creates a new Client object, gClient, which is a global variable on frmMain.

I would then like the user to be able to navigate to a form, frmStats, that is created in project2 along with passing in gClient.

Does this help paint a clearer picture?
  #6 (permalink)  
Old August 16th, 2004, 01:47 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Yes, that is a help. Thank you.

So you need to have these different applications talk to each other. I don't work with this type of scenario so I can't help you much more. What you are getting into sounds like dynamic data exchange (DDE) or whatever the .NET equivelant is. My work is primarily in ASP.NET applications so I'm not familiar with this type of programming.

Hopefully someone can join this thread and take over the discussion with more explanation of how you would acheive this in the .NET world.
  #7 (permalink)  
Old August 17th, 2004, 12:11 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Is there a reason why you don't put everything in the same project?

J
  #8 (permalink)  
Old August 17th, 2004, 07:40 AM
Authorized User
 
Join Date: Mar 2004
Location: Maumee, OH, USA.
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Right now it's just experimentation. In the future I think it would have more advantages in a team setting if one person preferred to code in say C#, the other in VB. Also, it may have some practical purposes if you were developing a modular type application.
  #9 (permalink)  
Old August 17th, 2004, 08:11 AM
Friend of Wrox
Points: 3,489, Level: 24
Points: 3,489, Level: 24 Points: 3,489, Level: 24 Points: 3,489, Level: 24
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Central, NJ, USA.
Posts: 1,101
Thanks: 0
Thanked 2 Times in 2 Posts
Default

This has no practical purpose in a well designed system. There is no problem, in a team setting, with objects copiled from different languages being in the same Solution. HOWEVER, a professional development team will establish standards and have everyone stick to them. What happens if the one person on your team that chose to use perl.NET leaves and now someone needs to maintain that code?



Hal Levy
Web Developer, PDI Inc.

NOT a Wiley/Wrox Employee
  #10 (permalink)  
Old August 17th, 2004, 08:42 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

I agree with Hal. While you can work in multiple languages, most managers (at least the ones that I have worked with) will want to keep everything as uniform as possible.

If you want something for team development, you would be better off building classes that can be accessed by other members of the team but not changed.

J




Similar Threads
Thread Thread Starter Forum Replies Last Post
Help passing login info to new page peterh Classic ASP Basics 4 January 10th, 2008 12:39 PM
HELP:Join & Split Projects/soln Aritra ASP.NET 1.0 and 1.1 Basics 4 March 2nd, 2007 03:04 AM
Passing Database Logon Info happyslug BOOK: Professional Crystal Reports for VS.NET 1 February 14th, 2005 08:48 AM
Passing logon info sandeep Crystal Reports 1 October 6th, 2004 08:41 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.