Approach For Handling Global Application Object?

Jun 15, 2009

What is the recommended way in VS.NET to have a global application handler object? Something that can load/verify/return user folders, settings, application specfic settings, manage the unhandled exceptions, etc. I would have a class that has most of the code, then subclass it for each application.

I can create one if I start as a module instead of a form. But then I lose some options such as NetworkAvailabilityChanged, etc. I define a "Public" object from within a form (I don't think so and don't feel this would be the right approach.)?can I "attach" an object to an existing global object store (such as "My."), etc.?

Once created, any object in my application should be able to reference methods/properties of this application object to get default folders, user values, etc. as necessary.

View 6 Replies


ADVERTISEMENT

Exception Handling In Winforms Application Using A Global Error Handler?

Sep 9, 2009

I have a Windows Form application that has a global error handler to display unexpected errors.

Namespace My
Class MyApplication
Delegate Sub ProcessParametersDelegate(ByVal sender As Object, ByVal args() As String)

[code]....

1) for the same deployed code, I SOMETIMES get line number in the displayed StackTrace error message and sometimes do not, even when the error message includes source code that I have written rather than a referenced binary. The project is compiled with a DEBUG configuration.

2) The application strangely minimizes to the tray when the error occurs (I thin it is unlikely that anyone can diagnose this issue w/o my more code posted, but I'll mention it anyways)

3) When I try to intentionally raise an error by, for example, dividing by zero hoping to test by global error handler, I get a dialog error message from the interactive debugger rather than jumping into my global error handler (which i want to debug because there is more to it than I posted.) Do you have any idea how to triggerand force teh execution of the global event handler?

View 2 Replies

VS 2005 Approach To Handling Multiple Tables?

Dec 7, 2010

I started out with just one table called products but I had problems with doing an update; it said sql to complex which was because the product table had nearly 100 columns in. The products table consists of header information like product quality, colour etc. Then there are 3 blocks of columns which mainly consist of a size as being the column name and a quantity as being the value. I have put these in three seperate tables to get around the SQL update problem. My problem is what is the best way to code this. The tables link to the header table using an autonumber primary key.

[Code]...

View 2 Replies

VS 2008 Project / Application Global OleDbConnection Object

Jun 17, 2009

I need a single, global OleDbConnection. One which will be available to use throughout my app/project. Another project like a custom UserControl? I should mention I'm not using TableAdapters, BindingNavigitor, etc. The datasource is not associated with my project. I communicate with the Db through code I write. I'm just a hack trying to ride with the big dogs while I develop an app for my job... We were/are in the stone-age!!!

View 7 Replies

Changing The Object Declarations To Global Using The 'global' Keyword Evertime?

Mar 15, 2012

evrytime i add new controls to a form in vb.net the designer regenerates code and asks me to make corrections, so i have to keep on changing the object declarations to global using the 'global' keyword evertime it regenarates code,especialy dataset objects.how can i prevent this?

View 1 Replies

MDI Global Error Handling - Nothing In Try Catch Block

Nov 21, 2008

I normally use the following for global error handling:
Code:
Dim currentDomain As AppDomain = AppDomain.CurrentDomain
AddHandler currentDomain.UnhandledException, AddressOf MYExceptionHandler
AddHandler Application.ThreadException, AddressOf MYThreadHandler
I normally don't have a MDI application, and When I force an error, neither of the events get fired. I don't have anything in a try catch block. How do I do this with a MDI application?

View 2 Replies

VS 2010 Easy Global Numeric Key Handling?

Oct 5, 2011

I have an application which is strictly numeric input only, for everything in the main form, call it X in this post.

I want every single control that can handle input in X to only accept numeric entries, I have a way of doing this but it requires me to put a tonne of arguments for the handle, I tried to change this to handle any .KeyPress event on MyBase or Me (X) but it won't work.

Code that works but requires 1 000 arguments:

