C# - Instantiate The Object To Use It In The Immediate Window?

Dec 13, 2011

If I have a console application containing the class

[Code]...

I'm not a VB.NET guy. Am I correct in assuming I need to instantiate my object first? Why does the VB.NET example differ?

View 1 Replies


ADVERTISEMENT

Instantiate Object From Class Using String Variable For Name Of New Object?

Aug 11, 2009

dim myCollection as new Specialized.StringCollection
dim myFoundThings as new ArrayList
dim index as Integer
dim newResultMemberName as String

[code]....

This is part of some code that will run without user interaction once it's spinning away, and I need to create a unique object from some items found in a StringCollection, naming the objects using information found in the strings stored in that StringCollection.

View 2 Replies

Instantiate A New Object From My Class?

Jun 11, 2009

I'm trying to decide whether to get a value, call it X, in my class through a read only property or through a function. Normally I'd code it as a property except in this case the GET involves doing a lookup to a sql table. So there's way more overhead than a simple RETURN X. So my question is, when I instantiate a new object from my class, are all the properties calculated at that point, so that the sql lookup will occur too? Or is the property only evaluated when I actually reference it in the calling code.

View 3 Replies

Instantiate Type Of Object With Dim?

Oct 31, 2009

i wanted to do something simple that sort of replicate an object:

public function clone(byval realcopy as object) as object return new Control ' something like this works, however i want to return the type of realcopy, which may not be a control end function so i tried this:

public function clone(byval realcopy as object) as object
return new gettype(realcopy.gettype)
end function

View 3 Replies

How To Instantiate Objects Contained Within Object

Jan 20, 2010

I am having some real issues with this one. I have a class which contains two other objects...but I cannot seem to instantiate those sub objects. Here is the code for my class:

Code:
Option Explicit On
Public Class Boot

[code]......

View 1 Replies

Unable To Instantiate Database Object

Jan 24, 2010

I have an application which I am trying out on machines without mysql. The app runs fine on my local host however when I try to use the application on another machine I am getting the following error:

Access denied for user 'root'@'localhost (using password: YES)

Then I get a .net framework error

System.NullReferenceException: Object reference not set to an instance of an object.

I thought I had exported the DB but I was left with a mysql file which I placed in the bin directory.

View 2 Replies

Instantiate A Generic Class Using Concrete Object?

Sep 27, 2011

i've got a generic class for xml serialization and deserialization.

Public Class clsXMLHandler(Of T)
Public Sub serializeFromObject(ByVal filePath As String, ByVal [object] As T)
Dim creater As New FileStream(filePath, FileMode.Create)
Dim xml As New XmlSerializer([object].GetType)
xml.Serialize(creater, [object])

[Code]...

View 1 Replies

Instantiate Object Inside Class Definition

Jun 22, 2010

I see a sample code that an object is instantiated within the class definition block. But when I test the folllowing, I got error "Process is terminated due to

[Code]...

View 3 Replies

.net - WPF BackgroundWorker - UI Locks Up Trying To Instantiate Object From External Class?

Apr 13, 2011

I am trying to run a backgroundworker to load data from my DAL (which is available in another class). I want to keep the UI available and not have the "locked up" feel while the object is loading.When I create a simple backgroundworker and Sleep the UI stays responsive and my controls can be updated after the sleep. As soon as I replace the sleep with a call to instantiate the object from my DAL, the UI locks up. Is there someway I can instantiate this object using the background worked and keep the UI responsive?

When the situation object is instantiated it could take several seconds for it to load completely, during this time is when the UI is locked up... It does eventually load just fine.

Private WithEvents backWork As New BackgroundWorker()
Dim sit As Situation
Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnLoad.Click

[code]....

View 1 Replies

Instantiate An Anonymous Object While Passing The Propertynames And Values As String?

Mar 12, 2010

How can I instantiate an anonymous object while passing the propertynames and values as string?

new With { .SomeProperty = "Value" }
new With { ".SomeProperty" = "Value" }

View 1 Replies

C# .NET 3.5: Object MyClass = SomeMethodToInstantiate("MyClass"); - Instantiate An Object Given Its String Name?

Dec 2, 2010

In C# .NET 3.5, is there a way to instantiate an object given its string name? For example, suppose I have a DLL (e.g., MyClass.DLL) which contains type MyClass. Is possible to write something like... Object myClass = SomeMethodToInstantiate("MyClass"); // ? Is it possible to do this in VB .NET 3.5?

