just downloaded microsoft compatability package 8.04 for VS2022, and...I have questions


sdowney717

Well-known member
Member
VIP
Local time
4:42 AM
Posts
1,013
OS
windows 11
extracted it with 7Zip, but not sure that needs to be done.

HOW can it be today, yesterday and last month? I just unzipped the files few minutes ago.
I find that very confusing.

How to install the package? what does this mean?
shows this
dotnet add package Microsoft.Windows.Compatibility --version 8.0.4


1713811749379.png
 

My Computer

System One

  • OS
    windows 11
    Computer type
    PC/Desktop
    Manufacturer/Model
    some kind of old ASUS MB
    CPU
    old AMD B95
    Motherboard
    ASUS
    Memory
    8gb
    Hard Drives
    ssd WD 500 gb
The Microsoft.Windows.Compatibility package provides Windows-specific APIs to help you port your .NET Framework applications to .NET Core 2.0+, .NET 5+ or .NET Standard. This package offers a smoother transition for those looking to modernize their applications without losing access to familiar Windows functionalities.

Getting Started​

To start using the Microsoft.Windows.Compatibility package, you'll first need to install it via NuGet Package Manager, Package Manager Console, or by editing your project file.

Usage​

After installing the package, you can access Windows-specific APIs just like you would in a .NET Framework application. Below are some examples in both C# and VB:
 

My Computer

System One

  • OS
    WIN 10 Pro
@Rollback_Jockey You just copied and pasted from the page that OP already linked to. How is that helpful?

@sdowney717 You can run that dotnet command (dotnet add package Microsoft.Windows.Compatibility --version 8.0.4) from the command prompt to install thet NuGet package. I prefer to run it from the developer command prompts that come with Studio, but it actually does work from the regular command prompt.

If you click those other tabs on the nuget.org page you linked, you can see other ways to install the package, if you want, e.g., adding a package reference to your project.
 

My Computers

System One System Two

  • OS
    Windows 11 Pro 23H2 [rev. 3447]
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC12WSHi7
    CPU
    12th Gen Intel Core i7-1260P, 2100 MHz
    Motherboard
    NUC12WSBi7
    Memory
    64 GB
    Graphics Card(s)
    Intel Iris Xe
    Sound Card
    built-in Realtek HD audio
    Monitor(s) Displays
    Dell U3219Q
    Screen Resolution
    3840x2160 @ 60Hz
    Hard Drives
    Samsung SSD 990 PRO 1TB
    Keyboard
    CODE 104-Key Mechanical Keyboard with Cherry MX Clears
  • Operating System
    Linux Mint 21.2 (Cinnamon)
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC8i5BEH
    CPU
    Intel Core i5-8259U CPU @ 2.30GHz
    Memory
    32 GB
    Graphics card(s)
    Iris Plus 655
    Keyboard
    CODE 104-Key Mechanical Keyboard - Cherry MX Clear
@Rollback_Jockey You just copied and pasted from the page that OP already linked to. How is that helpful?

@sdowney717 You can run that dotnet command (dotnet add package Microsoft.Windows.Compatibility --version 8.0.4) from the command prompt to install thet NuGet package. I prefer to run it from the developer command prompts that come with Studio, but it actually does work from the regular command prompt.

If you click those other tabs on the nuget.org page you linked, you can see other ways to install the package, if you want, e.g., adding a package reference to your project.
I managed to do it in vs2022 in the nuget section of the IDE
At the PM prompt enter the install command and it retrieves the package and installs it in vs2022.

I have noticed with computer things, a certain knowledge is assumed about procedures , and websites do not actually show a person what to to do.
 

My Computer

System One

  • OS
    windows 11
    Computer type
    PC/Desktop
    Manufacturer/Model
    some kind of old ASUS MB
    CPU
    old AMD B95
    Motherboard
    ASUS
    Memory
    8gb
    Hard Drives
    ssd WD 500 gb
I have been converting a huge vb6 project of mine from vb6 to vbnet.
I have 25 forms and 20 modules of code.

You know how same language has different dialects, that is what it is like between vb6 and vbnet

I found helpful to use vs2008 to 'convert' vb6 project to vbnet, but only as regards a rough framework for the coding as lots of things it does is wrong. I would say 10% of the code it screws with badly that that part must be recoded to be working in vbnet.

It created a project with over 3000 errors to daunting to do anything with.

