Fail on .NET class My.Computer

Questions about Wine on Linux
Locked
tjobes
Level 2
Level 2
Posts: 14
Joined: Mon Nov 23, 2020 4:32 pm

Fail on .NET class My.Computer

Post by tjobes »

I'm trying to run a technical app written in VB.NET in Wine. I had a previous thread where some folks helped me figure out how to get the app to work with its database connection.

Now it seems to be failing using the .NET method My.Computer.FileSystem.CurrentDirectory. Does anyone know if My.Computer is implemented in Wine 5.0.2? And if so, is there anything in particular that needs to be done to make it work?

I do now have the VB source, and am looking into replacing this call (made in several places) with a more direct approach, also.
fargodwe

Re: Fail on .NET class My.Computer

Post by fargodwe »

It might be a day or 2 since I would need to reinstall studio on my Windows machine, but I could test that with a simple change to a VB .NET program I wrote and have running in Wine.
tjobes
Level 2
Level 2
Posts: 14
Joined: Mon Nov 23, 2020 4:32 pm

Re: Fail on .NET class My.Computer

Post by tjobes »

That would be much appreciated!

I found in the .NET System.IO namespace a set of methods for get/set current directory and copying files, which could replace the calls from My.Computer, but I also have a delay before I can get a VB compiler to try it myself.
fargodwe

Re: Fail on .NET class My.Computer

Post by fargodwe »

Humm, my program uses a 32-bit prefix. I modified it so that it does

Code: Select all

msgbox(My.Computer.FileSystem.CurrentDirectory)
That worked fine. I haven't actually tried anything else with it but that part did work. Using winetricks I installed the lastest .NET and accidentally installed netcore2 as well.

That program was generated with visual studio community edition 2019. I had previously used VB 2010 because previous use of one of the studios resulted in my code getting hosed in translation. 2019 seemed to convert the program fine.

How exactly are you using My.Computer.FileSystem.CurrentDirectory ? Could you post back samples of what you are doing and I can try to duplicate.
fargodwe

Re: Fail on .NET class My.Computer

Post by fargodwe »

BTW - I just tried the above, then setting it, then showing it again and it worked fine. This is a snippet of the code so you can see the common sub I use for showing messages and the code were I added the things to test the My.Computer.FileSystem.CurrentDirectory

Code: Select all

    Private Sub ShowMessage(ByVal message As String)
        mymessage.Label1.Text = message
        mymessage.ShowDialog()
    End Sub


    Private Sub Button_Misc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_Misc.Click

        ShowMessage(My.Computer.FileSystem.CurrentDirectory)
        My.Computer.FileSystem.CurrentDirectory = "c:\"
        ShowMessage(My.Computer.FileSystem.CurrentDirectory)

        Print_Cards.ShowDialog()



    End Sub
I know these are just very basic uses. Perhaps there is a problem with path conversion or something in what the program you are using is doing.
tjobes
Level 2
Level 2
Posts: 14
Joined: Mon Nov 23, 2020 4:32 pm

Re: Fail on .NET class My.Computer

Post by tjobes »

Finally could get back to this project....

Here is a typical example - very simple. Save the current directory as a string. Set it to a new value from a string constructed elsewhere in the code. Do some stuff. Set it back to the original value. Do some different stuff.

Dim OriginalDirectory As String = My.Computer.FileSystem.CurrentDirectory
My.Computer.FileSystem.CurrentDirectory = workingPath
....
My.Computer.FileSystem.CurrentDirectory = OriginalDirectory
...
fargodwe

Re: Fail on .NET class My.Computer

Post by fargodwe »

It will probably be late tonight or else early tomorrow before I can get to this and try it out. BTW - is workingPath a variable you defined or is that a builtin?
fargodwe

Re: Fail on .NET class My.Computer

Post by fargodwe »

I just took a few minutes and did this before I do the rest of what I need to do today. I just placed the code inside an existing sub routine in my code so I could remember where it is so I can delete it when all done:

Code: Select all

  Private Sub ShowMessage(ByVal message As String)
        mymessage.Label1.Text = message
        mymessage.ShowDialog()
    End Sub


    Private Sub Button_Misc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_Misc.Click

        Dim OriginalDirectory As String = My.Computer.FileSystem.CurrentDirectory
        Dim workingPath As String = "c:\Program Files"
        ShowMessage(OriginalDirectory)
        My.Computer.FileSystem.CurrentDirectory = workingPath
        ShowMessage(My.Computer.FileSystem.CurrentDirectory)
        My.Computer.FileSystem.CurrentDirectory = OriginalDirectory
        ShowMessage(My.Computer.FileSystem.CurrentDirectory)

        Print_Cards.ShowDialog()



    End Sub
It worked as expected, first showing "c:\Program Files (x86)\BINGO", then "c:\Program Files" then back to "c:\Program Files (x86)\BINGO". So while I had no "do other stuff" ;) it did still work as expected. Perhaps whatever is building "workingPath" in your code is not building a valid path? If it worked in Windows there might be a problem with path translation. Is it possible to post a snippet of the code where it builds workingPath as well as a sample of what should have been built in that code?
fargodwe

