Use Object Initializers In A Factory Pattern?
Mar 30, 2012
I have written a base class from which I wish to derive several child classes (in this case Windows Form classes), and I'm using a Factory pattern in order to maintain a collection of the child instances, so that a form can only have one instance per primary key value. (sort of a mash-up of Factory and Singleton patterns.)
I'm using the following code in the base form class[code]...
View 2 Replies
ADVERTISEMENT
Jun 22, 2009
when should a trigger in your head go off signifying "Aha! I should use the factory pattern here!"? I find these moments will occur with many other design patterns, but never do I stop myself and think about this pattern.
View 6 Replies
Mar 1, 2011
[code]I want to write a simple text based rpg game very simple that uses the abstract factory pattern. It will be a choose your own adventure style read and options like 1.run 2.fight 3.bribe your way out of it 4.talk your way out of it, really simple. Would i create a thing pattern, then have factorys like creatures, items etc.
View 5 Replies
Mar 18, 2010
So I've been doing some research on the singleton factory design pattern, and I am wondering if my example implementation is correct (warning I did get carried away creating animals):
[Code]...
View 6 Replies
Jan 27, 2010
Whenever I try to create a new CD object I get a stack overflow. I want a parameter to be passed into mediaFactory so that it could be determined what type of media is created. Why I might be having problems with this when I do this
"Dim media As CD = New CD()"
Public MustInherit Class MediaFactory
Inherits MediaContext
Implements IMedia
Public Sub New(ByVal typeId As Integer)
[Code] .....
View 2 Replies
Mar 18, 2010
We have a serial port which is connected to hundreds of physical devices on the same wire. We have protocols like Modbus and Hart to handle the request and response between the application and devices. The question is related to managing the reference count of the channel. When no device is using the channel, the channel should be closed.
[Code]...
View 2 Replies
Sep 5, 2009
having difficulty with understanding object lifetime / instantiation.I have a windows from with a datagridview and a panel. The datagridview has a checkbox column and a list of names which is populated from a database.The panel has a few text boxes (e.g. name, age, favourite sports team) and a 'save changes' button.
The idea is that when the user selects a person in the datagridview by checking the appropriate checkbox then the panel shows the relevant data for that person (name, age, fav sports team) by pulling the data from a database. If the user would like to update the person's details they can do so by typing in the textboxes and then clicking the 'save changes' button. All quite simple so far.
The way I have designed this is to have a 'panel' class and to create an instance when the user checks a checkbox.(NB - the reason I have created a 'panel' class is that I intend to replicate the datagridview and panel on other tabpages within my form and thought it would be useful to have a generic 'panel' class that I could re-use.)
My code looks a bit like this:
If CheckBoxClicked Then
Dim UpdatePanel As New UpdatePanel(MyForm.NameTextBox, MyForm.AgeTextBox, MyForm.FavSportTeamTextBox, MyForm.SaveButton)
UpdatePanel.GetData()
...
When the user clicks the SaveButton the data is updated to the database and I have a display message (simple textbox) which says "Update successful" and displays for 5 seconds before hiding itself.
Here is the problem:Suppose a user checks a checkbox, reviews the data and does not make any changes, and then checks another checkbox and decides to update the data by clicking the 'save changes' button. What happens is that the "Update successful" message is displayed twice.
I think this is because every time the user checks a checkbox an instance of UpdatePanel is created. If a I select five different people using the checkboxes and then hit 'save changes' I get five "Update successful" messages.
I am not sure how to overcome this. It feels like each time a checkbox is clicked I need to check if an instance of UpdatePanel exists and then destroy it. I tried using UpdatePanel = Nothing and also investigated IDisposable and GC.Collect() but with no luck.
[code]....
View 1 Replies
Apr 3, 2012
Question:Given a SQL string like
CREATE VIEW TestView AS
SELECT value1, value2
FROM TABLE_0[code]...........
for each strObjectName in tables, to check whether or not the view depends on this object.But this fails on table_12 (and results in cyclic dependencies) for example, because tables contains "table_1". Aaargh.I need a regex that can check if the view definition contains a function name, table-valued function or another view...
(
For checking with
System.Text.RegularExpressions.Regex.IsMatch([code].....
But it fails, plus it doesn't account for object names embraced in brackets, like
"[TABLE_NAME]"
View 3 Replies
Sep 14, 2011
I want to translate this C# code into VB.NET 2010:
using System.Activities;
using System.Activities.Statements;
using Microsoft.VisualBasic.Activities;
[code]....
View 10 Replies
Jan 5, 2010
ok this is annoying, i've got a structure RInteger.
Private VAR_Value As Integer
Private VAR_Max As Integer
Private VAR_Min As Integer
[code]......
View 5 Replies
Jul 3, 2009
First the requirements: By management requirements, I can't use open source code. I need the users to define their own formulas for a project. My users don't know how to code. The formulas need to be saved somehow, and being read later. I need to debug the formulas written, so I need to be able to see and understand them. The formulas used are quite specialized and specific (actuarial formulas). Adding new formulas (functionality) must be done in fast and maintainable way.
[Code].....
View 2 Replies
Feb 2, 2010
Using vs2008, vb.net, C#, fw 3.5
I am consuming my service in my client
Service is hosted in IIS
Client(winforms MDI) is generated using svcutil using /l, /r, /ct, & /n switches
Service and client both use a MyEntities.dll
I am using nettcp with TransportWithMessageCredential. I cache the proxy in the main form
if Membership.ValidateUser(UsernameTextBox.Text, PasswordTextBox.Text)
_proxy = new MyServiceClient
_proxy.ClientCredentials.UserName.UserName = "username"[code].....
Could I subscribe to the _proxy.InnerChannel.Faulted and do that clean up there?
View 2 Replies
Sep 20, 2011
In Motorola MC55, I'd like to get the factory or unique id or serial no of the scanner. How to code it in vb.net?
View 1 Replies
Apr 18, 2011
I have set up a process to create new tasks to handle file processing. A problem arised where I received and unhandled exception error and just clicking on the continue button, the main process continued to run. Now I also found that within the child task I was having a file conflict error and as the tasks run as separate .exe i was under the impression that everything would have been thread safe. So for the first issue here is the task creation in the main process..GProcess is a complete project on its own consisting of 6 classes. This is added as a class library reference to the main process class form1
Public Class Form1
..Private parser as GProcess.module = new GProcess.module()
dim factory as new taskfactory
[code].....
View 1 Replies
Feb 22, 2011
I have integrated the innovative gateway (third party payment gateway) into our asp.net ( language vb.net) web application. while doing transation we are getting the following error in server.
Server Error in '/' Application.
Retrieving the COM class factory for component with CLSID {7A1284E2-7E00-46B5-8440-FC28305E6A27} failed due to the following error: 80040154.
But in my localhost am getting the failure transaction without getting any error.
View 11 Replies
Jun 13, 2011
I am trying to start a new thread in VB.Net and having syntax problems.In C# this is we can do the same task using
var manualResetEvent = new ManualResetEvent(false);
waitHandles.Add(manualResetEvent);
var taskOne = Task.Factory.StartNew(() => new Thread(TaskToRun).Start(manualResetEvent));[code]....
where TaskToRun is a void method with a single object parameter.All online converters generate similar code to this
Dim manualResetEvent = New ManualResetEvent(False)
waitHandles.Add(manualResetEvent)
Dim taskOne = Task.Factory.StartNew(Function() New Thread(AddressOf TaskToRun).Start(manualResetEvent))
taskOne.Wait()
View 1 Replies
May 6, 2011
I tried this one...but its not working.[code]...
View 1 Replies
Feb 12, 2011
How would I change this code to make the factory dynamic. I believe I was close with remoting. I don't want any hardcoding of the factory, nor do I want to have to recompile. The database drives it.
Dim genericRule As Rule
Dim factoryObject As String
factoryObject = _dal.GetFactoryObject(ruleId)
[code]....
View 1 Replies
Sep 26, 2006
I have a VB.NET application that references a 3rd party Com component. The file is Interop.WINTSRRLIB.dll. My VB.NET application has a project reference to the COM comonent which lives in the directory: C:WaveTracker. The application runs fine. When I sent it to my customer, he installed in on his desktop machine. It runs fine. Then he copied all of the application files (which live in C:WaveTracker) to his laptop. However, on his laptop, he gets the error:
"System.Runtime.InteropServices.COMException (0x80040154). Retrieving the COM class factory for component xxxx failed due to the following error: 80040154" The customer swears he has the .NET 2.0 Framework installed properly on his laptop. Any ideas on how I can get over this problem???
View 1 Replies
Feb 4, 2011
I am having a problem with a SQL server query giving a timeout error. I read about setting the timeout value of the command object but in my DAL, I do not see how to do that. Here is how I create the command object
Public Sub Init()
If ConnString = "" Then
Select Case ConnStringID
[Code]....
View 1 Replies
Apr 30, 2009
Is it possible to prevent compiler warning caused by a static factory method returning an instance of an obsolete class? For example if an instance of an obsolete class (Foo) is created through a static method (Create) a compiler warning is caused by the factory method.
<Obsolete()> _
Public Class Foo
Public Shared Function Create() As Foo
[code]....
In C# the warning could be suppressed using "#pragma warning..." but I don't think that this exists within VB.Net. Migrating to C# is not an option due to business requirements.
View 2 Replies
Jan 21, 2011
Is it possible to prevent compiler warning caused by a static factory method returning an instance of an obsolete class? For example if an instance of an obsolete class (Foo) is created through a static method (Create) a compiler warning is caused by the factory method.
<Obsolete()> _
Public Class Foo
Public Shared Function Create() As Foo
[code]....
In C# the warning could be suppressed using "#pragma warning..." but I don't think that this exists within VB.Net. Migrating to C# is not an option due to business requirements.
View 1 Replies
Aug 12, 2009
I found a lot of information about how to make a database factory or how to deal with connection pooling but i nowhere found a complete solution.I have always used my own solutions, but they're not complete i think or could be improved.Are there some good designed classes any of you use that i can find on the net?
View 1 Replies
Aug 26, 2011
I created a VB.NET application that takes in parameters from a javascript file, uses those parameters to then retrieve info from a database, then send back to the javascript. When I locally test the webservice however, this is the error message I get:Retrieving the COM class factory for component with CLSID {C2C0AFBE-102A-4A8D-A792-06B4063E863F} failed due to the following error: 8000401a.Everything I've googled on the error says it has something to do with the either a word or excel file... which the process has nothing to do with neither. [code]
View 7 Replies
Aug 31, 2009
I am getting the below error while i am using Microsfot excel interop. In my server there no excel installation. With out excel installation i want to export data to excel. So i used excel interop. But i am getting the below error.
Error: Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80040154.
I am using the below code. It is working, if the machine have excel installation, But i dont have excel installation in my server.
Dim lobjExcelApp As Excel.Application
Dim lobjExcelWrkBk As Excel.Workbook
Dim lobjExcelWrkshtFee As Excel.Worksheet
Dim lobjsht As Excel.Worksheet
[code]....
View 6 Replies
Feb 1, 2010
I have created a small SMS apllication with Windows application.Ihave used two dll called "lcgsmsms" and "Interop.excel".But even after adding all those dll ,while building my aplication
(1)it shows ambiguous column name and after debugging ,
(2)It shows SQL server could not connect remote connections and
(3)getting error "Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80040154."
View 1 Replies
Feb 19, 2009
Iam working with VB.net. I have used MsComm6.0 control in VB.net. It is working properly on my machine.But when i installs in a system in which .net is not installed it is giving an error
[Code]....
View 4 Replies
Dec 18, 2009
I have a line of code that is producing the error: Retrieving the com class factory for component with clsid failed error: 80040154 ADOX The line of code is:
Dim
ADOXTable As New ADOX.Table
This error only occurs on one computer.
View 3 Replies
May 24, 2010
I'm using task.factory to make threads and start having the "Cross-thread operation not valid" error when trying to update the main form.I search for this error and tried some examples of code, using delegate for example, but all result in some deadlock.
[Code]...
View 1 Replies
Apr 3, 2012
Getting error like :
Retrieving the COM class factory for component with CLSID , class not registered at RichTechSTK1.SIMToolkit, etc
having put MSCOMM32.OCX in windows/system32, and added relevant .dlls.
View 3 Replies