So what I did was start a new vbnet project, and one by one add forms from the converted project into the new net project and fix the code line by line.
The forms themselves seem to convert mostly ok, except for imagelist control which it just drops completely and the slider control too.
Slider in vbnet has become trackbar. imagelist is the same name but it just drops it.
Several times the code designer cant load a form, so I learned to edit that code taking out the failed lines, often finding 'vb6.' something to be a culprit and references to controls not imported. vs2022 will tell you not to edit the code as the designer does it automatically, but I found you can and I have to. the designer creates that file and when you remove the defective lines it can then load the form.

And control arrays same stupid stuff, the converter artinsoft will give the controls a new name similar to the control array name, but the designer code window also keeps the original reference to the array while adding the proper new codes for the renamed controls, so all that has to deleted from that file. to display the form

You create a control array in vb6 by placing a control on a form, then say copy the control and paste, paste paste. That forms a control array.
Which was useful timesaver making forms in vb6
 

My Computer

System One

  • OS
    windows 11
    Computer type
    PC/Desktop
    Manufacturer/Model
    some kind of old ASUS MB
    CPU
    old AMD B95
    Motherboard
    ASUS
    Memory
    8gb
    Hard Drives
    ssd WD 500 gb
I also gave up on using vs2008 for doing any more coding fixes as I found it has a major flaw with using 'getsetting' from the windows registry.

I use a casual encryption sub that uses XOR to flip chars in a string and write it into the registry to prevent people from snooping into db connection strings etc... and the sub uses extended ASCII char table. With vs2008, getsetting quits in the middle of the encrypted registry string and only gives you half of what is in there, dies on some char maybe null chars.

vs2022 though works just like vb6 getsetting and retrieves the entire string stored in the windows registry.

The fact the MS chose to fix getsetting shows they knew it had flaw in vs2008.

here is that sub, works only for vb6 and vs2022 and this has worked since win98

I was forced though to use AES crypt decrypt database functions in MariaDB as their ODBC driver also died in the same way as vs2008
The database though is able to handle the string, their driver could not. MySQL and MSSQL it worked fine. I had just recently added MariaDB to the servers that can work with the program. Since AES function works the same way in MariaDB and MySQL i now use that for password and privileges storage in my program. But I left it alone for MSSQL and for storing db connection strings which still use the code below.

storing the DB connection string in the registry means a user will never have to enter db connection settings to start using the program.
Start it up and it just runs. Unless somehow the server is gone or changed and then I load a frmFailure and they have to choose which server to use and reenter the connection settings manually.

Code:
Public Function Encrypt(secret As Variant, PassWord As Variant) As Variant
     '????
     'The passwords and privileges are encrypted with "1234567890"
     'the connection string is encrypted with "123456789"
     'Win98 had a problem with 1234567890
  
     ' secret = the string you wish to encrypt or decrypt.
     ' PassWord = the password with which to encrypt the string.
      On Error GoTo errhandler
     ' priv = Encrypt("A11111111111111111111", "1234567890")
    
    '' secret = "A11111111111111111111"
    ''  PassWord = "1234567890"
    
      L = Len(PassWord)
      For X = 1 To Len(secret)
         Char = Asc(Mid(PassWord, (X Mod L) - L * ((X Mod L) = 0), 1))
         Mid(secret, X, 1) = Chr(Asc(Mid(secret, X, 1)) Xor Char)
      Next
    
      Encrypt = secret
      Exit Function
errhandler:
    
      Err.Number = 0
      On Error GoTo errhandler2
    
      'like chinese unicode???
 
      L = Len(PassWord)
      For X = 1 To Len(secret)
         Char = AscW(Mid(PassWord, (X Mod L) - L * ((X Mod L) = 0), 1))
         Mid(secret, X, 1) = ChrW(AscW(Mid(secret, X, 1)) Xor Char)
      Next
    
      Encrypt = secret
      Exit Function
errhandler2:
    
      Encrypt = secret
    

End Function
 
Last edited:

My Computer

System One

  • OS
    windows 11
    Computer type
    PC/Desktop
    Manufacturer/Model
    some kind of old ASUS MB
    CPU
    old AMD B95
    Motherboard
    ASUS
    Memory
    8gb
    Hard Drives
    ssd WD 500 gb
And still after all this, I do not think today I would ever code a standalone type program. I would want to use internet type web pages and let the browser render all the pages. That way anyone using any OS in a browser could run the program. I did years ago write a small PHP app and setup a webserver and it worked, but was limited only to searches. No management features. Just like today here we are using the web to communicate things is so much better than having individual installs of apps to use a database

that would be like having to install a program on a computer just to interact with 11 forums.
 

My Computer

