| Accessing VB component property methods from C# application |
|
 |
Index ‹ Visual Basic ‹ Visual Basic Interop and Upgrade
|
- Previous
- 1
- Visual Basic IDE First chance 'system.invalidcastexception"
A first chance exception of type 'System.InvalidCastException' occurred in Microsoft.VisualBasic.dll
In the immediate window, I keep getting up to 6 of the above exceptions. The program runs normally. They seemed to start appearing when I write e.graphics..drawstring code. I don't know if that has anything to do with it. What would be a common cause of these exceptions The above tells me nothing.
- 2
- Visual Basic Language Building a VB / VBA app for Windows 2000 -> Windows XP
I have a VB application which collects data and generates an Excel file with a data table and graph.
My development and testing is done with VB Express on a Windows XP system with Office 2003.
If I run the application on a Windows 2000 system with Office 2000 I get the following exceptions.
Does not support a collection. (Exception from HRESULT: 0x80020011 (DISP_E_NOTACOLLECTION)) Exception: Does not support a collection. (Exception from HRESULT: 0x80020011 (DISP_E_NOTACOLLECTION)) Module: ExcelData:CopyRawData
And:
Attempted to read or write protected memory. This is often an indication that other memory is corrupt. Exception: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. Module: ExcelData:SaveExcelFile
If I move my code to the Windows 2000 system and build it there everything works when run in both XP and 2000. This is fine although moving my code to the Windows 2000 system is very cumbersome.
I would assume there would be some sort of setting somewhere to tell VB to compile for Windows2000/Office2000 as the lowest target but I cannot find any such setting Am I missing something
Any help would be greatly appreciated.
- 3
- Visual Basic General Updating a DatasetHi All,
I am having a issue with getting some information updated on a datagrid control.
here are the steps that I have taken:
1) load the datagrid with the checkbox column (Successful)
2) change the column value by selecting a checkbox (tested :) )
3) determining which Rows were selected and thereby updating the actual database and doing some additional "stuff" (PROBLEMS :( )
Please remember that so far the information in two is only what was changed on the form by selecting the check boxes. The data has not been updated to the dataset as yet.
Below is the code blocks for all so far, any help is appreciated
Thanks Michael
PS it is a windows form application using VS2003 (so no datagriditem option which i am accustomed to use :( )
Sub Frm_load
Str = "select * from XXX where Done=0"
ds = New DataSet ds = getDataSet(Str)
Dim dc As New DataColumn With dc .ColumnName = "Process" .DataType = GetType(Boolean) .DefaultValue = False End With ds.Tables(0).Columns.Add(dc)
Dim dc2 As New DataColumn With dc2 .ColumnName = "Delete" .DataType = GetType(Boolean) .DefaultValue = False End With ds.Tables(0).Columns.Add(dc2)
' da.Fill(ds, "POS") DG.DataSource = ds.Tables("POS")
Dim ts As New DataGridTableStyle ts.MappingName = "POS" Dim textCol As New DataGridTextBoxColumn textCol.MappingName = "HDR21" textCol.HeaderText = "Customer" textCol.Width = 120 ts.GridColumnStyles.Add(textCol)
Dim boolCol As New DataGridBoolColumn boolCol.MappingName = "Process" boolCol.HeaderText = "Process" boolCol.Width = 80 boolCol.NullValue = False ts.GridColumnStyles.Add(boolCol) DG.TableStyles.Add(ts)
Dim cmdbut As New DataGridBoolColumn cmdbut.MappingName = "Delete" cmdbut.HeaderText = "Delete" cmdbut.Width = 80 cmdbut.NullValue = False ts.GridColumnStyles.Add(cmdbut) DG.TableStyles.Add(ts) End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If ds.HasChanges(DataRowState.Modified) Then
For Each dr As DataRow In ds.Tables("POS").Rows 'ds.Tables(0).Columns("Process").ToString = "True" Then Dim ctl As Control Dim dgx As DataGrid = DG ' DG is the name of my datagrid For Each ctl In dgx.Controls Dim gd As New System.Windows.Forms.DataGridBoolColumn If ctl.GetType Is gd.GetType And gd.MappingName = "Process" Then If ctl.Enabled = True Then MsgBox("true") 'do update to the database and other stuff here End If Else MsgBox("False") End If Next Next 'dr("HDR21").ToString) '& " " & dr("Process").ToString) End If
End Sub
- 4
- Visual Basic Language getobject for multiple instance
hi
i was trying to create an application that can allow multiple instance of application(lppx2.application) running,but when i using getobject, it will return me the instance that is launched first,how do i get the second or third instance
thanks
regards
Yap
- 5
- Visual Basic General Media Player gets resized after form is closed...
Hi,
I've placed a Windows Media Player control on one of my forms, and works great. The user then plays a song, and that works great also. When he/she closes the form, and reopens it afterwards, and pushes the 'play' button, the Media Player gets resized to... almost 1/4 of the original size.
What can I do about this Regards,
Francois vdv, Netherlands
- 6
- 7
- 8
- Visual Basic IDE System.IO.PathTooLongException error
After converting my vs2003 win form app to vs2005, I got this System.IO.PathTooLongException error. (see below for full error)
The strange thing is, it is ok on day one, but got it on day two after the convertion. So I can still "run the last successful build", but not be able to create new build.
How do you find out the location of this offending long path file
Error 2 The "GenerateApplicationManifest" task failed unexpectedly. System.IO.PathTooLongException: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters. at System.IO.Path.NormalizePathFast(String path, Boolean fullCheck) at System.IO.Path.GetFullPathInternal(String path) at System.IO.Path.GetFullPath(String path) at Microsoft.Build.Tasks.Deployment.ManifestUtilities.Manifest.ResolvePath(String path, String[] searchPaths) at Microsoft.Build.Tasks.Deployment.ManifestUtilities.Manifest.ResolveAssembly(AssemblyReference a, String[] searchPaths) at Microsoft.Build.Tasks.Deployment.ManifestUtilities.Manifest.ResolveFiles_1(String[] searchPaths) at Microsoft.Build.Tasks.GenerateManifestBase.ResolveFiles() at Microsoft.Build.Tasks.GenerateManifestBase.BuildManifest() at Microsoft.Build.Tasks.GenerateManifestBase.Execute() at Microsoft.Build.BuildEngine.TaskEngine.ExecuteTask(ExecutionMode howToExecuteTask, Hashtable projectItemsAvailableToTask, BuildPropertyGroup projectPropertiesAvailableToTask, Boolean& taskClassWasFound) CSRTS
- 9
- Visual Basic Language Passing a Structure
I am attempting to pass a structure from one DLL to another.
The Structures are identically define in each DLL (Cut-and-Paste), but compiler complains it cannot convert types.
I've tried the usual 'fixes' -- moving code around, changing ByVal to ByRef, etc., etc., etc. No Help.
Any ideas
ERROR:
Value of type 'LPM.Menu.User_Data' cannot be converted to 'SS.clsUpdates.User_Data' <CODE>
' ' In One DLL '
Public Class Menu
#Region "Structures"
Public Structure User_Data
Dim ID As Integer Dim Role As String Dim Preferences As String
End Structure
#End Region
#Region "Variables"
Public UserData As User_Data
#End Region
#Region "Update"
Private Sub cbUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _ Handles cbUpdate.Click
Dim oSS As New SS.clsUpdates
oSS.SetUserData(UserData)
End Sub
End Class
' ' In Another DLL '
Public Class clsUpdates
#Region "Structures"
Public Structure User_Data
Dim ID As Integer Dim Role As String Dim Preferences As String
End Structure
#End Region
#Region "Variables"
Public UserData As User_Data
#End Region
#Region "Set User Data"
Sub SetUserData(ByVal UD As User_Data)
UserData = UD
End Sub
#End Region
End Class
<\CODE>
All help gives me is:
A statement attempts to convert one data type to another in a way that is not defined. Possible causes of this error include the following:
A conversion specifies two data types between which no conversion exists. An example of this is a conversion from a Boolean value to the Date type.
An initialization of an array does not include braces ({}) following a New clause. In this case, <type2> is of the form '1-dimensional array of <type>'.
I have IDENTICAL code that passes simple types between these same two DLL's successfully. Therefore, I assume it has something to do with Structures.
Any ideas,
Roger
- 10
- Visual Basic Language Any idea, please...
Hello, A question please. I have 2 environments of working. TEST (this is for tests only) and PRODUCTION (this is my release distribution).
Now, for example, I create 1 dll that opens my connection. 2 different connections. I'd want to open my connection depending on if I am testing (on TEST environment) or if the program is running on the customer PC (PRODUCTION environment).
After I got my program to modify it, how could I set the environment of working without modify my program I mean if my program is running on the development PC, it must open a connection (test connection) , and If my program is running on customer PC, it must open another connection (release connection).
Thanks in advance....
- 11
- Visual Basic General Button!
Hello all, I am a total visual studio newbie and need help with a very basic task and was wondering if anybody could help me.
I basically need a button on my userform to be able to link to an external application, for example the user presses the button and the alternate application will then open.
Thank you if you can help me with this problem I am having I hope to learn much more within visual studio as it seems to be a vast but brilliant program.
- 12
- Visual Basic IDE MessageBox.Show is Not Displayed Properly!
I’m using Visual Basic 2005, I have experienced a problem with displaying a message box after opening several windows form in the same project.
After the messagebox.show function is executed, the project freezes which is a correct behavior (You can hear a sound if it is a typed message box), but the message box is NOT displayed on screen! You need to open any application with a maximize mode and minimize it again to see the message box!
As a wasted effort, I tried to re-install .NET Framework 2 and Visual Basic!
Please Help
- 13
- Visual Basic Language Transfer Array from VB.net to C++ and Back
I am having a bit of a frustrating problem. I am trying to pass an array of unsigned short to a c++ .dll which the dll will populate and return. I have tried to convert it to a managed dll, but I am still having issues.
The debugger in the vb.net side( 2k5) is returning 'getMeasurement' has a return type that is not supported or parameter types that are no supported for the below highlighted statement
Any help/advice is greatly appreciated!
Here is the code I am using:
vb 2005 code Public Shared usSampleBuffer() as UInt16 Public Shared iResult as Integer Public Property bReadingStatus() as Integer Get Return iResult End Get Set (ByVal iHold as Integer) ReDim usSampleBuffer(256000) Dim lRoutine as New RoutineDLL.clsRoutineDLL Dim usTemp as UInt16 Dim cDevice as Char = "0" iResult = lRoutine.getMeasure(clsSettings.iSampleCount, cDevice, usSampleBuffer, usTemp) End Set
End Property
vc++ (2005) code #pragma once using namespace System; namespace RoutineDLL { public ref class clsRoutineDLL {
public: int clsRoutineDLL::getMeasure(int ulSampleCount, char cDevice, array <UInt16>^ usSampleBuffer, unsigned short usTemp)
{ int iI; HANDLE hDevice = NULL; DWORD dwBytesReturned = 0; unsigned long ulMaxTransferSize = 600 * ulSampleCount; unsigned long ulXferCount = 0; int bStatus = 0; unsigned short * pusInBuffer = NULL; clsRoutineDLL::BULK_TRANSFER_CONTROL inBulkControl; if (bOpenDriver (&hDevice, cDevice) != TRUE) { return 9999; } pusInBuffer = (unsigned short *)malloc(ulMaxTransferSize); memset(pusInBuffer,0,ulMaxTransferSize); ROUTINE_CMD CmdDoMeasurement = { 0,2,0,0,0xB4,10,0); CmdDoMeasurement.usValue = (unsigned short) ulSampleCount; dwBytesReturned = sizeof(CmdDoMeasurement); bStatus = DeviceIoControl(hDevice, IOCTL_ROUTINE_COMMAND, &CmdDoMeasurement, sizeof(ROUTINE_CMD), NULL, 0, &dwBytesReturned, NULL); for (iI=1;iI<8; iI++) { bStatus = DeviceIoControl(hDevice, IOCTL_ROUTINE_BULK_READ, &inBulkControl, sizeof(inBulkControl), pusInBuffer + (ulXferCount/2), 51200, (unsigned long *) &dwBytesReturned, NULL); xlXferCount +=51200; }
for (iI=0;iI<256000;iI++) { usSampleBuffer[iI]=pusInBuffer[iI]; } free (pusInBuffer); CloseHandle(hDevice); return (0); }
- 14
- Visual Basic IDE VB.NET FindWindow(Ex) + SendMessage Mouse click (on specific coord). Looks like a challenge?!
Hi all,
I just bought a nice G15 Gaming Keyboard. It has a nice LCD screen with media keys (Play, Stop, Next, Previous etc,).
Anyway, I managed to intercept the original functions to WMP of it (By Global Hotkeying them).
Now, I have to send mouse clicks to my own Music Player (Playa!TraX, it isn't my creation) on a specific coord.
This is the code i have, it finds the window, and says it clicks, but nothing happens, what am I doing wrong
Code:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal Hwnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Private Declare Function FindWindow Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
Private Declare Function FindWindowEx Lib "user32" (ByVal hWnd1 As IntPtr, ByVal hWnd2 As IntPtr, ByVal lpsz1 As String, ByVal lpsz2 As String) As IntPtr
Const WM_LBUTTONUP As Integer = &H202
Const WM_LBUTTONDOWN As Integer = &H201
Public Sub SendClick(ByVal Location As Point)
Dim hwnd As IntPtr = FindWindow("WindowsForms10.Window.8.app3", "Playa!TraX Media Player")
If Handle.Equals(IntPtr.Zero) Then
MsgBox("Not found!")
Else
MsgBox("Found!")
Dim hwnd2 As IntPtr = FindWindowEx(hwnd, IntPtr.Zero, "WindowsForms10.Window.8.app3", Nothing)
Dim lnglParam As String = (Location.Y * &H10000) + Location.X
SendMessage(hwnd2, WM_LBUTTONDOWN, 1&, lnglParam)
SendMessage(hwnd2, WM_LBUTTONUP, 1&, lnglParam)
MsgBox("I clicked")
End If
End Sub
Private Sub Form_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
SendClick( New Point(43, 40))
End Sub
Help will be much appreciated, I can't stand it won't work!
Best Regards,
Lennard Fonteijn, the Netherlands
Ps. It looks like the SendMessage with Coords, Findwindow and mouse clicks are like government secret....
- 15
- Visual Basic Language Application Configuration
Hello. A question, please. I am working with VS 2005. I don't find how can I set the working enviroment. I mean DEBUG, RELEASE. I know that I must see a bouton called SOLUTION CONFIGURATION, but I dont have it. Can anyone help me
Thanks...
|
| Author |
Message |
Hemant Hindlekar

|
Posted: Visual Basic Interop and Upgrade, Accessing VB component property methods from C# application |
Top |
Hello
Can someone help me for the below proble,
I am working on a task of converting one vb6 application in .Net.
Current vb6 application is using one vb dll provided by third party. I have written a code in C# and added the third party dll (developed in vb6) in the reference. The strange problem I am facing is that I am able to access all the properties of vb6 dll but not the methods of the property.One thing I do not know is whether the property datatype is collection or any other datatype.
For example :
TestClient.Client objClient = new TestClient.Client();
I am able access the "GenericBO' property of the objClient but not the "Item" method of the "GenericBO' property.
In current VB6 the same property method is accessed as below
objClient.GenericBO.Item("Administrator").value = "test"
Due to above problem tried the same thing in VB.NET application and found that it works.
Any reason why it is not working in C#.
Visual Basic14
|
| |
|
| |
 |
danych

|
Posted: Visual Basic Interop and Upgrade, Accessing VB component property methods from C# application |
Top |
HI,
Just add the reference "Microsoft Visual Basic .NET Runtime" to your project.
you needs to import "using Microsoft.VisualBasic;"
then try to access the control's methods that you want.
hope that answers ur questions
|
| |
|
| |
 |
Hemant Hindlekar

|
Posted: Visual Basic Interop and Upgrade, Accessing VB component property methods from C# application |
Top |
Hi
Thanks for the reply.
I tried as per your suggestion but I get the error at the time of compilation itself because at the time of compilation it tries to search for the method. The error message is "Object does not contain a defination for item".
Genericbo object contains the method Item() which I am able to see in VB.Net , hence do not get this error VB.Net.
In C# I am unable to see this method so i get the error at the time of compilation. If I do get the solution then I might have to go for VB.Net. Lets see.
|
| |
|
| |
 |
CommonGenius.com

|
Posted: Visual Basic Interop and Upgrade, Accessing VB component property methods from C# application |
Top |
The Item() method in VB is expressed as an indexer in C#. Try objClient.GenericBO["Administrator"].value = "test"
|
| |
|
| |
 |
| |
 |
Index ‹ Visual Basic ‹ Visual Basic Interop and Upgrade |
- Next
- 1
- Visual Basic General Reading dialog resources in .mui Files
I am not sure if this is the right forum to post this question but, here goes.
I am trying to write language independent automation by reading .mui files to get resource strings. Some resource strings are inside of a Dialog object that is contained within the mui file. How do I access the strings within this dialog object Thus far I am having no trouble getting simple strings from .mui files, but strings within dialogs are what I am stuck on.
thanks,
Michael Cartwright - michcart@microsoft.com
- 2
- 3
- 4
- Visual Basic General Using openfiledialog without changing the default start folderIn my application a have an .ini in the same folder as the main program. Since the user can put the program anywhere, when i read from this ini file in my app i just call it without the drive and folders (i just use the command:
Dim laser As New StreamReader("indstillinger.ini", System.Text.Encoding.Default)
And then the file is automaticaly read from the same folder as my program is in. But when i use the openfiledialog to select a file, the new folder that my program seaches for the ini file in, is the same as the folder where i found a file with the fileopendialog.
Anyway to get around this so that the default path isn't changed
- 5
- Visual Basic General Toolstrip Questions
In VB 2005, I have a toolstrip that is inside a panel and docked to the left of the form. I want to place buttons such as Home, Inventory, Contracts, Purchasing etc in the toolstrip that start in the top center of the toolstrip and then below one another but I am unable to achieve this. I have looked at all the properties of the toolstrip but cannot find what I am looking for.
I have images for the buttons and want the images to appear there as well.
I really just want to be able to select the options on the left so that the other forms are displayed on the right hand side.
Dipendra
- 6
- 7
- 8
- 9
- Visual Basic General adding local html files to winforms control at runtime to read with browser.
I would like to add the code to the for loop below which will dynamically add "1 to n" html files found in the current directory and add them to the appropriate vb.net control as a hyperlink, which the user can then click on to launch the html file into a browser window. (using Process.Start most likely) what would those controls be and how would I add these files at runtime I found out the webbrowser control didn't work because it only reads html and doesn't allow for hyperlink (html anchor) functionality. Thanks for any ideas.
For Each filePath In IO.Directory.GetFiles(Environment.CurrentDirectory, "*.html", IO.SearchOption.AllDirectories)
'add to approprate control at runtime
Next filePath
- 10
- 11
- Visual Basic Interop and Upgrade Unload VB.Net ComClass from VB6??
Anyone know how to unload a vb.net dll that is created in a vb6 exe I am able to create a new instance of the dll and it runs without error... The problem is that I can't seem to figure out how to unload it.
I've tried something like "set myVBNETDll = nothing" in the vb6 code, but it doesn't kickoff the finalize() in the vb.net dll. Suggestions Thanks.
- 12
- Visual Basic General Windows form minimize and restore
I have an MDIParent form with a number of controls that are rearranged programmatically. When the user subsequently minimizes and then restores the form, all the controls revert to their original design time locations. I have tried a number of things including putting code in the form's Resize event to retain the most recent locations of the controls, but nothing seems to work. I would really appreciate some help.
Thanks to any and all,
Gerry
- 13
- Visual Basic General Unexpected Results when resetting a dataset
I have what is basically an adhoc query tool that loads a single table (ds.tables("Work")...)in one dataset from SQL server. The dataset can be saved with WriteXml(FileName, XmlWriteMode.WriteSchema) and reloaded with ReadXml(FileName, XmlReadMode.ReadSchema). Because the query behind each dataset might change between saved DataSets I am calling DS.tables("Work").Reset before each reload. The first "reload" of the dataset using the ReadXML works as expected, but if a second resultset is loaded the second set does not produce the desired results.
ds.tables("Work:).rows.count returns the correct number of rows but ds.tables("Work").columns.count always returns 0.
console.writeline ds.writexmlschema or ds.writexml do not return what is expected.
If the program is exited and re-started and the second result set is loaded first, the above commands return good values.
I can even forced a gc.collect, no avail...
VS2003
.NET 1.1.4322 SP1
Any insight is appreciated.
- 14
- Visual Basic General MEMORYSTATUS
Hi, can anyone help me with this code
Public Class Form1
# Region "Memory Status"
Public Structure MEMORYSTATUS
Public dwLength As Long
Public dwMemoryLoad As Long
Public dwTotalPhys As Long
Public dwAvailPhys As Long
Public dwTotalPageFile As Long
Public dwAvailPageFile As Long
Public dwTotalVirtual As Long
Public dwAvailVirtual As Long
End Structure
Public memStatus As MEMORYSTATUS
Public Declare Sub GlobalMemoryStatus Lib "kernel32" (ByVal lpBuffer As MEMORYSTATUS)
Private Sub timer_Tick(ByVal sender As Object, ByVal e As EventArgs) Handles timer.Tick
Label1.Text = memStatus.dwTotalPhys / Math.Pow(1024, 2) 'Returns total Physical size
Label2.Text = memStatus.dwTotalVirtual / Math.Pow(1024, 2) 'Returns total Virtual size
Label3.Text = memStatus.dwAvailPhys / Math.Pow(1024, 2) 'Returns available Physical size
Label4.Text = memStatus.dwAvailVirtual / Math.Pow(1024, 2) 'Return available Virtual size
Label5.Text = (memStatus.dwTotalPhys / Math.Pow(1024, 2)) - (memStatus.dwAvailPhys / Math.Pow(1024, 2)) 'Returns used Physical size
Label6.Text = (memStatus.dwTotalVirtual / Math.Pow(1024, 2)) - (memStatus.dwAvailVirtual / Math.Pow(1024, 2)) 'Returns used Virtual size
End Sub 'Process of using the API within timer and returns to MB size Put this code on your form
# End Region
End Class
the result is 0
- 15
- Visual Basic IDE windows toolbar dropdown button
Hi, All,
I have developed a window app in vs2003. On this form I have a toolbar. One of the button is of dropdown style. As it is right now, mouse clicks on the main icon area of the button will do nothing. Only clicks to its arrow down area (the narrower strip on right side) will make the dropdown menu show.
Does any one know how to make the click on the main icon area has the same effect as clicking on the down arrow
Also, I am converting my project to vs2005. Is there any new control in vs05 that will give me the feature
Thanks!
|
|
|