473,769 Members | 2,102 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to create application wide var?

I'd like to create an application wide variable in a winform app. I
can do this on my start up form by reading in some values from a config
file (since these values may change in the future) and assigning them
to a public var. From there, I'd always have to reference the start up
form. Is there a better way?

Thanks,
Brett

Dec 7 '05 #1
2 1468
You can create a class with static fields that you can access.

"Brett Romero" <ac*****@cygen. com> wrote in message
news:11******** **************@ o13g2000cwo.goo glegroups.com.. .
I'd like to create an application wide variable in a winform app. I
can do this on my start up form by reading in some values from a config
file (since these values may change in the future) and assigning them
to a public var. From there, I'd always have to reference the start up
form. Is there a better way?

Thanks,
Brett

Dec 7 '05 #2
Great! I actually created a DLL with a structure and reference them
from there, since it will be used across a few apps.

I do this through out my application. It is all winforms. I'd like to
put the code below into one place and reference it. It has to be an
instance as you can see. I want to abstract it somehow because the
enum references below could change and I don't want to go through the
app doing find/replace.

private ErrorHandling.L ogErrors ErrorHandler = new
ErrorHandling.L ogErrors(Config uration.ErrorLo gging.Tracker_E ventLogSource,
Configuration.E rrorLogging.Tra cker_EventLogNa me);

Brett

Dec 8 '05 #3

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

Similar topics

2
1666
by: Mr.Tickle | last post by:
Is it possible to determine when and what application crashed from within C# ? I want to send data over UDP to an application socket, and after that I want to determine whether its crashed or not and decide what to do next, like report the crash etc.and stop sending (AV'd etc), is this easy to do on C#?
3
2647
by: Jonathan Mcdougall | last post by:
I started using boost's filesystem library a couple of days ago. In its FAQ, it states "Wide-character names would provide an illusion of portability where portability does not in fact exist. Behavior would be completely different on operating systems (Windows, for example) that support wide-character names, than on systems which don't (POSIX). Providing functionality that appears to provide portability but in fact
1
1476
by: Jigar mehta | last post by:
Hye, How to create systemwide hooks for keyboard for keys like WIN, ALT+TAB, CTRL+ALT+DEL even when the application does not have the focus on it... Thanks,
6
1914
by: Shibu | last post by:
Hi, Can anyone tell me how to create a DSN from asp.net.. Thanks Shibu
16
3153
by: Fernando Arámburu | last post by:
Hi , it´s me again. I will take another way because yesterday I make a question and, probably I didn´t make myself clear so you didn´t understand my question. I want to know if there is any way to register a method to the Application Start event. I know there is one way, in Global.asax writing code in Application_Start
3
2369
by: Opa | last post by:
Hi, Been stumped for many, many hours trying to create a web service project. I greatly appreciate any help. I get an error everytime I try to use the Visual Studio.NET wizard to create a Web Service. The error is: Visual Studio.NET cannot create or open the application. Website 'http://localhost/WDWS' not started on this Web server.
2
1461
by: Mark Olbert | last post by:
I want to bind a series of ObjectDataSource instances to an application-wide business object which caches the results of a database query. I'm confused about where/how to cache the results (it's a simple query, BTW, so I'm using a DataReader, not a DataTable). The business object has no knowledge of the application, and hence of the Cache, which is where I would normally put this kind of thing (actually, I used to put this stuff in...
11
2350
by: Sylvia A. | last post by:
How can I define global classes in web application ? Classes can be set to session variables ? Thanks
3
5322
by: =?Utf-8?B?Um9nZXIgVHJhbmNoZXo=?= | last post by:
Hello, I would like to know the best way to install an clickonce in .net 3.5 (we use LINQ 8-D) published application on terminal server 2003 Do I have to install it on EVERY user that will use it ? If so, all the files will be duplicated for every user ? in wich folder ? If not, where will reside the application on the server ? how to make a shortcut for the main "executable" for all the users pointing to that ?
0
9422
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10208
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10038
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9987
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8867
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7404
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5444
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3558
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2812
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.