System One

  • OS
    windows 11
    Computer type
    PC/Desktop
    Manufacturer/Model
    some kind of old ASUS MB
    CPU
    old AMD B95
    Motherboard
    ASUS
    Memory
    8gb
    Hard Drives
    ssd WD 500 gb
@sdowney717

One of the reasons that you might be having such trouble with Windows Forms is that MS has reworked a lot of the controls to be 64 bit aware and that causes some differences in how they work.

I am using C# and I find that some of the controls in my older code no longer work, or the code has to be modified for the new controls to work properly. If they will even load at all.

Here is an article from MS that details the changes to Visual Studio in making it 64 bit. Pay special attention to the section on WinForms. It may help to illustrate why you are having some issues. I know it did for me.

 

My Computer

System One

  • OS
    Win 11 Pro 23H2
    Computer type
    PC/Desktop
    Manufacturer/Model
    Self build
    CPU
    Ryzen 5800X
    Motherboard
    Gigabyte x570 Aorus Elite Wifi
    Memory
    32 GB GSkill Trident Neo with pretty LED lights
    Graphics Card(s)
    ASUS TUF GAMING RTX 3070 Ti
    Sound Card
    On board Realtek
    Monitor(s) Displays
    2 x Samsung 32 inch curved - one 4K, one 1080p
    Screen Resolution
    4K, 1920 x 1080
    Hard Drives
    1 TB Samsung 980 Pro Nvme, 1 TB Samsung 970 EVO Nvme, 2 x Samsung 970 2TB SSD SATA
    PSU
    EVGA 1000Q
    Case
    Rosewill something or other
    Cooling
    Noctua NH-D15. A whole schwak of Noctua case fans. $$$
    Keyboard
    Logitech G815
    Mouse
    Logitech G502 Hero
    Internet Speed
    700 up, 600 down
    Browser
    Firefox
    Antivirus
    MalwareBytes
@sdowney717

One of the reasons that you might be having such trouble with Windows Forms is that MS has reworked a lot of the controls to be 64 bit aware and that causes some differences in how they work.

I am using C# and I find that some of the controls in my older code no longer work, or the code has to be modified for the new controls to work properly. If they will even load at all.

Here is an article from MS that details the changes to Visual Studio in making it 64 bit. Pay special attention to the section on WinForms. It may help to illustrate why you are having some issues. I know it did for me.

I noticed in VS2022, the program runs in 64bit mode. When debugging I can not change any of the code, have to stop. Change code, then restart.
I find that not so great.
Is there a way to let me change code in debug with program execution sitting at a breakpoint?

The program I imported from vb6 into VS2008, then upgraded into VS2022, which I where I am doing the debugging.
It is set for NET 4.8 and any CPU.


Reading that article, is it using 32 bit controls or 64 bit controls?
And how would you change to using NET 8.0?

If I had to redraw all the controls on forms, I wont bother, too much work.

See I am very new to VS anything, so about anything you tell me is ok with me.
 

My Computer

System One

  • OS
    windows 11
    Computer type
    PC/Desktop
    Manufacturer/Model
    some kind of old ASUS MB
    CPU
    old AMD B95
    Motherboard
    ASUS
    Memory
    8gb
    Hard Drives
    ssd WD 500 gb
I noticed in VS2022, the program runs in 64bit mode. When debugging I can not change any of the code, have to stop. Change code, then restart.
I find that not so great.
Is there a way to let me change code in debug with program execution sitting at a breakpoint?

The program I imported from vb6 into VS2008, then upgraded into VS2022, which I where I am doing the debugging.
It is set for NET 4.8 and any CPU.


Reading that article, is it using 32 bit controls or 64 bit controls?
And how would you change to using NET 8.0?

If I had to redraw all the controls on forms, I wont bother, too much work.

See I am very new to VS anything, so about anything you tell me is ok with me.
To my knowledge, you have to stop debugging to apply new code or make changes to the code. This is because the code has to be recompiled to incorporate the changes you have just made. That is normal Visual Studio behaviour.

If you are set to "Any CPU", VS will create code that runs on a 32 bit system as well as a 64 bit system. Your code will be bulkier (larger executable) and may be slower, but it should run on anything.

I believe that most of the UI controls available in VS 2022 are 64 bit, but I am not 100% certain. In your case, since you are porting over from VS 2008, you might run into the problem of some of your controls not working because they are 32 bit. Using "Any CPU" should help that problem.

You can change to .NET 8.0 by using the methods described here: Upgrade a .NET Framework WinForms app to .NET 8 - Windows Forms .NET

I should warn you that .NET 8.0 is rather... um... difficult? Complicated? Unforgiving? You will find that a lot of your old code will not work at all, without significant recoding. I just upgraded a project to .NET 8 and I had to spend a long time debugging my older code before it would work. I don't know about VB, but the C# implementation under .NET 8 is significantly different than under .NET 4.8.1. The languages have matured, and what you could get away with in earlier versions doesn't fly any more. If it were me, I would not upgrade your VB6 app to .NET 8 at this time. Get it working under .NET 4.8.1 and then upgrade it to .NET 8. It would be a two step process, but unless you have a compelling reason to go to .NET 8, like a special function or control, I would stick with 4.8.1 for the time being. You would just be adding unneeded complexity to your project.

I doubt you would have to redraw all the controls. Just re-place the ones on the form that don't work anymore. Maybe you'll get lucky and all of them will work for you the way they are. I hope so.
 

My Computer

System One

  • OS
    Win 11 Pro 23H2
    Computer type
    PC/Desktop
    Manufacturer/Model
    Self build
    CPU
    Ryzen 5800X
    Motherboard
    Gigabyte x570 Aorus Elite Wifi
    Memory
    32 GB GSkill Trident Neo with pretty LED lights
    Graphics Card(s)
    ASUS TUF GAMING RTX 3070 Ti
    Sound Card
    On board Realtek
    Monitor(s) Displays
    2 x Samsung 32 inch curved - one 4K, one 1080p
    Screen Resolution
    4K, 1920 x 1080
    Hard Drives
    1 TB Samsung 980 Pro Nvme, 1 TB Samsung 970 EVO Nvme, 2 x Samsung 970 2TB SSD SATA
    PSU
    EVGA 1000Q
    Case
    Rosewill something or other
    Cooling
    Noctua NH-D15. A whole schwak of Noctua case fans. $$$
    Keyboard
    Logitech G815
    Mouse
    Logitech G502 Hero
    Internet Speed
    700 up, 600 down
    Browser
    Firefox
    Antivirus
    MalwareBytes
To my knowledge, you have to stop debugging to apply new code or make changes to the code. This is because the code has to be recompiled to incorporate the changes you have just made. That is normal Visual Studio behaviour.

If you are set to "Any CPU", VS will create code that runs on a 32 bit system as well as a 64 bit system. Your code will be bulkier (larger executable) and may be slower, but it should run on anything.

I believe that most of the UI controls available in VS 2022 are 64 bit, but I am not 100% certain. In your case, since you are porting over from VS 2008, you might run into the problem of some of your controls not working because they are 32 bit. Using "Any CPU" should help that problem.

You can change to .NET 8.0 by using the methods described here: Upgrade a .NET Framework WinForms app to .NET 8 - Windows Forms .NET

I should warn you that .NET 8.0 is rather... um... difficult? Complicated? Unforgiving? You will find that a lot of your old code will not work at all, without significant recoding. I just upgraded a project to .NET 8 and I had to spend a long time debugging my older code before it would work. I don't know about VB, but the C# implementation under .NET 8 is significantly different than under .NET 4.8.1. The languages have matured, and what you could get away with in earlier versions doesn't fly any more. If it were me, I would not upgrade your VB6 app to .NET 8 at this time. Get it working under .NET 4.8.1 and then upgrade it to .NET 8. It would be a two step process, but unless you have a compelling reason to go to .NET 8, like a special function or control, I would stick with 4.8.1 for the time being. You would just be adding unneeded complexity to your project.

I doubt you would have to redraw all the controls. Just re-place the ones on the form that don't work anymore. Maybe you'll get lucky and all of them will work for you the way they are. I hope so.
So far only 2 controls dont upgrade, the slider and the imagelist as ASFAIK
None of the controls can be control arrays.

I agree then about not going from 4.8, if ever.

vs2022 does allow LEFT, RIGHT etc. Which helps me.
It is used as vb.Left, vb.right string functions.
 

My Computer

System One

  • OS
    windows 11
    Computer type
    PC/Desktop
    Manufacturer/Model
    some kind of old ASUS MB
    CPU
    old AMD B95
    Motherboard
    ASUS
    Memory
    8gb
    Hard Drives
    ssd WD 500 gb
So far only 2 controls dont upgrade, the slider and the imagelist as ASFAIK
None of the controls can be control arrays.

I agree then about not going from 4.8, if ever.

vs2022 does allow LEFT, RIGHT etc. Which helps me.
It is used as vb.Left, vb.right string functions.
There are probably equivalent controls to the Slider and the ImageList. They would just be a little different and have newer functions. There is a component that is called Trackbar that I think replaces the Slider, and I did find ImageList. They are part of the standard WinForms Toolbox in VS 2022. You might need to do some back end coding to get them to fit into your application as the methods of using them have probably changed a little, but you should be able to fit them in. Give them a try and see if you can make them work.

ImageList.jpg

Trackbar.jpg

I don't know how control arrays are implemented in VB, but in the Winform Toolbox there is a control called Panel. That allows you to group controls together. Is that what you are trying to do?

Yes, I would stay with 4.8.1 for now, until you get the hang of the nuances of the .NET development platform. .NET 8 is a huge jump from 4.8.1

I know that the string handling functions in C# are very powerful. I would expect the same thing in VB. And the nice thing about VS 2022 is that Intellisense is a lot smarter now than it used to be and it can suggest some pretty interesting methods for accomplishing things in code. There is also an AI component now, but I think it's only available in the Pro and Enterprise versions of VS.

Ain't coding fun? :p
 

My Computer

System One

  • OS
    Win 11 Pro 23H2
    Computer type
    PC/Desktop
    Manufacturer/Model
    Self build
    CPU
    Ryzen 5800X
    Motherboard
    Gigabyte x570 Aorus Elite Wifi
    Memory
    32 GB GSkill Trident Neo with pretty LED lights
    Graphics Card(s)
    ASUS TUF GAMING RTX 3070 Ti
    Sound Card
    On board Realtek
    Monitor(s) Displays
    2 x Samsung 32 inch curved - one 4K, one 1080p
    Screen Resolution
    4K, 1920 x 1080
    Hard Drives
    1 TB Samsung 980 Pro Nvme, 1 TB Samsung 970 EVO Nvme, 2 x Samsung 970 2TB SSD SATA
    PSU
    EVGA 1000Q
    Case
    Rosewill something or other
    Cooling
    Noctua NH-D15. A whole schwak of Noctua case fans. $$$
    Keyboard
    Logitech G815
    Mouse
    Logitech G502 Hero
    Internet Speed
    700 up, 600 down
    Browser
    Firefox
    Antivirus
    MalwareBytes

My Computers

System One System Two

  • OS
    Windows 11 Pro 23H2 [rev. 3447]
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC12WSHi7
    CPU
    12th Gen Intel Core i7-1260P, 2100 MHz
    Motherboard
    NUC12WSBi7
    Memory
    64 GB
    Graphics Card(s)
    Intel Iris Xe
    Sound Card
    built-in Realtek HD audio
    Monitor(s) Displays
    Dell U3219Q
    Screen Resolution
    3840x2160 @ 60Hz
    Hard Drives
    Samsung SSD 990 PRO 1TB
    Keyboard
    CODE 104-Key Mechanical Keyboard with Cherry MX Clears
  • Operating System
    Linux Mint 21.2 (Cinnamon)
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC8i5BEH
    CPU
    Intel Core i5-8259U CPU @ 2.30GHz
    Memory
    32 GB
    Graphics card(s)
    Iris Plus 655
    Keyboard
    CODE 104-Key Mechanical Keyboard - Cherry MX Clear
@sdowney717 Apologies if this has been posted before, but I found this....

Yes nice to read that. Don't know if I agree with only having to fix 5% of the code the converters generates, feels like more than that.
Out of 60 forms and 15 code modules, it created 3200 errors. I did nothing unusual in vb6. Feels more like I have to fix 10% of the code or more.

Having the converter though is a super great thing and it gives a framework rather than having to do everything new. Just a matter of translating from vb6 to vbnet. Would have hated to have to recreate all those form with controls.

One of the stupid things the converter does about VB6 mouse cursors is it adds Dim Cursors as Object to the head of all subs that does something with a vb6 mouse. And cant convert any mouse cursor lines from vb6 to vbnet like it does not know what mouse cursor =0 is, or any other thing to do with a mouse line in vb6, every single line had to be fixed by me.

It threw me in a loop for awhile as I was wondering why none of the vbnet mouse lines I learned how to make right worked until I removed that stupid DIM line it added.
 

My Computer

System One

  • OS
    windows 11
    Computer type
    PC/Desktop
    Manufacturer/Model
    some kind of old ASUS MB
    CPU
    old AMD B95
    Motherboard
    ASUS
    Memory
    8gb
    Hard Drives
    ssd WD 500 gb

Latest Support Threads

Back
Top Bottom