473,479 Members | 2,085 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Accessing static members of class in main Assembly

I've got a bit of a problem acceessing a class that I am using as a 'global'
placeholder of numerous static variables I'm using across the application.
Basically I need a place to store a reference to my MDIframe so I can access
it from anywhere.

I have a class called AppObj in a framework assembly. I inherited it in my
main application assembly and called it EPMApp. In my mainform (which is a
mdiframe) I am setting the EPMApp.MDIFrame to the form.

In a separate assembly where I want to open a new MDI child I am trying to
access the AppNameApp.MDIFrame but I cannot find a way to call it. I think
it is because it is in the main assembly. I keep getting the "The type or
namespace name 'EPMApp' could not be found (are you missing a using
directive or an assembly reference?)" compiler error.

I know I'm just doing something silly wrong but I'm not sure what it is. I
was able to move the inherited object into another assembly and then get
things to compile but there must be something wrong if I cannot reference
objects in my main assemble/exe.

could someone please fill in what I'm missing.

thanks

jack
Nov 16 '05 #1
6 1561

"Jack Addington" <ja********@shaw.ca> wrote in message
news:O8**************@TK2MSFTNGP10.phx.gbl...
I've got a bit of a problem acceessing a class that I am using as a
'global' placeholder of numerous static variables I'm using across the
application. Basically I need a place to store a reference to my MDIframe
so I can access it from anywhere.

I have a class called AppObj in a framework assembly. I inherited it in
my main application assembly and called it EPMApp. In my mainform (which
is a mdiframe) I am setting the EPMApp.MDIFrame to the form.

In a separate assembly where I want to open a new MDI child I am trying to
access the AppNameApp.MDIFrame but I cannot find a way to call it. I
think it is because it is in the main assembly. I keep getting the "The
type or namespace name 'EPMApp' could not be found (are you missing a
using directive or an assembly reference?)" compiler error.

I know I'm just doing something silly wrong but I'm not sure what it is.
I was able to move the inherited object into another assembly and then get
things to compile but there must be something wrong if I cannot reference
objects in my main assemble/exe.

could someone please fill in what I'm missing.

No. You're not missing anything. You cannot reference items in an EXE.
Only a DLL can be the target of a reference.

Why inherit the type in your exe? Just leave the type in a library and set
its value from code in the EXE.

David
Nov 16 '05 #2
<"David Browne" <davidbaxterbrowne no potted me**@hotmail.com>> wrote:
No. You're not missing anything. You cannot reference items in an EXE.
Only a DLL can be the target of a reference.


Note that this is a VS.NET limitation, not a .NET limitation. .NET
itself allows you to reference an executable instead of a DLL with no
problem.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #3
Why is that?

thanks...

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
<"David Browne" <davidbaxterbrowne no potted me**@hotmail.com>> wrote:
No. You're not missing anything. You cannot reference items in an EXE.
Only a DLL can be the target of a reference.


Note that this is a VS.NET limitation, not a .NET limitation. .NET
itself allows you to reference an executable instead of a DLL with no
problem.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 16 '05 #4
Jack Addington <ja********@shaw.ca> wrote:
Why is that?


Not sure, to be honest. While it's not useful hugely often, every so
often it's handy.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #5
The reason behind this problem is legacy OS support. Aka Windows 95
I believe. We had smiliar issues when certain languages started disabling
support for linking executables as references (aka vbc.exe). This may not
be 100% accurate, since this is an old issue I remember from when I
worked on the .NET QuickStart Tutorials pre-V1.

--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Jack Addington <ja********@shaw.ca> wrote:
Why is that?


Not sure, to be honest. While it's not useful hugely often, every so
often it's handy.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 16 '05 #6
Justin Rogers <Ju****@games4dotnet.com> wrote:
The reason behind this problem is legacy OS support. Aka Windows 95
I believe. We had smiliar issues when certain languages started disabling
support for linking executables as references (aka vbc.exe). This may not
be 100% accurate, since this is an old issue I remember from when I
worked on the .NET QuickStart Tutorials pre-V1.


Interesting. Of course, V1.1 doesn't even support Windows 95, so those
issues may have gone.

The common example I can think of where it would be useful would be for
a plugin architecture. If the plugin interface can be in the
executable, with no extra libraries needed, it's often possible to
deploy just the executable itself, making things a bit simpler.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3576
by: DanielBradley | last post by:
Hello all, I have recently been porting code from Linux to cygwin and came across a problem with static const class members (discussed below). I am seeking to determine whether I am programming...
2
1549
by: Ray Mitchell | last post by:
In my main dialog, which opens when my application starts and never closes until the application completes, I have a list box. My assembly also contains several threads. I would like to write to...
6
1609
by: Matt | last post by:
All of a sudden all my C# apps require the keyword static on all global fields and methods that I create. Even in the simplest of console apps. Can someone tell me what I have inadvertenly set in...
6
2794
by: mflanagan | last post by:
I have unmanaged C++ program that will load a managed C++ dll and then call a function in that dll. The managed C++ routine will call some C# routines. The unmanaged C++ main program will make...
12
2540
by: Joe Narissi | last post by:
I know how to create and use static constructors, but is there a such thing as a static destructor? If not, then how do you deallocate memory intialized in the static constructor? Thanks in...
5
5445
by: Ben | last post by:
Hello I have a protected variable in a class (Class A) that I need to call from another class (Class B) to modify. I thought what I had to do was create a public method in the class (Class A)...
4
5056
by: Ole Nielsby | last post by:
Here comes a generic class with a static property. Let's say they are exotic singleton pets. abstract class Pet {...} abstract class SharedPet<T>: Pet where T: SharedPet<T>, new() {...
1
1587
by: bg_ie | last post by:
Hi, I have my own UserSettings class that I wish to include within my windows application. To include it at the moment, I do something like this - namespace WindowsApplication1 { static...
3
2289
by: =?Utf-8?B?TkVXMi5ORVQ=?= | last post by:
I have a static event declared in a C++ ref class, that can then be handled in a VB app. I'm trying to expose the static event through the interface that the C++ ref class implements so the VB app...
0
6899
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7019
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6719
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
6847
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5312
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4757
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4463
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1288
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
166
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.