Private Sub numeric_keys_only(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles msTEXT.KeyPress, ssText.KeyPress etc...

[Code]...

I have tinkered with the latter, specifying things like all the controls in a certain group box and it doesn't work.

I know the sub header has to be changed - I have changed it in my tests, that is just the example code. When I change everything it runs, just doesn't do anything.

View 2 Replies

General Exception Handling Without Global.asax File?

Mar 21, 2012

I was wondering if there was a way to catch all unhandled exceptions in a visual studio project. My project does not have any files named global or global.asax so I was wondering if there was some other way to catch any and all unhandled exceptions? So far I've tried to put exception handling around specific blocks of code, but it doesn't have any effect.

View 3 Replies

.net - Try Catch Finally Blocks.. Do I Still Need Them When Handling Errors In The Global.asax

Jun 2, 2010

I am handling errors via my global.asax in this method:

Dim CurrentException As Exception
CurrentException = Server.GetLastError()
Dim LogFilePath As String = Server.MapPath("~/Error/" & DateTime.Now.ToString("dd-MM-yy.HH.mm") & ".txt")
Dim sw As System.IO.StreamWriter = New System.IO.StreamWriter(LogFilePath)

[code]....

In my code I currently have no other error handling. Should I still insert try, catch, finally blocks?

View 1 Replies

Best Approach To Update Wrapped Object?

Apr 24, 2012

I'm using VB.NET but this question applies to any OO language - Java, C# etc. I've tagged the question with Java and C# but will remove if not considered appropriate. I have an entity class ClassAAA that contains a reference to ClassBBB as one of it's attributes:

Public Class ClassAAA
Private Property _blah As ClassBBB = Nothing
Private Property _somethingElse As String
Private Property _anotherthing As String
' Make it private so cannot instantiate class without supplying ClassBBB '
[Code] .....

I could make the ClassBBB reference public (or supply a public getter method) but that would expose the inner workings of ClassAAA. What I'm thinking of doing is making the ClassBBB reference Friend so that it is only visible in the assembly i.e. a data layer and is not visible to client projects. But this stills feel like I'm exposing the inner workings of the class.

View 3 Replies

Looping Through A Dataset - Object-oriented Approach

Feb 25, 2012

The problem is as follows, a group of users (~50k) must be filtered from a DB, four fields for each user must be saved into a variable, then a second process will take each user and proceed to enable some licences into another system/platform. Both processes will be developed into the same application.

My first attempt was basically a query looping through the users but I wonder if thinking in objects is a better approach.

I was thinking in a structure inside an object to hold the 4 parameters, then pass each user object to the other object however considering the amount of data I'm not sure if this is fine.

View 1 Replies

Create A Global Object But Have The Events Within That Object Fire On A Separate Thread?

Oct 26, 2009

I have an object that is defined as a global variable based on custom class. Within that class I have an event that gets fired a certain intervals. These events are fired on the same thread as where the object is declared. How do I create a global object, but have the events within that object fire on a separate thread?

View 2 Replies

Approach Custom Invoice Application Using Word?

Jun 8, 2010

Here at my company we have an Access application that allows users to create documents based on invoices that are in Great Plains. Documents such as invoices, packing lists, export documentation, etc., etc.This application is very old and very hard to maintain so we're doing a rewrite and I've chosen this project to be my first Visual Basic .NET project.

View 5 Replies

Create Global Object In .NET?

Apr 1, 2011

I'm trying to build a language dictionary in VB NET in order to be able to have several languages in the application.This dictionary has a init method that loads from database the entire dictionary and stores it in memory.In the rest of the classes of the project, I added the reference and I can use directly the object without create a new instance because their methods are shared.

how i have to load the dictionary content in order that the rest of classes only accessing to Language.GetWord method obtains the properly record of the collection, same way as My.Settings class.When My.Settings is used from any class the values are loaded. I'm looking for the same effect.This is the code of the class:

Public Class LanguageProvider
Private Shared CurrentLanguage As Collection
Public Shared ReadOnly Property GetWord(ByVal Label As String)

[code]....

Function LoadLanguage must be called when the application loads, in order to access once to database. After that property GetWord must access to the collection with the words and return the result. The problem is that the instances are not the same and the dictionary is not loaded when a class uses it.

View 1 Replies

How To Declare A Global List Object

Jun 8, 2012

I would like to declare a list above Sub procedure and to be able to add/modify it. I would like to have something like this:

[Code]....

When i run the above example i get an error like: Object reference not set to an instance of an object.

View 1 Replies

VS 2010 Global Object For Custom Class?

Feb 24, 2011

This is also posted in the database development forum. As I think the same problem could apply to things other than connections, I am posting it here also. I have created a custom class. All methods in this class, I want to interact with a single connection object.

Imports MySql.Data.MySqlClient
Public Class clsRegTester
Private cn As New MySqlConnection

[code].....

View 6 Replies

Access The Page Object In Global.asax In The PreRequestHandlerExecute

May 31, 2010

I have a huge website (containing around 5000+) pages. There is a theme functionality in the website where user can choose different colors for their profile. Now i want to use the ASP.net theme feature and put different CSS (for different colors) in the theme folder and in Global.asax i want check the user theme and render appropriate link element with the css. But my problem is, i am not able to access the Page element for adding the link in the page. Here is my code

Dim page As System.Web.UI.Page = TryCast(System.Web.HttpContext.Current.Handler,System.Web.UI.Page)
page.StyleSheetTheme = "Black"

But when i run this code I get a Null reference error.

P.s : My application is very huge so its not possible to have a master page or a base class and inherit it in every page.

View 2 Replies

VB2010 - Call Application.Run() In Application Without A Form - "Object Reference Not Set To An Instance Of An Object

Nov 12, 2009

My problem is when i try to call Application.Run() in a application without a form i get "Object reference not set to an instance of an object." when i run it outside VS. but if ran in debug or release mode it works just fine. i may just be forgetting to setup application right, but ive done it before in this same manor and it worked fine.

Sub main() 'this runs first.
AddHandler Application.ApplicationExit, AddressOf ExitEventHandler
dbg_f("handle added")

[CODE]...

Commented out init_timer and init_ready, and now it causes the same error for the myName line. there seems to be something wrong with class Application. btw theres seems to be something wrong with the forum code formatting.

View 4 Replies

Serialization Fails Because A Form Is Handling A Custom Object's Event

Aug 12, 2009

My application's binary serialization was working well up to today (this is not a released app yet - still in development). I have a "Project" class that is the top-level class of a hierarchy of other classes related to its function. And before you think it, yes, all of those classes are marked as serializable. Infact, they all were being serialized before today.

I have one event on the Project class that assists in informing when the project's save status has changed (i.e. new, modified, saved). This event was added today along with some events on the other classes that filter up to the Project class (the project needs to be told when its objects have been modified). I unfortunately added all of this at the same time so I can't provide any incremental details as to when it stopped working, but when I try to save the project through my binary formatter it tells me that my main form is not marked as serializable. Well, yeah... of course it isn't! it shouldn't need to be because there is no member of my classes that even mentions the form. But for some reason handling the Project's event on the form triggers this error.

Serializing the form is not a solution. Neither is not being able to handle my Project events. If I comment out the handler it works fine -- and I don't even have to remove the WithEvents keyword on my form's Project variable. Now that I write that I'm speculating that it may have to do with the event being raised as a result of the serialization (occurs when the save button is clicked).

View 7 Replies

Global Instance In MDI Application

Apr 29, 2011

given a MDIParent Form and 2 MDI Children: frmChild1, frmChild2..How can i realize a Instance of MyClass in MDIParent, which I can read and write from frmChild1 and frmChild2 , too

View 4 Replies

C# - Application Variables Global To Webgarden?

Jan 12, 2010

I am currently trying to program an online drawing program using the HTML5 canvas.the thing is, I need to have the current canvas saved somewhere globally. Static variables work, but they do not get shared across a Webgarden. This results in two different drawings being created.I will have to somehow create a new application object which is shared. I figured I will need an external application holding them.

1) How do I replace the application object with my own?
So either I will have to make my own program and call to it with remoting or use the ASP.NET session state server for application variables. I favor the Session State Server though.