View 2 Replies

Get A Property Name For A Type Without The Need To Instantiate An Object Of That Type?

May 15, 2012

I have a requirement where I need to have a "type safe" way of accessing property names, without actually instantiating an object to get to the property. To give an example, consider a method that takes as arguments a list of IMyObject and a string that represents a property name (a property that exists in IMyObject).

The methods implementation will take the list and access all the objects in the list using the property name passed... for some reason or another, we won't dwell on that!!

Now, I know that you can do this using an instantiated object, something like ...

Dim x as MyObject = nothing
Dim prop As PropertyInfo = PropHelper.GetProperty(Of MyObject)(Function() x.MyProperty)

Where my helper method uses reflection to get the name of the property as a string - there are numerous examples of this flying around on the web!

But I don't want to have to create this pointless object, I just want to do something like MyObject.MyProperty! Reflection allows you to iterate through a types properties and methods without declaring an object of that type... but I want to access a specific property and retrieve the string version of its name without iteration and without declaring an object of that type!

The main point here is that although I am trying to get the property name as a string... this is done at run time... at compile time, I want this to be type safe so if someone changes the property name, the compilation will break.

View 2 Replies

C# - Manipulate A Window Object From Another Class In WPF?

Aug 28, 2011

I'm new in WPF and C#. I know a lot of VB.NET and I'm used to the way when I call a form object like textboxes, etc. I'm calling it from another form. Now, I'm using WPF, I'm confused. Because I have a Main Window. And I want to add and item to a listbox in the Main Window from a Class. In VB.Net , its just like this.

[Code]...

View 2 Replies

How To Maintain Position Of An Object W.r.t Window

Jan 18, 2011

i just want to know how to maintain the position of an object w.r.t the window in vb when i resize the window during run-time.i tried anchoring it from all sides and the object resizes along with it.

View 6 Replies

Get Window Handle From EnvDTE80.Process2 Object?

Jan 16, 2012

I have a piece of vb.net code that finds the nunit.exe process like thisDim proc2 As EnvDTE80.Process2 = dbg2.GetProcesses(trans, "myPC").Item("nunit.exe")now I'd like to press a button on the window of that process so I do thisDim ButtonHandle As IntPtr = FindWindowEx(X, 0, "Button", "Run")SendMessage(ButtonHandle, &HF5, 0, 0)

View 1 Replies

Resize An Object (listview Datagridview) If The Window Is Maximized?

Feb 23, 2010

how do i resize an object(listview datagridview) if the window is maximized? and how to properly place the buttons when maximized?

View 2 Replies

Show Output In Console Window From Remote Object?

Aug 13, 2011

I am trying a .Net remoting project hosted in a console application.I have the following code in remote object class.

[Code]...

View 1 Replies

VS 2008 Find External Window, Object Text?

Aug 5, 2011

i have an external form, and it has a label, which his name is: Static62 how do i read the label into my vb.net program?

View 10 Replies

IDE :: Debugging Nightmare: Cannot Drill Down Into Object Collections In QuickWatch Window?

Mar 15, 2007

My colleague and I have recently upgraded our projects from .NET Framework 1.0 and VS2002 to .NET Framework 2.0 and VS2005. We also applied the latest VS2005 service pack.

Our problem: normally when debugging we use the QuickWatch window to drill down into and view collections of objects belonging to the parent object we are "watching". THIS NO LONGER WORKS...instead, we get a message in the value line against the object collection saying:"In order to evaluate an indexed property, the property must be qualified and the arguments must be explicitly supplied by the user."This is incredibly frustrating, particularly when we have large nested collections of objects.We are pretty sure this feature was working fine after we upgraded, but we are not so sure that it was working after we applied the VS2005 service pack.

View 1 Replies

Javascript Error: 'window.top.document.getElementById(...)' Is Null Or Not An Object?

Sep 8, 2011

I am getting a javascript error when I attempt to click on my calendar control.

The html code is:
<td align="left" style="width:50%;"><asp:Label runat="server" CssClass="TextFontBold" ID="lblStartDate" Text="Start Date:"></asp:Label>

[code].....

View 2 Replies

How To Instantiate A Class In A Web Site

Sep 28, 2009

I have created a WebSite with a folder called Classes. In the folder, there is a class with a Public Shared Function. How do I go about instantiating that class so I can use that function on a web form?

View 5 Replies

Instantiate And Name Listbox Dynamically?

Jun 5, 2009

I want to instantiate and name a listbox based on the value of a textbox. If the listbox already exists by this name (textbox value) I want to add items to the list.

View 14 Replies

Instantiate Local Variable By Value?

Jan 7, 2010

I sort of understand why this is happening, but not entirely. I have a base class with a Shared (Static) variable, declared like so:
Public Shared myVar As New MyObject(arg1, arg2)

In a method of a derived class, I set a local variable like so:
Dim myLocalVar As MyObject = myVar

Now when I do something like myLocalVar.Property1 += value, the value in Property1 persists to the next call of that method! I suppose I get why it would be happening; myVar is being set by reference instead of by value, but I've never encountered anything like this before. Is there any way (other than my workaround which is to just create a new object using the property values of myVar) to create myLocalVar by value?

View 2 Replies

Instantiate While Remaining De-coupled?

Jan 24, 2011

Just a bit of an issue that we're trying to resolve here. Assuming We're implementing a business model as one dll and a data access layer as another dll. We want them to be de-coupled so we implement an interface for the data-access layer. Great, we could now swap out the data access layer and, as long as the new data access layer fulfils the interface we're good to go, right?

Except we're not. In the business model we need to insanciate the data access layer and, because you can't instanciate an interface, you have to instanciate the actual class. We need to know the name space and the class name.We're going to end up with a line of code somewhere in our business model that looks something like this:-

Dim test as iDataLayer

test = new namespace.DataLayer

Basically, we can declare test as an iDataLayer (the interface) but to instanciate it we need to refer to the actual class (DataLayer). So we haven't really removed the coupling. If we want to swap out the data layer for a different implementation with a possibly different class name or namespace then we need to ammend the code in the business model. We're trying to avoid that.

So far the best we can come up with is to use the activate instance method instead of the New keyword (Late Binding). Because that takes a string we could hold the namespace and classname in a config file or similar, so swapping out one component wouldn't invalidate the others, you'd just need to update the config. That's just our home-spun solution though and I can't help feeling there are betters ways out there.

View 9 Replies

Possible To Instantiate And Invoke Delegate By Name?

Mar 5, 2009

I'm trying to figure out if it is possible to instantiate and invoke a delegate by name, rather than explicitly. I think the code below explains it fairly well. I want to accept a function name and then instantiate the delegate based on that. In the example I use a select case, but I want to eliminate that and just use the methodName argument itself.

Private Delegate Sub myDelegate()
Private Sub myDelegate_Implementation1()
'Some code
End Sub
Private Sub myDelegate_Implementation2()
[Code] .....

View 4 Replies

Possible To Instantiate New Instance Of Interface?

Jun 5, 2009

I have defined an interface named IEmployee (ID, FirstName and Surname properties) but I have not yet implemented that interface in any class. What I want to do is something like:
Dim User as New IEmployee
User.ID = 1
User.FirstName = ""
User.Surname = ""
Call SomeFunction (User)
The VB.NET complier does not seem to like this.

View 6 Replies

Reference Versus Instantiate?

Aug 25, 2011

what actually goes on inside the pc when I reference an object vs when I instantiate it.

Like this

Guys joe; (reference)

Joe = new Guys; (instantiate).So what goes on inside the computer for each line above.

View 15 Replies

.net - Instantiate Class Directly In Namespace?

Oct 13, 2011

this is what i want to do. I have a class library project into my solution. Into it i have a class. I want that class to be instantiated as soon as the solution starts. So it can be accesible from the other projects in the solution like this: Namespace.InstanceOfTheForm.Property Is there any way to do that? or something close to that?

[Code]...

View 2 Replies

Can't Simultaneously Instantiate Multiple Forms?

May 5, 2010

I used different backgroundworkers to instantiate some 'heavy' forms thinking that it will reduce the time to instantiate them if I did them at once but it looks like I am wrong since it is still taking about 43 seconds to load all of them. Am I missing something or do you have a tip on how I can speed up their instantiation?

View 15 Replies

Compare Ways To Instantiate A DataTable?

Feb 17, 2012

Presuming "instantiate" is the appropriate terminology, may I get some insight as to which of these are better, more efficient,[code]...

View 3 Replies







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