I'm quite desperate because my C# Application won't start if I open it remotely with the PowerShell.
My application is doing some hardware access and grabs a camera picture. If I open this .exe over the VS Remote Debugger it works fine. If I open it with TeamViewer directly on the remote client, it works well.
But if I try to open my application over the PowerShell, it crashes during a bitmap operation
Bitmap newBmp = new Bitmap(ROI[2] - ROI[0], ROI[3] - ROI[1], source.PixelFormat);
with the error "Parameter is not valid!".
The values that are beeing passed are:
new Bitmap(2544 - 1, 1944 - 3, Format24bppRgb)
Why is the exe behaving completely different even though the PS doesn't anything different than simply starting a new instance of the application?
Here is how I open the executable:
PS Z:\> invoke-command -ScriptBlock { & 'C:\Users\###\Documents\Visual Studio 2015\Projects\###\Commo
n\Remote Console\bin\Debug\Remote Console.exe' -save_path=C:\Temp\Images fov=large filename=test1 setposition=200.00 Ope
ration=getpicture } -Session $remotesession
Here's stack trace:
Sure (sorry for having forgotten):
Parameter is not valid. System.Drawing at System.Drawing.Bitmap..ctor(Int32 width, Int32 height, PixelFormat format) at Utility.ImageProcessing.CopyBitmap(Bitmap source, Int32[] ROI) in C:\Users###\Documents\Visual Studio 2015 \Projects###\Common\Utility\Utility.cs:line 46 at Utility.###ServiceUtilities.ByteToImage(Int32 width, Int32 height, Byte[] imageData) in C:\Users###\Doc uments\Visual Studio 2015\Projects###Interface\Common\Utility###ServiceUtilities.cs:line 232 at Utility.###ServiceUtilities.getImage(ImageServerClient client, cameraSelect Cam, FieldType FT, Int32 WaitTime) in C:\Users###\Documents\Visual Studio 2015\Projects###Interface\Common\Utility###ServiceUtilities.cs: line 61
What the heck is going on?! ~.~
UPDATE: I found sth interesting. Any creation of a new bitmap will fail if its bigger than a defined size around 500*500*24bpp. May this be caused by some memory overflow? On the remote PC is still enough ram free (5,7Gb)!