|
Oh may be my english is not good enough so you still confuse about the code sample. You don't need to understanding what I doing in the code statement. Just look at that then you will see the try-catch block cover all code that I use ffmpeg lib to do. My question is: when exception from ffmpeg raised, why it let my application scrash instead of jump to catch statement.
|
|
|
|
|
WOW! You did a really bad thing by what appears to be creating your entire application in a single method. That's some real spaghetti code and is probably the source of your problem. The first thing you need to fix is the indentation. It's impossible for you, or anyone else, to follow that code because you have no idea what lines below to which if or using statements.
You REALLY need to scrap this code and rethink it. Methods should do ONE thing and one thing only. Break your work flow down into smaller and smaller chunks until you get each chunk down to doing one thing. Then you can write code for methods to do those one things.
|
|
|
|
|
Dave Kreskowiak wrote: Then you can write code for methods to do those one things. And possibly even test them. 
|
|
|
|
|
Oh may be my english is not good enough so you still confuse about the code sample. You don't need to understanding what I doing in the code statement. Just look at that then you will see the try-catch block cover all code that I use ffmpeg lib to do. My question is: when exception from ffmpeg raised, why it let my application scrash instead of jump to catch statement.
|
|
|
|
|
Your English is fine, it is your code that is the problem. Look at these catch blocks:
catch (AccessViolationException ex)
{
Console.WriteLine(ex.ToString());
}
catch
{
}
So all of those exceptions are just ignored and your program continues on, until it tries to do something that causes it to crash.
|
|
|
|
|
That is the problem. I write catch block to catch all exception raised from the main code but it cannot catch exception from FFMediaToolkit. My app is crashed and show below exception on debuger:
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at FFMediaToolkit.Decoding.Internal.InputContainer.ReadPacket() in C:\projects\ffmediatoolkit\FFMediaToolkit\Decoding\Internal\InputContainer.cs:line 174
at FFMediaToolkit.Decoding.Internal.InputContainer.GetPacketFromStream(Int32 streamIndex) in C:\projects\ffmediatoolkit\FFMediaToolkit\Decoding\Internal\InputContainer.cs:line 90
at FFMediaToolkit.Decoding.Internal.Decoder.DecodePacket() in
....
Atfter that, I try to add block "catch (AccessViolationException ex)" but no luck. I'm thinking about something that I need to add to my code to catch native (or unmanage exception) but I don't have any idea about it.
|
|
|
|
|
I just think about one more case: FFMediaToolkit call ffmpeg lib and it create a new thread to process may task (extract frame, encode video.. etc) and when exception occur, my app canot catch the exeption in my way because it raised from difference thread.
|
|
|
|
|
As I already told you, you are ignoring the exceptions in your catch blocks, so you cannot expect your program to work without problems. You must handle the exception; at the very least display a message. Until you do that you cannot be certain what is happening in your code.
|
|
|
|
|
Thanks for your guide. I summary something about my problem:
My code statement like below:
try
{
}
catch
{
}
My main code can raise exception at anytime depend on bad situation (bad code, bad input video file,..etc) and we don't care about why it raise the excption in main code block, and whatever reason, it must be jump to catch statement when exception raise. But it didn't jump in catch block, in fact. I'm sure about, because I've ever take break point, add debug print exception, and some otherway. So at this time, I'm thinking about the reason come from the way ffmpeg process video. It run on other thread so when exception is raised, it does not go to catch block.
|
|
|
|
|
Since your catch block has no code you have no idea what happens, and no way to find out.
|
|
|
|
|
Oh may be my english is not good enough so you still confuse about the code sample. You don't need to understanding what I doing in the code statement, I get some statements that use ffmpeg lib. Just look at that then you will see the try-catch block cover all code that I use ffmpeg lib to do. My question is: when exception from ffmpeg raised, why it let my application scrash instead of jump to catch statement.
|
|
|
|
|
I understood the English.
You're not understanding the problem. It's not with the library or the system. It's your code.
You ARE catching the exceptions. The problem is you're not handling them correctly. Your error handling is so bad that you handle the exception in one place, and don't fix anything, letting the code continue on using bad data and causing another problem further down the line.
Your bigger problem is that nobody is going to go through that pile of garbage code to tell you "oh, just do this little thing and you'll be good". There is no fixing that code because it's so poorly written. This is a scrap it and rewrite fix.
You REALLY need to break your problem down into smaller and smaller parts so you can write methods that do one thing and one thing only.
|
|
|
|
|
I'm not sure why this is giving me an issue, I am not very in depth in c#.
Uri webAddress = new Uri("http://" + textBox1.Text);
WebRequest request = WebRequest.Create(webAddress);
webrequest is having issue CS1929, "button does not contain a definition for 'create' and the best extension method overload 'FileSystemAcIExtensions.Create(DirectoryInfo, DirectorySecurity)' requires a receiver of type 'DirectoryInfo'"
|
|
|
|
|
From those lines we can't be certain, but ... I'd say that the most likely reason is that you have a Button on your form called WebRequest, and it's being searched for the Create method, which a Button will not have.
If so, there are two ways to fix it:
1) Change the name of the Button.
2) Use a fully qualified name for WebRequest:
System.Net.WebRequest request = System.Net.WebRequest.Create(webAddress);
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
the button name was exactly the problem, thank you so much.
|
|
|
|
|
You're welcome!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I have a Metter Toledo PS60 Tilt, i have not drive, in fact, i can not find it anywhere.
I need to read and display the Weight using c#.
I have any codes and nothing happen.
Any helpds
|
|
|
|
|
Have you looked at the code in this repository[^]? This seems as though it could be a starting point.
|
|
|
|
|
Excellent,
Thanks: It is working
|
|
|
|
|
You should talk to the people who created it - Metter Toledo[^] - they should provide technical support and will know more about their product than we will. If they don't, then find another supplier and demand your money back!
The link gives you the technical manual to download and read, plus a link to their support service.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
There may not be a driver for it if the scale exposes itself as a serial device. Look in Device Manager for it and see if it has a COM port associated with it.
|
|
|
|
|
Currently, I am having difficulty in opening firefox browser in mobile emulation mode in selenium c# with MS Test , can someone please help me in that?
Fifrefox code
private static IWebDriver GetFireFoxDriver(string userAgent)
{
var rand = new Random();
var firefox_options = new FirefoxOptions();
firefox_options.AddArgument("-private");
firefox_options.AddArguments("--window-size=1024,768");
firefox_options.AddArguments("--window-position=0,0");
firefox_options.AddArgument($"--user-agent= {userAgent}");
firefox_options.AddArgument("--disable-backgrounding-occluded-windows");
var driver = new FirefoxDriver("C:\\selenium\\firefoxdriver", firefox_options, TimeSpan.FromMinutes(3));
if (userAgent.Contains("Mobile") == true)
{
driver.Manage().Window.Size = new Size(411, 731);
}
return driver;
}
I have done in Chrome Browser - Mobile Emulation
private static IWebDriver GetChromeDriver(string userAgent)
{
var options = new ChromeOptions();
options.AddArgument("incognito");
options.AddArguments("disable-infobars");
options.AddArguments("--window-size=1024,768");
options.AddArguments("--window-position=0,0");
options.AddArgument($"--user-agent= {userAgent}");
if (userAgent.Contains("Mobile") == true)
{
var settings = new ChromeMobileEmulationDeviceSettings(userAgent)
{
Height = 731,
Width = 411,
PixelRatio = 2.6
};
options.EnableMobileEmulation(settings);
}
options.AddArgument("--disable-backgrounding-occluded-windows");
ChromeDriverService service = ChromeDriverService.CreateDefaultService();
service.SuppressInitialDiagnosticInformation = true;
var driver = new ChromeDriver(service, options, TimeSpan.FromMinutes(3));
return driver;
}
|
|
|
|
|
|
Hi,
I have a web service developed in C# running over Windows 2012 server. This service receives data and connects to destination server for processing. When it establishes connection with remote server it uses only 20 fixed Source Ports. Every new connection is initialized with one of those 20 fixed Source ports. Problem happens when it uses the last source port. Web service can't use the first port again without restarting application pool. I do not see source ports in TIME_WAIT state as well. Strangely web service starts working again after pool re-start but then works until the 20th port only . I know we should have dynamic source ports but there is requirement to setup source ports only given 20 port numbers.
I think code is not doing socket close /cleanup properly and thereby not letting me use the same port again without restarting the pool. Can somebody please help me in any direction where should I check?
|
|
|
|
|
I want to collapse or expand all TreeView nodes under parent node if user holds down Left Control key and presses left mouse button on expansion arrow of tree view.
How do you do this in WPF? It's not as obvious as it was in WinForms.
|
|
|
|