Re: Fail on .NET class My.Computer

Post by fargodwe »

If you have the source and if you have access to a windows PC, try installing Visual Studio Community Edition 2019 and building it there. Try it in windows, then bring the exe over to your wine prefix and see what happens.
tjobes
Level 2
Level 2
Posts: 14
Joined: Mon Nov 23, 2020 4:32 pm

Re: Fail on .NET class My.Computer

Post by tjobes »

Hey @fargodwe. I do have the source. There is still a delay getting VS on my work computer, but putting the CE on my own is a good idea.

The fail is an unresolved reference in the first My.Computer call, not the reset to workingPath. Perhaps our Wine setups are different, so that yours can find it but mine can't?
fargodwe

Re: Fail on .NET class My.Computer

Post by fargodwe »

Hmmmm. Could you tell me what version of wine and winetricks you are using. Also how you created the prefix and installed the program? I'd like to come as close as I can to duplicating what you are installed in and try my program from there.

Please include and extras you installed via winetricks - I know you have mdac28 and jet40 installed but don't know what else. I assume some version of dotnet as well.
fargodwe

Re: Fail on .NET class My.Computer

Post by fargodwe »

Would you be willing to privately share the source? I could try building it in Visual Studio Community Edition 2019 (btw - it's free) and try a new wine prefix to see if I can get it to work.
tjobes
Level 2
Level 2
Posts: 14
Joined: Mon Nov 23, 2020 4:32 pm

Re: Fail on .NET class My.Computer

Post by tjobes »

I'm afraid I'm not allowed to share the source, due to an understanding I have with the developer. I'll try the free community edition myself, hopefully later this week. I appreciate the offer, though.
tjobes
Level 2
Level 2
Posts: 14
Joined: Mon Nov 23, 2020 4:32 pm

Re: Fail on .NET class My.Computer

Post by tjobes »

I'm using wine 5.0.2, and winetricks dated 20200412. I have the sha sum if you need it. The installed windows components are dotnet48, dotnet40, jet40, mdac27, mdac28, and wsh57. The order of installs was dotnet48 (which adds dotnet40 automatically), then mdac28, then jet40 (which adds mdac27 automatically). I'm not sure which step added wsh57.
fargodwe

Re: Fail on .NET class My.Computer

Post by fargodwe »

The winetricks is 20201206-next (via self update).

Wine version is 5.0.2

i'll go through and create a 32-bit prefix and put everything in as you did and test again, Not sure why wsh57 is there. Does the program connect to a network? Is it failing when it is trying to access a remote file? Does it execute any VBScript's?

What path shows as being built for the first time as you mentioned?

My test app doesn't actually use jet but I loaded it anyway to test. I can try to write a small program create a sample database via vb.net so I can test it, but that won't be for a little while. How does it connect to the database? ODBC?

It would be easier just to use your source and visual studio. If privacy is a concern p.m. me and we can try to exchange via email or other means. I would never disclose or keep the source. It would be purely for testing. If it does use a network then that might be a problem. Via PM or email I would be happy to do a non-disclosure with the developer if that would help.

BTW - not that I would know, but if this accessing any adult content somewhere I would prefer not to be involved.

Thanks.
tjobes
Level 2
Level 2
Posts: 14
Joined: Mon Nov 23, 2020 4:32 pm

Re: Fail on .NET class My.Computer

Post by tjobes »

Sorry for the delay in responding - the holidays were very busy. To answer your questions as best I can:

The program fails trying to change working directory, in this case on a local drive, not remote.
It does not connect to the network.
It does use MS Access to run VB macros.
Yes, ODBC. Would you like to see the actual DB connection call?
By agreement with the developer, I can't share the code, and I dno't believe they would be willling to set up a special NDA for volunteer debugging help, but I appreciate the offer!
No, there is no "adult content" involved. Purely a technical app.

Thanks again for your continuing help.
fargodwe

Re: Fail on .NET class My.Computer

Post by fargodwe »

I really doubt that without the code I'm going to be able to do anything. To debug you need to know what you are debugging.
tjobes
Level 2
Level 2
Posts: 14
Joined: Mon Nov 23, 2020 4:32 pm

Re: Fail on .NET class My.Computer

Post by tjobes »

@fargodwe, I understand. I wasn't really expecting you to debug this for me, in the end. I have other projects ahead of this one in priority at the moment - this is why my progress has been so slow, not because I'm sitting around waiting for you to do my work for me! But you've given me many useful tips on how to move forward, and I truly appreciate all of your help thus far. I'll post progress when I have any. In the meantime, I wish you the best. Cheers
fargodwe

Re: Fail on .NET class My.Computer

Post by fargodwe »

I would definitely added either some debugging statements or some temporary messagebox's to show the contents of everything each time before and after doing anything dealing with the paths. That should help find the problem quickly.

Good luck, and when you get back to it let me know if there is something I can do. Even just a snippet of the exact code where it is failing *might* help - but no promises there either.
fargodwe

Re: Fail on .NET class My.Computer

Post by fargodwe »

I'm curious if you've done any more with this and if so what and the results.
Locked