Closed sjsepan3 closed 1 year ago
@sjsepan3 I faced the same problem while I was trying the sVB Installer (not published yet). It happens when thee sVB is saved in the program files folder, where windows enforces more security rules. But if you move the sVB folder to your desktop or any other folder in your user account, it will work fine with no issues. Or you can move it away from your operating system's drive entirely to another desk partition. Note that I am facing other troubles with traditional SB code file, because they are temporarily saved in the temp folder, and my anti-virus gets suspicious about this action and blocks the app then restarts it! So, saving temp files causes troubles either way!
It happens when thee sVB is saved in the program files folder, where windows enforces more security rules.
OK, that makes sense. It gives me something to try out. I've written .Net apps that worked OK in Program Files, but I think the folders created under there were created staticly during install-time, and probably got permission somehow as I was running the installer. I wonder if there is some way for you to define a temp folder created in the project at install-time. But then I don't recall if creating files there is limited. Another possibility is to do those folders/files in the user's AppData/Local|Roaming folder. (I think that's what I ended up dong a lot of the time.)
@sjsepan3 Yes, the installer can create the unsaved folder even if it is empty, and I expect it will give it the same privileges. It is a good idea to try. Thanks. But the roaming folder will get agitate the antivirus as I explained above :D.
When I looked at the security permissions of the UnSaved folder in sVB file in the programs files folder, I found that it permits the user to only read and execute files. When I gave it the full control, sVB runs correctly. So, this is another solution, but it will not be easy for kids. Creating the folder with the installer will not solve this, because it creates the Toolbar folder with the same linited access. I will dig more to find a solution.
When I gave it the full control, sVB runs correctly. So, this is another solution, but it will not be easy for kids. Creating the folder with the installer will not solve this
Plus its probably not a good idea security-wise, which is why they made it so difficult to make changes.
What puzzles me is that the AV gets upset about AppData/Local|Roaming, as I always got the impression that was where changeable files were supposed to go after they locked down Program Files.
@sjsepan3
I reviewed the code. sVB already use a folder in the LocalApplicationData:
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) & "\SmallVisualBasic"
and the antivirus is OK with it. But temp sb code files are saved in the temporary folder System.IO.Path.GetTempFileName()
, and this is where the antivirus gets suspicious. Both are inherited from Small Basic.
I use the unsaved folder in the sVB\bin to save projects, and this makes troubles. So, you are absolutely right, I should save all types of files to the LocalApplicationData. I will notify you when I release sVB 2.8.1 with this fix and publish its installer on the VS marketplace.
Thanks.
@sjsepan3 Done: https://marketplace.visualstudio.com/items?itemName=ModernVBNET.sVBInstaller Thanks.
And 2.8.1 is working -- Thank You! :-)
I did discover an issue when running normally; although I can open an existing form, there are no controls in the toolbox unless I run as Admin.
Strange! The user has the read and list contents permissions and should use the toolbox folder normally! I will see what is happening,
But you can solve it manually by giving the user full control permissions for the ToolBox and Lib folders
Got it!
I use this code to read the file
IO.File.Open(xamlPath, IO.FileMode.Open)
This by default tries to open the file for read\write acess, but files in program files
are for read only, so it fails!
I modified it to:
IO.File.Open(xamlPath, IO.FileMode.Open, FileAccess.Read)
and it works!
I will update sVB to Vs.8.2 and publish the installer!
This program files thing is an agony!
Thanks.
I use this code to read the file
IO.File.Open(xamlPath, IO.FileMode.Open)
This by default tries to open the file for read\write acess, but files inprogram files
are for read only, so it fails! I modified it to:IO.File.Open(xamlPath, IO.FileMode.Open, FileAccess.Read)
and it works!
Ah, Yes. Good catch!
sVB 2.8.2 is ready!
And 2.8.2 did solve it! :-)
One minor thing I ought to mention, almost cosmetic, but a technical detail: I see in the control Panel Add/Remove Programs that both 2.8.1 and 2.8.2 list their installed version as 2.8.0 -- must be something in a manifest somewhere...
After app window opens, but before form controls appear, a message dialog is shown: "Small Visual Basic has stopped working".
Using the std-error redirect from user @progamateur in issue #4 ("sVB.exe 2>&1 | more") I get the following output in the console:
`Program Files\sVB 2.8\Bin?? took 43s ? sVB.exe 2>&1 | more Access to the path 'unsaved\23-05-13-09-20-20\Form1' is denied.
Unhandled Exception: System.UnauthorizedAccessException: Access to the path 'unsaved\23-05-13-09-20-20\Form1' is denied. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.Directory.InternalCreateDirectory(String fullPath, String path, Object dirSecurityObj, Boolean checkHost) at System.IO.Directory.InternalCreateDirectoryHelper(String path, Boolean checkHost) at Microsoft.SmallVisualBasic.MainWindow.SaveDesignInfo(TextDocument doc, Boolean openDoc, Boolean saveAs) at Microsoft.SmallVisualBasic.MainWindow._Lambda$__31-0() at System.Windows.Threading.DispatcherTimer.FireTick(Object unused) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler) at System.Windows.Threading.DispatcherOperation.InvokeImpl() at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state) at System.Windows.Threading.DispatcherOperation.Invoke() at System.Windows.Threading.Dispatcher.ProcessQueue() at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler) at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs) at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam) at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg) at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame) at System.Windows.Application.RunDispatcher(Object ignore) at System.Windows.Application.RunInternal(Window window) at Microsoft.SmallVisualBasic.App.Main()
Program Files\sVB 2.8\Bin?? took 16s ?`
According to message, issue appears to happen while trying to create a temporary folder for the form.
If I run the same command in a console started as admin, there is no error and the form design interface appears. If I close and run the first way (not admin) its back to the error.
I am running sVB 2.8 on Win7 SP1 w/ .Net 4.8 in VirtualBox 6.1.38_Ubuntu r153438, on Linux Mint 21.1 Cinnamon