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:
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.
I've come from a Assembler and C/C++ background, so I understand the concept behind reference types versus value types in vb.net. Also, I've read Jon Skeet's article regarding references and value types and I understand all of that. My question is: How can you tell if a given type is a reference type or a value type? Is it simply that all integral types (ints, floats, etc.) are value types and all classes are reference types? (If so, where do strings fall?)
I'm trying to add a new record to my database but i keep getting the message - "conversion from type DBnull to type string is not valid". I think its something to do with the Employee ID when VB attempts to save it to the database my code is below
Imports System.Data.OleDb Public Class Add Private Sub DisplayRow()
I now have SQL Parameters set up and I'm using them to save/delete/add my data. This all works well, except when it's trying to save a combobox to the datatable it appears with the error above.Majority of my comboboxes have datasources, and the valuemembers of these are the actual list items, not the ID's of the list items.I'm not sure why this error could be happening, I'm fairly sure I've connected everything to the binding source correctly; I've checked it a few times.Does anybody know what the cause of this could be? I've looked around a bit and I haven't found much
I've spent quite a bit of time reading up on generics, covariance, etc., and I am failing to understand why I get the aforementioned compiler error in this type of codeLet's say I have a base "Bill" class made up of a collection of Lines..
Public Class Bill(Of L As Line) Private _lines As List(Of L) Public Property Lines() As List(Of L)
I am implementing IMAPI2 into my vb.net project but ran into a wall. I am getting the message Unable to cast object of type 'IMAPI2FS.FsiStreamClass' to type 'IMAPI2.IStream' when trying to start the burn. I googled around and found this is something that microsoft hasn't fixed.. which basically renders IMAPI2 useless in vb.net.
I found a post on codeproject.com by eric hadden who combined the IMAPI2.dll and IMAPI2fs.dll into an c# interop file. I also see the IBURN interop in microsoft SDK samples. I'd like to use either, but it's in c# and I'm using vb express. Does anyone know a way to get the interop into visual basic or a way around "Unable to cast object of type 'IMAPI2FS.FsiStreamClass' to type 'IMAPI2.IStream'"?
I'm having a problem with converting from one source type to a destination type. I have a form with 2 buttons (button 2 uses the OpenFileDialog to have the user open an excel file set to NewFile),(button 1 takes the contents from specific cells in NewFile and arranges them how I need into oXLApp1).
The error I get is "Unable to cast object of type 'System.IO.FileStream' to type 'Excel.Application'." in line 14 of the code below.
Public Class Form1 Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
I'm new to VB 2005, the code below is actualy coded from VB 6 and just converted it to VB 2005. I'm having trouble with line that's on bold letters.In VB 6 this works just ok. By the way the error message is "Unable to cast object of type 'System.String' to type 'ADODB.Connection'." [code]
I have a number of controls (Device1, Device2, etc.) that all inherit from BaseDeviceControl. In the DragEnter event handler I am trying to test for the correct type by using the BaseDevvceControl like this....
I'm compiling a VB.Net 2.0 app (created in VS2008) using msbuild, and now I've added a generic return type, it's giving me the following:
Warning: Type library exporter encountered a generic type instance in a signature. Generic code may not be exported to COM.
Having just spent ages removing all of the previous warnings, I don't really want to add a new one. Any idea how to get rid of it (aside from not using generics)?I don't know what details I'd put in the attribute, or what number to put in the project-level ignore list.
I am pulling data from a local MSSQL database using a stored procedure, then send the data to a web service. Every part of the component works well except for a pesky problem will a DBNull being returned from the DataRow field, when I know that the field is not null and has valid data. The database and associated INSERT statements that add to this field are designed to not allow NULL entries. When I debug break the program on or right before the line that throws the error I see that the field has valid data for the current row.If I add a null check to the code (as below) the operation continues as normal:
Dim dataResultsTable = Me.myViewTableAdapter.GetData(int) For Each myDataRow In dataResultsTable.Rows If worker.CancellationPending Then
[code]....
Why is the read operation returning DBNull instead of the data in the database?
EDIT: Just to be clear, the operation does return the proper data, but the data is not being saved into the variable.
But i am now trying to declare time however i keep getting an error because i cannot get the type correct. I tried the following but get the following error: "Conversion from type 'Timespan' to type 'integer' is not valid".
Dim DeliveryTime as DateTime Dim DeliveryTime as Integer
In my database the DeliveryTime type is set to Time(7) so i would assume there should be 'Time' which i could use to declare it, but there isnt. What is the correct type i should be using?
Here is my exact code. There error is Input string was not in correct format:
GraphDate4 = String.Empty DeliveryProducts = "{ name: 'DeliveryProducts', data: [" If DataReader4.HasRows Then
I'm using a date/time picker control and sending the db value to it. I know that the value is null, but I don't understand why the Picker can't be blank. Is there a way to let it be blank? Or should I set up a way to check for nulls and assign today's date or something just in case?
Error 1Server Error in '/ Application. -------------------------------------------------------------------------------- Conversion from type 'DBNull' to type 'String' is not valid. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.InvalidCastException: Conversion from type 'DBNull' to type 'String' is not valid. Source Error: Line 64: Line 65:
Could anyone assist me in solving my problem ? My code was written in VB (VS 2003.)I got this error: System.InvalidCastException: Cast from type 'DBNull' to type 'Integer' is not valid. in my code.Here is the code line where I am getting the error: LeadCampusID = CInt(.Item("mkCampusID"))I fixed the error by making the changes in the code as :
If Not IsDBNull(.Item("mkCampusID")) Then LeadCampusID = CInt(.Item("mkCampusID")) Else
When i execute this linq to sql command its given an error "The null value cannot be assigned to a member with type System.Int32 which is a non-nullable value type." 0 Records in my Commotidy Table
I want generate manual number and get the last CommodityCode.My Code as follow,
Dim QRecordCount = From RC In cntxtCommodity.CommodityMasters _ Where RC.CommodityCode <> 0 _ Select RC.CommodityCode[code].....
Unable to cast COM object of type 'System.__ComObject' to class type 'rjsDocMan.Folder'.Instances of types that represent COM components cannot be cast to types that do not represent COM components; however they can be cast to interfaces as long as the underlying COM component supports QueryInterface calls for the IID of the interface.The code where it is flagging the error is:
I saw this thread and I had simple answer in mind. To use custom enumerator class. So I was trying to make one for that guy, which would have one more property to check whether its has reached end or not. It would also provide current position.I'm getting an error "Unable to cast object of type 'SZArrayEnumerator' to type 'WindowsApplication1.myEnumerator'." at the line 6 [see below].However, return type of values.getEnumerator says its IEnumerator. [code]
Columns 0 & 1 are filled from a DataAdapter from Access Database and three are added. I had this working, but I changed it to check for the column "Feed" so I could add several Locations. At first this worked,but I did someething in perfecting it and it now fails after filling the first row of the datagridview (dgvFdMed).I ran a check and the table LotsTab has 8 rows filled. Column 1 & 2 are strings and the database appears they are fine. The added columns have just been created with no value. My plan is to enter the values and then use the data from the grid.
Private Sub sfillGrid(ByVal Loc As String) Dim i As Integer Dim column As DataGridViewColumn
I have 2 Child forms inside a parent. For example, FrmChild1 contains a "Friend Sub" I wish to call.I would like one of the child forms to call that sub from another child form (we will call it FrmChild2. The following code works, but when it's done going through the "For Each", I get a "Invalid Cast"
' THIS CODE IS IN FrmChild1 For Each mFrmChild2 As FrmChild2 In FrmParent.MdiChildren mFrmChild2.GuestRefresh(False) Next
Error after calls are made:"Unable to cast object of type FrmChild1 to type FrmChild2.
In the code above, if there are no children (the ChildrenPath property returns NULL), nothing is rendered in the view. In the code below, when ChildrenDataSetPath is NULL the XamDataGrid still gets rendered. How do I achieve the same for a single object (as opposed to a collection) as the datacontext?