Starting processes error in vb.net - vb.net

Sorry if this question is 'newbie'
So I have a code that opens some programs that were added to a listbox. These programs range from games to other applications I've made using VB.net to webpages.
I have a problem when I try to start some games. Say I have a button and the code is like this:
Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click
Dim sDirectory1 = "C:\Games\Company of Heroes 2 Master Collection\RelicCoH2.exe"
Process.Start(sDirectory1)
End Sub
The game is Company of Heroes 2, but it gives me the error 'Cannot find items file' outside of VB. And a few other games have similar errors too, but I can run them myself by directly starting the .exe. Do some programs need more permissions? I've tried running as admin to no avail. Over applications will work, such as applications I've made myself and games with launchers. Thanks.

Related

VB Forms don't recognize each other in the same project

Hi everyone I need some help,
I am having a weird situation every time I try to call a window form I get this error
BC30469 Reference to a non-shared member requires an object reference.
I was originally working on Visual Studio 2010 when the first time contouring this problem so I thought that I may accidentally deleted or edited some code in the declaration of the form witch caused the problem so I closed the solution and created a new one to make sure that the problem is limited the solution not to VS. then I add window form "Form2" then created/added a button1 on Form1 to call Form2.Show()
simple code that should work fine but when I tape Form2.Show() it give that ERROR and red mark Form2
so I uninstalled VS2010 then Reset Windows 10 with option to wipe out all data on windows partition (I now that was extreme but I suspected that maybe the system was infected with some virus "prior action") so after that I checked the system with HitmanPro and found nothing then I installed VS2019 Community and get The some problem I searched on the web but did not found any similar case so here I am hoping that someone will resolve the mystery.
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Form2.Show()
End Sub
End Class
Form2 is empty form I didn't make any change on it
Before this problem showing up everything work fine now even old project have the same issue
Thanks
Edit: Add project as simple
https://mega.nz/file/FgoXkCwA#ootxYrXGnR6sQR_Pifjvz617-r_Az1ozXWB49oGxqKU
the project dose not contain any executable file
I usually do something like this when calling a subform:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
' using a Using block:
Using form2 as New Form2
form2.ShowDialog(Me)
form2.Close()
End Using
' using a With block
With New Form2
.ShowDialog(Me)
.Close()
End With
End Sub
ShowDialog(Me) keeps the subform open until a DialogResult is provided by the user (OK or Cancel usually).

Closing main form doesn't finish process (only some computers)

The problem is happening on 2 of the company's computers and on a client computer, but we can not identify a pattern.
I was able to reproduce the error using a simple program that only opens an OpenFileDialog. The program must be run by the generated executable itself (NOT by Debug) and it is still running in the background even after closing. Below is the code of the program, along with a link to download the project and a video demonstrating the error.
Code:
Public Class Form1
Private ofdAbrir As Windows.Forms.OpenFileDialog
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ofdAbrir = New Windows.Forms.OpenFileDialog
ofdAbrir.ShowDialog()
ofdAbrir.Dispose()
ofdAbrir = Nothing
End Sub
End Class
As you can see in the code above, I only have one form, so it is not the case that some form remains open and it is also not related to threads running since none is created.
To reproduce the problem, click on Button1, cancel the OpenFileDialog and try to close the form (clicking on X). The form apparently will close, but you will see at task manager that it still running. The big mystery is that this problem does not happens in all computers.
Video: https://drive.google.com/open?id=1sfdVUGQlwYNCQkl1Ht-cJSOb4433sqnT
Project: https://drive.google.com/open?id=1d4oJYUjaaZ9xnRj4CX3HXOQPqwMZmE0V
I couldn't reproduce the problem, but how about using this method:
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Using ofdAbrir As New Windows.Forms.OpenFileDialog
ofdAbrir.ShowDialog()
MsgBox(ofdAbrir.FileName)
End Using
End Sub
I've seen the video u posted...It is not your application that is running rather it is the vsHost.exe that is running :)...The problem shouldn't occur if u run the app outside visual studio.
If the problem is still there,just disable Enable Diagnostic Tools while debugging from Tools > Options > Debugging > Uncheck Enable Diagnostic Tools while debugging
Also u can disable Visual Studio hosting service from Project > Project Properties > Uncheck Enable the Visual Studio hosting service

Disconnecting iTunes COM

I'm currently working with the iTunes COM with .NET, and something I came across previously, which stopped me using it, has happened again and I can't for the life of me figure it out.
When I go to close iTunes during or after my program has closed, it tells me something is still using the "Application Scripting Interface", COM is still connected.
This is what I have (removed what is not required)
Private Sub frmMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
AddHandler itunes.OnAboutToPromptUserToQuitEvent, AddressOf itunes_OnAboutToPromptUserToQuitEvent
End Sub
Private Sub itunes_OnAboutToPromptUserToQuitEvent()
System.Runtime.InteropServices.Marshal.ReleaseComObject(itunes)
End Sub
So, the above code does disconnect the COM to the extent that I need to restart iTunes to use it again, but, it doesn't get rid of the Application Scripting error. Meaning, I still need to click quit after the error dialog comes up. Everything else works fine, apart from this.
Any idea?
-- I've had a look at other questions that had this issue, but none of them resolved it for me. I'm not sure if the event doesn't work anymore with this current version of iTunes, but, it doesn't seem to work currently either way.
Had same issue with COM and Office, this solved it;
While System.Runtime.InteropServices.Marshal.ReleaseComObject(itunes) <> 0
Application.DoEvents()
End While

How to detect a collision in a Windows Store apps?

This is my first question on Stack Overflow's possible that I'll make mistakes. (and I use a internet translator)
I do not know how to detect collision in Windows Store apps. On Windows Forms it looks like this:
If Player.Bounds.IntersectsWith (Enemy1.Bounds) Then
'do something
End If
Please give me function that returns a boolean. Thank you for all the answers.
You can give me c# code i will convert it!
This is just a function with a boolean value as result. You can try this with two simple controls, with buttons for example.
You can create a new project, add two buttons and put them away, then launch the window app, then overlap them and relaunch the app.
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
If Button1.Bounds.IntersectsWith(Button2.Bounds) Then 'this return true/false
MsgBox("Collision detected")
End If
end sub

Getting Current Song Data From Windows Media Player 12

I have been searching all over for an answer to this, and I'm figuring there is no way to do it, but I thought I'd ask.
I'm looking to make a VB.net app that gets and displays the artist and title of a song playing in Windows Media Player. I'm not looking to embed the player in my app, just pull data from the already existing window.
Most of the stuff I find on how to do this is old or related to embedding WMP. I'm looking to do it in with MWP12. I've also seen references to using AxWindowsMediaPlayer.currentMedia Property, but that doesn't seem to work anymore. I used to be able to pull the data from the Registry, but it seems Microsoft took that away.
I've tried sooooo much other code, but this is currently what I have. I'm at my wits end.
Imports WMPLib
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim wmp As WindowsMediaPlayer = New WindowsMediaPlayer
Dim playlist As IWMPPlaylist = wmp.currentMedia.???????(????).Item(?)
Label1.Text = playlist.getItemInfo("Title")
End Sub
End Class
No idea where to go here, but thanks for any help.