2) How do I use the session state server for my own variables? How do I access it?

I searched high and low on the internet and only found the ideas mentioned above, but no help executing them.

I mainly code in VB.NET, but I can also understand C# code for examples.

A little info on my application:The client side has two canvas objects on top of each other. The top canvas object us used for drawing stuff, the canvas object below it holds the drawing in the end.When something is drawn, it is sent to the server in it's base64 representation. (getDataUri).The server puts this graphic on top of a stored Bitmap object through a Graphics object.

How the changes are being distributed to the other clients, I am working on that right now. Either I transfer the complete picture or each and every change that is submitted. This should work through Server Push. If this does not work thoroughly I will have to save and timestamp changes. A link to the current implementation, which is not currently fetching changes (but they get transfered to the server... With the problem that some reach one instance some reach the other on either w3wp in the webgarden) from the server is here: http:[url].....

View 1 Replies

Create A Global Function To Use Throughout The Application?

Jul 7, 2011

I want to create a global function to use throughout my application. Let say it's about the connection to the database.My code that i plan to use in my global function is:

myConnection = New SqlConnection("...........")
myConnection.Open()

So that I can call it to use in every form throughout my application. This can make me easy to edit the connection later.how to define this global function and how to call this function in the form.

View 2 Replies

Defiine A Global Variable For The Whole Application?

Aug 26, 2009

How do I defiine a global variable for the whole application so that it does not have to be defined in all the forms that need it.

View 6 Replies

Global Hotkey Working For Application

Mar 17, 2012

I have implemented a global Hotkey into my code but the problem is that when I move the focus from the form to IE (For Example) i cannot use the Hotkey from my application. Everything is working great if I was to stay int the form but that's not the purpose of this code.

