C# - Exposing Property As Variant In .NET For Interop?

Feb 28, 2012

I am creating a wrapper class in .NET (VB.NET as it happens but is equally related to C#) that is exposed to COM and one of the properties I am trying to wrap is a Variant. I thought I would just be able to use an Object, but I get an error: Public Property FieldValue([vFieldID As Object = -1]) As Object cannot be exposed to COM as a property 'Let'. You will not be able to assign non-object values (such as numbers or strings) to this property from Visual Basic 6.0 using a 'Let' statement.*

My property declaration looks like this:
Public Property FieldValue(Optional ByVal vFieldID As Object = -1) As Object
Get

[code].....

View 2 Replies


ADVERTISEMENT

VS 2010 : Exposing An Instance Property As Shared?

May 24, 2010

Suppose I have a class of objects called Porky with a property called IsHuge:

Public Class Porky
Public Property IsHuge As Boolean
End Class

Now I want to make a special kind of Porky -- let's call it UberPorky -- for which I want to change ALL instances to either IsHuge or not IsHuge. What I'd like to do is this:

Public Class UberPorky
Inherits Porky
Public Overrides Shared Property IsHuge As Boolean

[code]....

The trouble is, I can't do that. I'm not allowed to reference MyBase or Me in a Shared property.

View 17 Replies

Default Property For DotNet Interop Usercontrol?

Mar 11, 2009

I need to set the default property of a dotNet Control used by an VB6 Application.

<ComClass(myControl.ClassId, myControl.InterfaceId, myControl.EventsId)> _
<DefaultProperty("NewProperty")> _
Public Class myControl

[code]....

View 2 Replies

.net - Slow Performance When Utilizing Interop.DSOFile To Search Files By Custom Document Property?

Apr 19, 2010

I am new to the world of VB.NET and have been tasked to put together a little program to search a directory of about 2000 Excel spreadsheets and put together a list to display based on the value of a Custom Document Property within that spreadsheet file. Given that I am far from a computer programmer by education or trade, this has been an adventure.

I've gotten it to work, the results are fine. The problem is, it takes well over a minute to run. It is being run over a LAN connection. When I run it locally (using a 'test' directory of about 300 files) it executes in about 4 seconds.I'm not sure even what to expect as a reasonable execution speed, so I thought I would ask here.The code is below, if anyone thinks changes there might be of use in speeding things up.

Private Sub listByPt()
Dim di As New IO.DirectoryInfo(dir_loc)
Dim aryFiles As IO.FileInfo() = di.GetFiles("*" & ext_to_check)[code]....

View 1 Replies

RE Exposing COM Interface To .NET?

Jun 29, 2010

Is it possible to create a VB6 interface that can be implemented in a .NET class? I have the need to call a method in an existing VB6 class that behind the scenes will call either a VB6 or .NET class that utilize the same interface.

MyObject.Type = "clsVB6"
MyObject.DoSomething(intID)
would behind the scenes be utilizing a VB6 class that implemented a 'DoSomething' VB6

[code]....

View 2 Replies

How To Pass Variant* To Com In .NET

Jun 10, 2010

Function "SetUserName" is used to download the specified user's name data to the appointed terminal.

[Format]
BOOL SetUserName(
long DeviceKind,
long dwMachineNumber,
long dwEnrollNumber,

[Code]...

View 2 Replies

Is N1 Actually Being Defined As A Variant

Jan 25, 2011

in the line dim n1,n2 as integer...is n1 actually being defined as a variant ?

View 2 Replies

.net - Error Exposing Event Through Interface?

May 19, 2010

I have this interface

Interface IProDataSource
Delegate Sub DstartingHandler(ByVal sender As Object, ByVal e As EventArgs)
Event starting_Sinc As DstartingHandler

[Code].....

View 2 Replies

Exposing A Supporting Class From A Usercontrol

Apr 8, 2010

I have a supporting GridColumn Class that resides in the same class library project as my GridBox usercontrol.It is used in a list of GridColumns as a property.[code]In the Load event of my form I would like to use the .Add method of the List(Of GridColumn) to add columns to the usercontrol.[code]It will not work though because it cannot find the GridColumn class.If I use: "Imports <My Class Library Name>" it works, but I would like it to work without having to do so.Standard controls do this all the time.Am I putting the supporting class in the wrong place?Is there a modifier I that will expose the class when the usercontrol is dropped on a form?As a work around I created a method that adds a column but I would like to know in any case.

View 9 Replies

Exposing An Enumeration Through COM That's Declared In A Different Module?

Mar 15, 2011

I have a .NET library that needed a COM wrapper around it so it could be called from VB6ish programs, in this case specifically Microsoft Access XP I have a type that's declared in one of the classes that went into the .NET library. I thought since its public, it would be seen, but it didn't show up in Access. And yes, we made the TLB file and registered the COM interface. I had to move the type declaration into the COM module, which I really didnt want to do. Is there a way to export a type/enum through COM without actually declaring it in the COM interface Scott Berger McCormick Systems

View 3 Replies

Variant Marshaling To A COM Assembly?

May 18, 2011

I'm having trouble using a COM based DLL in that one of the parameters is of type VARIANT.

The C++ definition of the structure is as follows:

typedef struct CSimData
{
DWORD dwSigId;

[Code].....

From debugging i've been able to determine that the COM server is getting no value in vValue. Is there some sort of Marshaling that needs to be done to be able to set that VARIANT up on my side so that it can use it?

View 1 Replies

Vb6 Migration - VB6 Convert To VB Variant?

Dec 2, 2009

I have been tasked to convert out VB6 program to VB.NET. In my research online everyone seems to say I need to go through my code and get rid of any Variants I have. I have had pretty good luck so far, but I am having an issue in replacing this one.

[code]...

I am still pretty new to VB (either 6 or .net) and I am having a hard time finding an alternative for this. Will the convert tool in VB.net handle this just fine? Or do I need to change this? If I do, is there a better alternative for this? Forgive my noobness.

View 2 Replies

VS 2010 Exposing Picture Box Drawing Surface?

Dec 27, 2010

studying GDI+ for drawing, there are many suggestions to expose the graphic surface for the paintbox control or a form using e.graphics in the paint event. Can graphics be exposed outside the paint for the picture box control?

In my old vb6 project that I am converting to vb.net 2010, I have several large routines located in a code module that draw lines, circles, etc on a picture box and it is desirable to keep these outside the paint event of the picture box so the same routines can be used to draw on more than one picture box.

In experimenting, I found I can create e.graphics from the picture box paint event and pass it by reference to a drawing routine and the drawing routine seems to work ok on initial experiments but it requires visiting the picture box paint event to get the drawing surface in the external sub.Is this apprach good programming practice or is there a better way to create the graphics surface of a picture box or form in subroutines outside the paint event?

View 1 Replies

Use Sql To Select A Variant Field From A Table?

Oct 31, 2009

I want to extract a field (field name is variant, i.e. depend on what the user's choice) from a table using sql statement. How do I do that? Do I have to declare some variables?

View 4 Replies

VS 2008 Use From Variant In Form1 In Form2?

Aug 2, 2010

I have a simple problem and I believe that the solution is with module using but I could not resolve it yet. Here is the scene:In Form1 I have a variant that gets its value from the selections of a listbox. The code is:OPtext) in Form2 because this selection from Listbox (in Form 1) should also trigger some events in Form 2. I tried to use a module and declare the variant using Public. I did this and I now can use the variant in Form 2. But the value selected in Form1 does not come to Form 2.

View 7 Replies

Compiling And Running Code Dynamically / Exposing Objects From App

Jul 19, 2011

I am trying to add some scripting to my VB.NET 2010 Windows Forms Application.I have figured out how to compile and execute VB.NET code stored in an external script file from within my app using Microsoft.VisualBasic.VBCodeProvider.CompileAssemblyFromSource and InvokeMember. I can also pass and return parameters to the code in the script file.In VB6 using the VBScript Host control, I could expose instances of objects in my app to the code in the VBScript.How do I do this in VB.NET?I'd like to expose a form object (the main form for my Windows Forms Application) to my VB.NET script.I don't want to pass the form as a parameter via InvokeMember.[code]

View 3 Replies

WCF Service Generated Proxy Class Exposing Function As ByRef Sub

May 23, 2011

I have a WCF Service exposing a single contract and operation:

<ServiceContract(Namespace:="ImageSystem")> _
Public Interface IUploadService
<OperationContract()> _

[Code].....

This subsequently leads to stream casting issues, because the generated function allows me to pass a memory stream as an input (which works correctly when passed through to the service), but instead of passing me back a new stream for the response, it attempts to cast the MessageBodyStream received from the service into my memory stream.

This is, in some ways similar to other posts but as you can see, there are no enums involved in my contracts - presence of Enums caused strange proxy class generation is marked as the answer in the similar post.

Is there anywhere I configure the proxy behaviour to use the contracts I've specified? Clearly I'm within a dev/test environment currently, but when this eventually goes to production it will be memory and file streams passed to the service, and the returned stream can be in any format to be honest, I intend to treat it as the abstract stream class. The only way round this I can see right now is to change my in stream to be the same as the anticipated out stream, but surely there is a better way?

View 1 Replies

Converting From VB6 - Reading Excel Range Into Variant Array

Oct 18, 2011

In VB6 I could assign an Excel range directly to a variant array dim vArr as variant vArr = xlSheet.range("A2:A10").value and then work with vArr to pull out the values I needed. This doesn't work in VB 2010. Is there a replacement procedure to allow me to read in a range (perhaps large) all at once and then process the data without needing Excel?

[Code]...

View 6 Replies

Converting VBA Related To Variant And Array Creation/Initialization Syntax To .Net?

Jun 17, 2011

The following code works fine in VBA Goal of the code is to find (select) all cells in an Excel worksheet where the backgrounf cell color is Yellow (6) or Rose (38)

Sub SelectColorsViaArray()
Dim e As Variant
Dim r As Range
Dim x As Range

[code]....

3) With the above, I still do not understand how to integrate the Variant and Array differences from VB6 to VB.Net. I know what to do with all other like: Application.FindFormat.Interior.ColorIndex ... etc.

View 10 Replies

VS 2005 Variant - Values Coming Back From The Function Is Not Getting Converted To Object Type Properly

Jun 8, 2011

I have some ActiveX that was written for VB6. They all seem to return Variant types. Ex.

[Code]....

In this case the GetPosition control is returning a robot axis position. It looks to me like the values coming back from the function is not getting converted to object type properly.

View 2 Replies

Where To Get The IMAPI2.Interop.dll Or The Equivalent IMAPI2.Interop.vb Class

Aug 29, 2011

i want to write a small app which enables the user to burn some files on cd/dvd. Something like:

- Make an export from related DB Tables with informations

- Collect customers informations

- zip everything

-burn on cd (its a settlement related tool)

View 4 Replies

Putting VB Content In The Center Of A Full Screen With Variant Screen Size?

Feb 2, 2012

Now I'm creating at app in VB (Microsoft's, Visual Basic 2010) which will be in full screen but I want to know if I can put all my content in the centre of the screen. At the moment it's at the far top, left of the screen. When the screen size varies I want it will stay in the middle for all shapes and sizes. Like :

<div style="margin: 0 auto; width: 500px;"></div>

But this is for web pages using HTML and CSS.

View 1 Replies

Exposing A Class Through Another Class With Consistent Naming In .net

Jul 15, 2010

In the pseudo code below, if I have two classes and I want one class to be initialized in the other class without the name having to be different, how would I accomplish this?

'==Car.vb==
Public Class Car
Public Model as New Car.Model()

[Code]...

Is there a better way of doing this so I get the result I want for my usage code?

'==ASPX page==
Dim c as New Car()
c.Model = Car.Model.Types.BMW

View 1 Replies

.net - 'Property' Cannot Implement 'Property' Because There Is No Matching Property On Interface 'IName'?

Dec 9, 2011

I'm having some very weird issues with interfaces right now.

I have a very simple setup. In one of my class, I have a Property implementing a Property from an Interface.

In my class it's like:

Private _oForm As IForm
Public Property Form As IForm Implements IContainer.Form
Set(value As IForm)

[Code]...

I have like dozens of interfaces like this working throughout my project and I can't believe this simple one can't work!

View 1 Replies

C# - VB6 Variant Type To .NET Type?

Jul 13, 2010

I have some VB6 code that can't be modified easily that looks like this:

Dim cCount as Long
Dim rCount as Long
Dim result()
Set mx = CreateObject("Component.Class")
Dim rtn = mx.GetList(rCount,cCount,result)

The method it calls is currently a VB6 component that we've migrated to .NET with one issue. We're not sure what type the result() is looking for since it's a variant type. We've tried object, object[], object[][], string, string[], etc, none of which have worked.

Here's an example:

public bool GetList(ref long rCount, ref long cCount, ref object result)
{
...
}

I've even tried setting the third param to VariantWrapper since it will add ByRef as necessary:

public bool GetList(ref long rCount, ref long cCount, VariantWrapper result)
{
...
}

what I can set the incoming result to be so that I don't have an unhandled exception?I've created a test Interface (for COM), test Class, and test VB6 app to ensure it was an issue with the Variant. So, it's defined like so:

.NET Interface:

[DispId(1)]
[ComVisible(true)]
string Test(ref object[] value);

[code]....

View 3 Replies

.net - Put Interop Dll Into GAC?

Apr 7, 2011

This might be a bit of stupid question but I need some clarification. I'm somewhat new to .NET and have created a EXE that had to reference an existing COM DLL. In doing so, Visual Studio 2010 automatically created an "Interop" DLL that it needs/uses to work with the legacy COM DLL.

I have deployed my project and included this Interop DLL with it (in the same folder) and everything is working fine. However, I have other applications that will need to use this same legacy COM DLL. Is it okay to reference it they same way in each application and keep deploying the "Interop" DLL with each application? Unfortuantely, all of these small applications go in the same folder and each use the same Interop DLL (so it will already exist there if it's used by another app.) I'm forced to having them in the same folder because these applications are being called as a way of customizing a parent application. As such it only looks in it's local folder when it wants to run a "custom" app. I'm just concerned if one the EXE's is ever removed and they take out the Interop DLL, then the others that still depend on it will fail.

So, I was wondering if it is possible or a good idea to put that Interop DLL in the GAC? I went ahead and installed the Interop DLL into the GAC and then removed the Interop DLL from the folder where my EXE runs and it failed to work. I get an error that says "Could not load file or assembly". I'm stuck on getting this working.

Do I need to reference the Interop DLL in my project differently such that it's now from the GAC? or Do I need to add something to my .NET code like Assembly.Load to make it work? Do I need to create that Interop DLL myself using TLBIMP?

View 2 Replies

What Is COM Interop

Apr 11, 2009

What is COM Interop? Please remember to mark the replies as answers if they help and unmark them if they provide no help.Welcome to the All-In-One Code Framework!

View 1 Replies

.net - If An Interface Defines A ReadOnly Property, How Can An Implementer Provide The Setter To This Property

Jun 10, 2011

Is there a way for implementers of an interface where a ReadOnly property is defined to make it a complete Read/Write Property ?

Imagine I define an interface to provide a ReadOnly Property (i.e., just a getter for a given value) :

Interface SomeInterface
'the interface only say that implementers must provide a value for reading
ReadOnly Property PublicProperty As String
End Interface

This means implementers must commit to providing a value. But I would like a given implementer to also allow setting that value. In my head, this would mean providing the Property's setter as part of the implementation, doing something like this :

Public Property PublicProperty As String Implements SomeInterface.PublicProperty
Get
Return _myProperty

[code]....

View 5 Replies

Reflection - Find From A Property Info Object If That Property Has A Non Public (Private / Protected) Setter?

Aug 27, 2009

I searched on the forum / Internet for the solution how a PropetryInfo object (of a Public property) can reveal if it has a Private Protected Setter ... it was all in vain .... all help I found was about how to "Set" value of a public property having a Private Setter.I would like to know if I have a PropertyInfo object of a public property, how would I know if its Setter is Non Public?

I tried, in a exception handling block, where I did a GetValue of the PropertyInfo object and then called SetValue by setting the same value back... but to my surprise it worked well and didn error out.

[Code]...

View 1 Replies

Error - In Order To Evaluate An Indexed Property, The Property Must Be Qualified And The Arguments Must Be Explicitly Supplied By The User

Jun 20, 2012

I'm having a few problems converting some code into VB.NET from C#. Most of the translating is done, but I am getting errors when I try to run my code, and I can't figure out what is causing them. Here is the Sub I translated.

Public Sub CreateWidget()
Dim blue As LCDColor
blue.Red = 0
blue.Green = 0

[code]....

The error I receive on this line ("vision.Widgets.CreateWidget(wg1)") reads "In order to evaluate an indexed property, the property must be qualified and the arguments must be explicitly supplied by the user."

View 11 Replies







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