Click here to Skip to main content
13,048,846 members (78,464 online)
Rate this:
Please Sign up or sign in to vote.

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

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 :),
Posted 30-Jun-13 13:44pm
ThePhantomUpvoter 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()

1 solution

Rate this: bad
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()
' ...
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.


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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 30 Jun 2013
Copyright © CodeProject, 1999-2017
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