|
I suggest you create a little C# EXE project, which also references said DLL, and mimicks the start-up of your VB.NET code.
FWIW: make sure all projects (EXE and DLL) refer to the same .NET version, you can't mix and match in general, some combinations could work (such as 3.5 and 2.0; bowever 4.0 and 2.0 would not). That is true even when using a single language.
|
|
|
|
|
This was a VERY good idea, Luc - I have to admit that sometimes I don't think of the obvious
So here's what I did and the results:
- took a given c# sample (which contained the unsafe code that I had extracted to a dll)
- deleted all these classes
- replaced them with the reference to the dll
RESULT: The C# program runs just like it's supposed to! So I figure the dll is ok, right?
Then I converted this modified project to VB.NET (using latest SharpDevelop 4.1)... No error messages regarding the conversion. But: Starting the VB project --> RESULT: The same error!
Unfortunately the compiler refuses telling me WHICH module it's missing, so I still have no clue about that. Would you know a way how to find that out?
|
|
|
|
|
There are a few subtle differences between C# and VB; I'm not sure if any of these would cause the error you see, but I'll throw them out there for you to look at:
1. VB does not support unsigned integers; if a C# DLL has any public methods/properties which take/return uint's, the DLL will not function properly when referenced from VB code.
2. C# and VB vary in their usage of indexers; I'm not 100% clear on the difference, but I seem to recall VB treating them internally as a property called Item. So I suppose if you have an actual property called Item in a C# class, that could throw VB off, into thinking it's an indexer or something...
3. VB supports some sort of XML-literal syntax; I've never used it so I'm not all that familiar with it, and since you're trying to reference C# code from VB, not the other way around, this probably isn't an issue, but I'll mention it nonetheless just in case...
edit: also, one more thing... there are some special namespaces Microsoft.VisualBasic and Microsoft.CSharp with language-specific utilities; I'm not sure if it's legal to reference one of those from the "opposite" language, but it might be worth looking into...
|
|
|
|
|
Thank's for your thoughts, ekolis! I think I took care of the differences you mentioned, as well as deleting the root namespace in VB (obviously VB adds the dll's namespace) which the conversion didn't care of. The UInteger issue btw seems older information or at least not completly true - I checked that and can surely define a 'UInteger' type variable in VB.
The funny thing is: My code starts with calling the 'MainForm' - but doesn't even reach the "Sub New" in this MainForm when I step through it. I wish I could find out what throws the 'FileNotFoundException' (just saying 'module not found' without it's name or path)...
|
|
|
|
|
Here is another suggestion: turn your VB.NET WinForms app into a Console app so you can control its start-up; more specifically:
1. in solution pane, right-click the project, then "Add a Module", default filename would be Module1.vb
2. in that file, stuff this (assuming your main form is called Form1):
Module Module1
Sub Main()
Try
Application.run(New Form1)
Catch ex As Exception
Console.WriteLine(ex.ToString)
End Try
Console.WriteLine("hit any key to finish...")
Console.ReadKey()
End Sub
End Module
3. in solution pane, click project/Properties, set app type to "Console Application" and startup object to "Module1"
4. Now build, run, and watch what shows in the Console window. Hopefully the full diagnosis will be there.
|
|
|
|
|
Wow - Luc, this approach seems to give me the key! After follwoing your advice, my error code is much more specific in the console window (translation): "System.Resources.MissingManifestResourceException: ... no resources for the culture found ..." etc.
Following that hint, I see that the form's .resx file is missing in the VB-converted project (actually that's the case with every form...). I don't yet know how to add the missing resources, but I'm highly motivated to get over this thing soon - and hopefully find that at least I wasn't to blame for messing up the dll
Thank you very much for your support
|
|
|
|
|
you're welcome.
I can't help much with resource files, as I avoid them as much as I can... Good luck with them!
|
|
|
|
|
How about write a C# app to test if the C# DLL works first?
|
|
|
|
|
Hi everybody,
I've been running into something where I have no idea how to debug: A FileNotFoundException right at the beginning of the main form creation. :
"Das angegebene Modul wurde nicht gefunden. (Ausnahme von HRESULT: 0x8007007E)"
Translation: "The module could not be found (Exception of HRESULT: 0x8007007E)" The stack trace message starts with:
"bei Tesseract.OCR.AppEntry.MainForm..ctor()"
Following the 'ctor' hint I see my very simple constructor:
Public Sub New()
InitializeComponent()
Initialize()
End Sub Stepping through, it doesn't even reach the "InitializeComponent" command. It have the feeling there's something wrong in the Form Designer module (which I had to edit). Starting with the form itself (not the 'program' class) I find the error marker in the very first line of "Mainform.Designer.vb" ('Partial Class MainForm').
Could someone please give me an idea where to look or how to start debugging at that stage?
Thank you
Mick
modified 11-Oct-11 6:12am.
|
|
|
|
|
Maybe translating your messages into English would help.
|
|
|
|
|
We shall see if that really was the hard part And btw I hope your signature wasn't part of you answer, was it? To be honest I wouldn't want my computer build my character
|
|
|
|
|
I am not sure about the specifics of your problem but a quick Google search of the error code results in this[^].
|
|
|
|
|
Thank you, Richard. I did that, but as you see there are millions of possibilities with thousands of different backgrounds. I have a clue which is connected with a dll reference - but I guess this will have to be a different thread.
|
|
|
|
|
I know that I have seen many hits on folders in the new .net FTP classes.
I need to rename/move a file to a different folder after downloading.
When I log into the customer's FTP site via the url, user, password it put in into a particular folder.
I can download these files using the URI but I cannot Rename (Move) into a different folder (i.e. DONE). I get a
The remote server returned an error: (550) File unavailable (e.g., file not found, no access
using the FTP Class and FTPClient.
Please tell me how this can be done without using 3rd party software.
The issue seems to be sending the URI out with
ftp://nnn.nnn.nnn.nnn/x.txt
when in fact we are in a folder based on the user ID home folder.
i.e. ftp://nnn.nnn.nnn.nnn/user/x.txt
Just don't know how to get around this.
Please help.
|
|
|
|
|
I'm using VB2008 with MS Access Database.
I make connection with DB by using the automatically way (by add a new data source ....)
I create the Sql in "SELECT id, na, num FROM Table1" by add query to Table1TableAdapter, and add this code in form to call the sql :
Me.Table1TableAdapter.Fill(Me.AcddDataSet.Table1)
And it succeed with me
I tried same way with insert data to DB like this
INSERT INTO Table1(num) VALUES (?)
And in form
Me.Table1TableAdapter.InsertQueryX(900)
It show the new data after run the program , but didn't save it to the DB Access
How to fix this problem
|
|
|
|
|
Did you set the attribute
GenerateDBDirectMethods = true
in your case:
Table1TableAdapter.GenerateDBDirectMethods = true
I think the attribute explains itself, but is normally set to true by default.
|
|
|
|
|
Hello !
i have a vb.net app , and i need to import data from excel sheet to sql server ( i'm using entity framework 4)
I need to specify column and row range from which i want to read.For example from columns E to G and from rows 5 to 20.
Is possible to do that ?
thank you.
|
|
|
|
|
|
This may help too[^]
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC Link[ ^]
Trolls[ ^]
|
|
|
|
|
Hello everybody,
i want to sort a specific part of my datatable in a different order. this is how i try to achive my goal:
1. Determine begin- and end-indices of the subset of the datatable
2. Import Rows into a new, temporary datatable
3. Assign new datatable to a dataview via the method DefaultView
4. Sort dataview
5. Reassign data from dataview to temporary datatable with method ToTable
6. copy datarows of temporary datatable to the origin datatable, beginning at the determined indices
I have two questions concerning my algorithm:
1. Is there an easier way to solve my problem?
2. step four doesn't work, because the columns of the origin datatable are not recognized in the new datatable. The question is: How can i import rows of an existing datatable to a new datable?
thanks in advance
Armigo
Code for step 2-4:
For i = iBegin To iEnd
tempTable.ImportRow(dataset.Tables("xy").Rows(i))
Next
dataview = tempTable.DefaultView
dataview.Sort = "a, b"
modified 10-Oct-11 7:55am.
|
|
|
|
|
First, sorting is only applicable to records shown to the user. Databases do not care about record order, so sorting them and writing the sorted records back to the database does absolutely nothing. The records will not be moved aorund to the new sorted order.
So, what's the point of all this?
|
|
|
|
|
Hi Dave,
thanks for your reply. I'm working with ADO-classes and i fill my datatable (ADO-class) with data from my database. I use the "ORDER BY"-statement in my SQL-string to fill my datatable in the needed order. But at one specific part i need to change the order.
For example, i fill my datatable via a tableadapter (also ADO-class) with the SQL-Statement
SELECT * FROM myDB ORDER BY a, b DESC
Then, the data are stored in my datatable in exact the order given by the statement. I go through my datatable an do some calculations with my records. When i reach - lets say - record No.30, i want to change the order of the next 10 records. After the 10 records, the order should remain the same as before.
I hope you could understand it better now.
|
|
|
|
|
If I understand you correctly you
Want to modify your a subsection of your datatable with a new order which still sits within the same datatable?
If I have this correct then as far as I am aware there is no existing method that can do this other than making yourself a routine to rebuild the datatable in the order that you want
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
Well, You'd have to build your own DataView from the data in the DataTable object, adding the records you need in the order you need them. You will have to implement your own sorting algorithm to do this.
In your example, you'd have to add records 0 through 29, then create a collection of records 30 through 40, send that to be sorted, then add those sorted records to the view, then add the remaining records.
|
|
|
|
|
Hello everybody and thanks for your replies,
i could manage to solve the problem with the algorithm presented in my first post. Here is my solution for those, who are interested in it:
iBlockRowStart = iCurrentRow
iBlockRowStop = iBlockRowStart
Do While System.Convert.ToDateTime(DS.Tables("AnyTable").Rows(iBlockRowStop).Item("Date")).DayOfWeek = dayofweek.Friday
iBlockRowStop = iBlockRowStop + 1
If iBlockRowStop = DS.Tables("AnyTable").Rows.Count Then
Exit Do
End If
Loop
iBlockRowStop = iBlockRowStop - 1
tempTable = DS.Tables("AnyTable").Clone()
For j = iBlockRowStart To iBlockRowStop
tempTable.ImportRow(DS.Tables("AnyTable").Rows(j))
Next
View = tempTable.DefaultView
View.Sort = "ColA, ColB"
Dim tempTable2 as DataTable = View.ToTable()
For j = iBlockRowStart To iBlockRowStop
For k = 0 To tempTable2.Columns.Count - 1
DS.Tables("AnyTable").Rows(j).Item(k) = tempTable2.Rows(j - iBlockRowStart).Item(k)
Next
Next
With this piece of code it is possible to sort a part of a datatable in a dataset in another order. In my case, i needed this repeatedly when the date of my record was friday. I needed to sort my "friday-records" in another order. My datatable was filled with data of a month, so i had four fridays...
Thanks again for your help!
|
|
|
|