Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Visual-Studio VB.NET Forms , +
Hey,
 
I'm writing a Windows Form Application and I have two projects in the solution. I've added a project reference to reference the two projects to each other. I'm trying to open a form on the other project, but I get the 'Reference to a non-shared member requires an object reference.' error when I try to use this
 
Launchform.show()
 
I've already added the Imports Project2 line which gives me access to the classes, but they won't give me access to the forms where I can use Form.Show(), Form.Close, Form.Focus, etc.
 
Is there any way I can share the forms across the projects?
 
Thanks for any help Smile | :) ,
Chris
Posted 30-Jun-13 14:44pm
CoolC22449
Comments
ThePhantomUpvoter at 30-Jun-13 19:47pm
   
You might need to share a bit more of your code but have you tried,
Dim l as Launchform = new Launchform()
l.Show()?

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

This problem has nothing to do with "projects". First thing you should understand is that the "project" does not exist during run-time. The project is the artifact which is nothing but the data used to build an assembly. Only assemblies are the players during runtime.
 
And you did not approach runtime, not even close, as you faced with the simplest problem. Your Launchform.Show() could not compile, because, judging by the error message, Launchform is a type, hopefully derived from System.Windows.Forms.Form and Show is its instance method. And the instance method needs a reference to some instance, not just type. For example, something like this could work:
Dim form As Form = New Launchform()
' ...
form.Show()
Again, it all has nothing to do with the fact you have to different project and more than one assembly in your application. Using multiple assemblies is very natural to .NET and is one of its bases.
 
What you really need is learning of the very basics of programming and, in particular, OOP. You need to understand type and their instance (object), managed references, value vs reference types, assemblies and modules, basics of projects and their builds, and so on.
 
—SA
  Permalink  
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Maciej Los 295
1 OriginalGriff 273
2 Aajmot Sk 234
3 Marcin Kozub 205
4 Richard MacCutchan 200
0 OriginalGriff 7,903
1 Sergey Alexandrovich Kryukov 7,127
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,820


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 30 Jun 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100