Private Sub frmMain_Load(ByVal sender As System.Object, e As System.EventArgs) Handles MyBase.Load
RegisterHotKey(Me.Handle, 9, MOD_ALT, VK_F9)
End Sub
Private Sub frmMain_FormClosing(ByVal sender As Object, e As
[Code] .....

View 8 Replies

.net - Global Entity Framework Context In WPF Application?

May 20, 2010

I am in the middle of development of a WPF application that is using Entity Framework (.NET 3.5). It accesses the entities in several places throughout. I am worried about consistency throughout the application in regard to the entities. Should I be instancing separate contexts in my different views, or should I (and is a a good way to do this) instance a single context that can be accessed globally?

For instance, my entity model has three sections, Shipments (with child packages and further child contents), Companies/Contacts (with child addresses and telephones), and disk specs. The Shipments and EditShipment views access the DiskSpecs, and the OptionsView manages the DiskSpecs (Create, Edit, Delete). If I edit a DiskSpec, I have to have something in the ShipmentsView to retrieve the latest specs if I have separate contexts right?

If it is safe to have one overall context from which the rest of the app retrieves it's objects, then I imagine that is the way to go. If so, where would that instance be put? I am using VB.NET, but I can translate from C# pretty good. I just don't want one of those applications where the user has to hit reload a dozen times in different parts of the app to get the new data.

All contexts are created in Using Blocks to dispose of them after they are no longer needed.When loaded, all entities are detatched from context before it is disposed.A new property in the MainViewModel (ContextUpdated) raises an event that all of the other ViewModels subscribe to which runs that ViewModels RefreshEntities method.After implementing this, I started getting errors saying that an entity can only be referenced by one ChangeTracker at a time. Since I could not figure out which context was still referencing the entity (shouldn't be any context right?) I cast the object as IEntityWithChangeTracker, and set SetChangeTracker to nothing (Null).

This has let to the current problem:When I Null the changeTracker on the Entity, and then attach it to a context, it loses it's changed state and does not get updated to the database. However if I do not null the change tracker, I can't attach. I have my own change tracking code, so that is not a problem.

My new question is, how are you supposed to do this. A good example Entity query and entity save code snipped would go a long way, cause I am beating my head in trying to get what I once thought was a simple transaction to work.

View 2 Replies

Application Like A Shopping Cart - Global Variable?

Dec 27, 2011

My project is to create a shopping cart application. I have my main form and from there the user can go to two different forms to add books to their cart, the cart being the main form. This all works. What I can't figure out, is how to use global variables for the prices, shipping, tax and updating the total. I have places for this information to show up on the main form, and I've created a module for the calculations and prices, but I don't know how to code it to get the prices to show up in the specified areas.

View 3 Replies

C# - .NET Global Exception Handler In Console Application?

Jun 28, 2010

I want to define a global exception handler for unhandled exceptions in my console application. In asp.net, one can define one in global.asax, and in windows applications /services, one can define as below

AppDomain currentDomain = AppDomain.CurrentDomain;
currentDomain.UnhandledException += new UnhandledExceptionEventHandler(MyExceptionHandler);

But how can I define a global exception handler for a console application ?currentDomain seems not to work (.NET 2.0) ?

View 4 Replies

Use Global X As String In Vb6 In A Module To Declare It With Global Privelages?

May 1, 2009

i could use Global x as string in vb6 in a module to declare it with global privelages, how can i do this in vb2008? how to declare a global variable in vb2008? so that i could use it anywhere i want. i know global variables are not recommended in programming but i need one.

View 4 Replies

Typical Method For Handling Application Settings?

May 27, 2010

Was just curious to know if there is a typical method for handling application settings. I have two types of settings; Applications settings (like user preferences) and 'system' settings (server IP, options related to the industrial machine it's running on that need to be set at startup, ports that certain devices are attached to, etc). I was thinking that what I'm referring to as system settings would be in a configuration.ini type of file that can easily be edited. Then save the other settings either in the registry or a separate user.cfg file that would not be edited on it's own but changed through option settings in the program itself. Am I over complicating this? Is it normal to use the registry to store program settings or would it be better in a file?

View 2 Replies

VS 2008 - Handling Online Activation For Application

Feb 20, 2010

This is how I handle online activation for my application the problem is that this is very poor security because i display my Username and Password. I was thinking of using Myslq but i also have to input the Username and the password into the application. What other ways do big companies like Kaspersky handle online activation.

My code
Try
My.Computer.Network.DownloadFile("FTP SITE" + textbox1.Text + ".txt", "C:" + textbox1.Text + ".txt", "USER", "PASS")
Dim auth As String = My.Computer.FileSystem.ReadAllText("C:" + textbox1.Text + ".txt")
If auth = Textbox2.Text Then
Kill("C:" + textbox1.Text + ".txt")
[Code] .....

View 9 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved