.NET Class As Callback Object In COM DLL?

Feb 21, 2012

I am a relative newcomer to Windows programming and VB.net. What we are trying to do is call a function in an existing, 3rd party COM dll. This function requires a callback parameter, whose type is an interface also defined in the dll.In our VB.net application, we have added the dll as a COM reference, and created a class that implements the interface in the DLL. We then send an object of that type as the callback parameter. This compiles fine. However, when we run the application, we receive an error stating that the program is unable to cast the object from our existing type to the interface type.

I suspect that there is a simple fix, but so far, my efforts to find a solution have come up short. If anyone could point me in the right direction,

View 1 Replies


ADVERTISEMENT

Utilizing A Centralized Class object That Needs To Call Another Class Object?

Jun 7, 2010

I am utilizing a centralized class object that needs to call another class object. The program itself will do something like the following

sFieldValue = CentralObject.ObjectHandler(1, TestFunction, "FunctionVar,FunctionVar2,FunctionVar3")

In the central object I have a function

Public
Function ObjectHandler(ByVal ObjectType
As
Integer,

[code]....

View 5 Replies

Flattening An Object Hierarchy Using A Shim Class - Initializing Derived Object Properties From The Base Object?

Jul 10, 2010

I am somewhat new to object oriented programming and am attempting to flatten a Linq object hierarchy by using a shim class.how to initalize a derived class with property values from a base class?I have two objects, a base object with about 100 properties, and a derived object which inherits from the base object and adds a few additional properties beyond those of the base object. My simple constructor creates the derived object, but I am looking for a way to initialize the derived object properties with values from the base object.Right now I am using reflection to iterate over the properties individually and I suspect there may be a better way. The following example shows my shim class constructor for the derived class, and two properties:

newProperty1 - a new string property of the derived class

flattenedProperty2 - a new string property of the derived class, copied from a 2nd-level object of the base class

Code example:

Public Class derivedObj
Inherits baseObj
Private _newProperty1 As String[code].......

Is this the correct constructor approach to flatten the object hierarchy using a shim class? My second question relates to initialization of properties in the derived class. The constructor above creates the derived object, but what is the best way to initialize the derived object properties with values from the base object? The following code uses reflection to iterate over the properties individually, but I suspect there may be a better way.

Code example:

' property names are in the string array fieldNames

'baseObjQuery is an ienumerable of baseObj

'derivedObjList is a list of derivedObj[code].....

Is there a simple way to initialize values for the properties in the derived object based upon the values of the common properties in the base object?

View 7 Replies

Object Reference Not Set To An Instance Of An Object With A Class With An Array Of Classes As A Member?

Aug 6, 2010

Here is the structure that I have:

Friend Class StandardFormatFile
Friend fileType As String
Friend numberOfSeries As Integer

[code].....

View 3 Replies

Access To Object Passed ByRef In The Constructor Of A Class Through Another Part Of The Class?

Aug 18, 2009

I have some classes, BsfciFile and StudyFlashCard. Bsfci is the extension to which I save my set of flashcards in an INI format. I am currently working to transform my code from using Windows API calls to access the INI to using a IniFile class that I found on the internet. I would like the BsfciFile to have a Array of StudyFlashCard objects, but I would like the StudyFlashCard class to use the IniFile class object contained in the BsfciFile class. I can pass the IniFile from the BsfciFile class to the constructor for the StudyFlashCard class, but I want it to modify the same IniFile as the BsfciFile class has later on.

[Code]...

View 1 Replies

VS 2008 Adding Class Object To List Or Array In A Different Class

Jun 21, 2010

I am trying to create an list or an array of a class.Here is my "Ingredient" class that I am trying to create a list of:[code]In my "recipe" class, I am want to create a list (or array) and I am drawing a big blank on how to do it. Can anyone point me in the right direction?

View 2 Replies

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

Iterate Through Class / Object Properties - Saving Them Each To Another Object

Dec 15, 2011

I'd like to have something like:

[Code]...

View 1 Replies

Type Conversion From Webservice Object To Class Object?

Jun 15, 2009

i've created bunch of classes. i have webservices which reference these classes and contains the classes as parameters and return objects.when i call the weservice, i have to convert the class to the webservice object else i can type conversion error.is there a generic way to convert between these types without having to assign the values by hand?

for example

public class person
fname as string
lname as string
end class

[code]....

i would liek ot be able to call the web service and return the data type back and have a generic coversion instead of as above in stead of:

dim wsPerson as wsReference.Person = ws.getperson()

View 2 Replies

Class With Class Properties: Object Reference Not Set To An Instance

Aug 19, 2009

I have a class in which some of the fields are also classes.

I can put values in the "normal" properties, but in the others when o try to assign values it gives the: "Object reference not set to an instance of an object"

But the code compiles fine.

dados_Defenicao = New ServiceReference1.draftClaimEntryDefinition
dados_Defenicao.arCode = "123"
dados_Defenicao.claimMarket.warrantyType = "w" - Here it gives the error

View 4 Replies

Get Base Class Object Reference Outside The Class's Definition?

Dec 10, 2010

If we are within the derived class then ofcource we can use MyBase keyword to access base class's object reference . That's fine , how can we take that base class's object reference outside that derived class's definition.My following code will explain what i want . Actually that is giving error right now, but it is explaining my requirement .

Public Class Base
Public x As String
End Class

[code]....

Actually there is error in ReadOnly Property BaseReference's Getter . Error is "Error 1 'MyBase' must be followed by '.' and an identifier. " how can i get base class object reference in Main method ?

View 1 Replies

IDE :: Class Files. Same As Namespace Or The Same As The Class Object Inside?

May 22, 2009

If my namespace is Company.Application.EDI.Acknowledgement and if I stick with theprogramming practice of one class per file then should my class be saved asacknowledgement.vb? Are there any gotchas that will come up?

View 5 Replies

Reference A Parent Class Object From A Child Class?

Jan 2, 2010

I have a Parent Class Called Fuselage that containsfour child classes called Forebody, CenterBody, AftBody, and CrossSection. CrossSection classcontains objects common to Forebody, CenterBody, and Aftbody (example: width). How do I access thewidth property in CrossSection from within the classForebody?

Public Class Fuselage
Dim Forebody As ClsSection
Dim Centerbody As ClsSection

[code].....

View 6 Replies

Create An Object From The Class - Use The Object To Interact With The SQL Db?

Apr 12, 2006

I am developing an IT Asset Tracking application using VB 2005 and SQL Server 2005 Express edition. Will I need to create classes to represent objects such as Computers, Printers, Scanners/Faxes, Contracts, Purchase Orders etc or are there any other approaches.For example, if I am correct, I will have a class called Computer and its properties will include Make,Model,CPU,Hard Disk,Memory etc. Is this the right approach.

Computers can be split up into Desktop PC's, Servers and Notebooks. Would I have to create separate classes for these as well or would they be ok under the Computer class.Once I create an object from the class, how can I use the object to interact with the SQL db.I am a beginner to VB.NET 2005 therefore I am slowly getting to grips with OOP.

View 13 Replies

"upgrade" An Object To An Inherited Class, And Keep All The Base Class's Property Values?

Jul 5, 2010

bare with me during this silly example. :-) Let's say I have a class like this:

Public Class Animal
Public iLegs as int32 ' Number of legs
Public bWings as Boolean ' Wings? Yes/No
End Class

And another class that inherits the "Animal" class and adds one more property:

Public Class ScaryAnimal
Inherits Animal
Public iScariness as int32 ' 0-100, how scary is it?
End Class

Now, if I have an instance of "Animal" with some values in it, and I decide I want to cast it to a ScaryAnimal for some reason, how do I do that without having to create a new instance of "ScaryAnimal" and copy each property value?Basically I'm looking for a way to do this, without having to write the lines marked with '*** below:

[Code]...

View 2 Replies

Declaring A Object - Instance Of An Object To Be Created When A Form Loads Or Another Class Is Created

Oct 5, 2009

If you want a instance of an object to be created when a form loads or another class is created, you have two options:

Public class example

private IAmAObject As IAmAObject

public sub new()

[CODE]...

Or like this:

public class example

private IAmAObject as new IAmAObject

public sub new()

[CODE]...

I always use the first one. It's more type work but I think it's neater. How about you people and is there any real difference between the two?

View 4 Replies

Class Diagram - Called Control Fields Not Object In The Class Diagram ?

Nov 11, 2011

if I put controls on form1 like button,textbox....etcwhy called this control fields not object in the class diagram ?

View 7 Replies

Callback A Sub From A DLL?

Jun 19, 2012

I'm trying to use a .DLL which Callbacks a Function of my project, but I can't get it to work.

Declaration from .h file of .DLL
void DLL_EXPORT SetEntity_CallBack(bool Active, _
void (*Entity_Callback)(int Site, int Application, int ID, _

[Code].....

View 11 Replies

.net - Using Object Class As An Array?

Dec 19, 2010

like every class in .net does Arrays also inherit Object?

View 1 Replies

Class Property Specifying An Object?

Mar 9, 2012

I'm currently writing a HMI for an automated machine in VB.Net 2010. I have a custom class that turns a Border green or red depending on the value of an input on a remote I/O module.

The connection to the remote I/O module is through a COM object provided by the manufacturer. I have three remote connections, lets' call them g1, g2, and g3. They're of type Manufacturer.ConnectionObject.

I would like to specify, using a property that I can set in XAML, that instances of MyCustomBorder use g1, g2, or g3. Unfortunately, setting up a Property called g and typing 'g1' into the property field results in the message "Property value is not valid. Details: Property 'g' does not support String to Value conversion."

[code...]

I need to implement a converter between String and the custom class, Manufacturer.ConnectionObject, but I have no idea how to accomplish this, especially since Manufacturer.ConnectionObject is part of a closed-to-me COM object.

View 2 Replies

Class To Return An Object?

Nov 14, 2010

I have a class i've called "buttons", which passes in 1 variable, the button text, and then returns a new button with that text. however, i do not know how to get the class, when called to return a button.

similar to how 'toString' works, except it would return a button object instead of a string. (im not sure how toString works in vb.net. in java it is automatically called when you call the new class, so newclass and newclass.toString(); return the same) [code]...

View 2 Replies

How To Use A Class Without Declaring Object

Mar 30, 2011

I'm trying to develop a class in VB .NET in order to manage a language globalization stored in a database and editable by the user.What I need is to know what kind of class I need to declare in order to use it without declaring a new object. For example, the way My.Settings is used.

One of the goals is that in some project the developer imports the reference and after that access directly to a property. For example: My.CustomLanguage.GetWord("Hello") without declaring objects.

Is this possible? And if it's what is the best way to aproach it?

View 3 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

Instantiating A New Class Object?

Mar 23, 2010

Is it possible to instantiate a new class object within a Form Procedure where it is accessible to all other Procedures/Functions within the Form Module? For example, I have a Client Class Module that contains properties and Methods that reflect a Client DB Table. All the properties and Methods within this class are Public. So, when I instantiate a new instance within a Procedure, I declare it as such:

Private Sub cmdNewClient_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdNewClient.Click
Try
Dim client as New clsClient

[code]....

Normally, I would declare a new instance of this Class Object at the beginning of a Form Module. I'm trying to do this in order to have more control.

View 2 Replies

Object From Class Of Properties In Vb?

Nov 20, 2010

I have a property grid and I want to be able to set the selectedobject to a class. The class contains properties. This is what I have, but it 'OtherFiles' is not an object.

pgProperties.SelectedObject(OtherFiles)

How do you create a class as an object. In VB.NET 2008 please. C# is ok.

View 1 Replies

Passing An Object From Its Own Class

Jul 4, 2011

In a VB 2010 program we have two classes Aclass and Bclass.In Bclass we need all values of an Aobject.How could we pass the Aobject to Bobject?[code]Is there any VB entity that could be defined as including all the properties of a given class?

View 3 Replies

VS 2008 Use A Class And Object?

Nov 21, 2010

I've got a form which is populated with text fields and listbox's etc. I've connected it to a database and i'm going to populate these with results from one selected row. Should I create a class object that will have a variable for each textbox and then in one function add or remove this object from each textbox Or Should I via a sub when selecting a row add each result to it's respected textbox.

View 5 Replies

Asynchronous Callback For TCP?

Aug 17, 2009

I have this code obtaining data from a sensor that is sending a string that contains 4 numbers separated by a tab and terminated by an end of line/ I am trying to use an asynchronous callback to get the data over TCP. That problem is that the callback function is not grabbing the complete string. Sometimes it will, other times it gets half in one retrieve and half in another. I need the callback to hold off until it gets a newline character.

Code:
Public Sub readVaisala()
Dim ip As String = "192.168.1.30"
Dim portNumber As Integer = 23
Dim time As Int32 = Now.Second * 1000 + Now.Millisecond

[code].....

View 2 Replies

Callback Marshaling From C++ To .Net?

Mar 3, 2011

I have a C++ dll that contains a callback. The callback has one parameter that is passed in and one parameter that is passed out. The parameter that is passed from C++ is a variant. So, we are going from a variant in C++ to an object in VB.NET. The function works. However, It seems that there is a memory leak on the VB.Net side. This must be a Marshaling issue. I have tried to use the MarshalAs Functions, but to no avail.

VB.NET
Declare
Function EnableWriteNotification
Lib

[code]....

View 2 Replies

Error In Using Callback

Jan 4, 2011

there is error when i use callback function A callback was made on a garbage collected delegate of type 'skynet1!skynet1.Form1+myCallBack::Invoke'. This may cause application crashes, corruption and data loss. When passing delegates to unmanaged code, they must be kept alive by the managed application until it is guaranteed that they will never be called.

View 6 Replies







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