I am coding a c# command line application (WIN7, 64bit) that should write many lines to the command line.
I cooked the problem down to the following code:
int lineno;
for (lineno = 0; lineno < 100000; lineno++) {
Console.WriteLine(">" + lineno);
}
I can't understand why the apllication dies after 39404 lines:
...
>39401
>39402
>39403
>39404
"Console Application has stopped working."
Please let me know if you have any ideas what went wrong here.
Thank you & best regards, Dirk.
I doubt your question. Because my program works fine and shows till 99999 under MS Visual Studio 2008.
EDIT : After Dirk commented on Davido's answer, with Console.WriteLine(">>>" + lineno); the output prints many 36251 times. But that's incorrect. With ">>>" also, program accurately works.
Here's image for same.
I couldn't reproduce the problem--it seems the problem is environment.
Does it always fail at 39404? Does it fail after a certain period of time? How do you launch it? Have you tried launching it from command line? Are you sure this is all code that you have? Have you tried building it with different configurations?
Answering these questions, you might find what causes the problem.
Edit: the oddest thing I see about it is this message:
"Console Application has stopped working."
It's obviously not system or framework message.
Please post complete code because it looks like you're doing something wrong.
Works fine on my system. (Windows 7, VS 2010).
What Operating System and Framework version are you using?
Try changing your application target to compile for x86. Sometimes this solves strange issues I have with different projects.
Edit:
Dirk, try making a NEW project and putting your code in a blank console project. See if that changes how it outputs. I suspect that doing this will change the number of lines you are able to write. If so, then there is a problem with some of your other code that you haven't posted. Just something you might want to consider.
Related
I am new to Visual Studio / Test Complete / C#. I have written a Test Complete test in C#, but when I try to run it it says "Cannot Create Test Complete Object". The only question so far that I have found does not apply to me. Even if it did, I did, as it suggested, run the program as admin but the same problem.
This is nowhere near enough information for you to go on, so let me continue.
My Test Complete test extends a class "AbstractTestCase" that we got from our team. This is the base class that has been used for years, so I am sure it is OK. I made a simple test, just to try to click an object. I have no idea whether the values are correct, but for now it does not matter, as my test is throwing an exception in the "Before()" method, so it has not gotten there yet.
The exception is being thrown at this method, which I believe is Smart Bear method, so I cannot debug into it, and it shows no line number:
Connect.RunTest(GetTestName(), "Generic", Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + #"\Automation\TcFramwork\TcFramwork.pjs");
The values are as follows:
GetTestName() = "RepriceTest"
Path.GetDirectoryName... = "C:\VS_Projects\ErepricerSolution\ErepriceClassLibrary\bin\Debug\Automation\TcFramwork\TcFramwork.pjs"
I do have a file C:\VS_Projects\ErepricerSolution\ErepriceClassLibrary\bin\Debug\Automation\TcFramwork\TcFramwork.pjs
which looks like this (along with a "Generic" subdirectory). Please see attached file. To attach it I had to convert it to an XML file.
The only difference is this. Because my Desktop started crashing, I was one of the first (and only so far) people to get a laptop. Others will be getting themn as time goes on. The laptop has Windows 10, while everyone else has Windows 7. The Laptop has Test Complete 12. The laptop had Visual Studio 2015, but due to compiler incompatibilities with Smart Bear Connetc, I had to have Visual Studio 12 installed, which I am using.
So others are using Windows 7, Visual Studio 12 and Test complete 12, while I am using Windows 10, Visual Studio 12 and Test Complete 12.
I do see somewhat of a backtrace from this Connect.RunTest(), so maybe someone can figure out what's going on. Please see attached file trace.png.
I am also attaching a copy of my test class. (And again I have no idea whether the Connect statement is right, but it never gets that far)
I can't upload files but I did share them on my google drive.
PJS file: https://drive.google.com/open?id=1FZ2__0smKTKZ8d6mqVxIO8gP4r_A-92y
Test Class: https://drive.google.com/open?id=1ixitvZ45M11Va1eDv-7Vv9Lz9WHh-k41
Stack Trace: https://drive.google.com/open?id=1C57iNacRnrmmGkE4Lx9mvetobPiJN3G4
PSJ File: https://drive.google.com/open?id=1FZ2__0smKTKZ8d6mqVxIO8gP4r_A-92y
I working on a pdf generator with NRec PdfGenerator and it works fine at the start when I working with local, once I package up and deploy to server it fail and show the error message
Cannot generate PDF: (exit code: -1073741521) ---> NReco.PdfGenerator.WkHtmlToPdfException: (exit code: -1073741521)
I not sure whats causing it and I believe is not related to the code itself, and I could find any related post or article that about the exit code shown.
Is there anyway to fix this error?
Any advice to this will be appreciated. Thanks.
As Vitaliy Fedorchenko commented, the problem, in the compatible operating systems, can be solved by installing the missing required Universal C runtime libs ( https://support.microsoft.com/en-us/help/2999226/update-for-universal-c-runtime-in-windows ).
First question on here and I am feeling pretty stumped, I've searched around but couldn't find something that I could apply to my situations, any help or direction to a prior question would be appreciated.
I'm receiving an error when trying to create some new files from my form. I'm following a guide at XNA Game Programming Academy (xnagpa_net/xna4rpg_php), I'm up to step 14 but I believe this started happening earlier and I hadn't noticed it yet.
Screenshot of Error
Please have a look at the above error and give me any tips.
My code for RpgEditor.FormMain.cs is here, it says something about line 128 which relates to;
if (Directory.Exists(gamePath))
throw new Exception("Selected directory already exists.");
I'm not sure why though, because I'm creating a brand new folder/directory when I am attempting to save the data.
If it helps, the subdirectories are being created by the process but I recieve that error and no files inside.
edit: I've downloaded the example project on his site and it's working fine with that, so I don't believe it's an issue with my system configuration.. must be a project setting or line of code somewhere..
To fix this I had to change the configuration settings.
It was set to AnyCPU but I had to change to x86.
The setting wasn't there originally, I had to create new and copy settings from AnyCPU.
Why this works I don't know, but it does :)
I see a strange issue(Most likely my code is not complete), can some one take a look and help me out why following code runs fine but no changes are happening. Whn I go and take a look at identity tab, nothing has changed. OS is windows 2008 server r2
COMAdminCatalog cc = new COMAdminCatalog);
COMAdminCatalogCollection ccc = (COMAdminCatalogCollection)cc.GetCollection("Applications");
ccc.Populate();
foreach(COMAdminCatalogObject cap in ccc){
if(cap.Name.ToString() == config.Application){
//cap.set_value("Authentication",COMAdminAuthenticationLevelOptions.COMAdminAuthenticationConnect)//I have changed all options here but no effect
cap.set_Value("Identity", config.user);
cap.set_Value("Password", config.password);
ccc.SaveChanges();//breakpoint here
}
}
It turned out that ccc.SaveChanges() returns an error code =1 does any one know what it means?
MS documentation says error codes returned are in hex values such as 0x800401 etc(just made up)
I did this myself (learn something new every day!) and this is my results, hopefully we can figure out your problem:
I created a new COM+ server Application and copied your code (with minor changes so it finds my app, because I don't know what config is in your example :)
From debugging up to ccc.SaveChanges() - this line should throw exceptions if something went wrong. In my case, I got an UnauthorizedAccessException - I fixed that by running my code in Visual Studio as administrator
Once I did that, ccc.SaveChanges() worked - I went to my Identity tab and it updated the user and password correctly (if you enter a wrong username or password in the code, it also throws an exception I believe).
The return type you are getting, the 1, isn't an error code I believe. Because that's what mine returns and it is working fine.
You could try surrounding your ccc.SaveChanges() in a try catch and see if any exceptions are thrown.
I hope this helps.
First of all THANK YOU ryrich for taking time to help me out. What it turned out to be the reason for which my changes were not shown is as dumb as it possibly can be. It is consistent on 3 machines where I tested it. Here is what I noticed.
Every time I run the code above, it did work as there were no errors, but I could not see the changes in Component Services Console, the messed up part is that I HAD to close the Component Services console completely, then restart it and only then I could see the changes.
This behavior was consistent on all three systems where I tested it.
1: WinXP sp3
2: Win 7 SP1
3: Win 2008 Server R2
I am explaining this so just in case some one else might see this STUPID behavior...
I have a command-line utility that gets quite a bit of downloads from my site. I'm trying to show the usage when a user uses the /? or /help parameters. I have a function called ShowUsage() that has nicely formatted text on the parameters available.
I see that ShowUsage() gets called fine from Visual Studio 2008, when I'm using the command-line parameters in the project properties. However the exe does not display the help text when run from the command-line. Here's a shortened version of ShowUsage():
private static void ShowUsage()
{
Console.WriteLine(Environment.NewLine);
Console.WriteLine("Text File Splitter v1.4.1 released: December 14, 2008");
Console.WriteLine("Copyright (C) 2007-2008 Hector Sosa, Jr");
Console.WriteLine("http://www.systemwidgets.com");
Console.WriteLine("");
}
I tried a bunch of different things from my searches in Google, but none are working. I know this has to be something simple/easy, but for the life of me, I can't figure this one out.
EDIT:
The code that calls ShowUsage():
if (!Equals(cmdargs["help"], null) || !Equals(cmdargs["?"], null))
{
ShowUsage();
}
I have a class that parses the parameters into the cmdargs array. I confirmed that the parameters are in the array. It's something inside ShowUsage() that is preventing from showing the text.
I'm going to try the debug trick, and see what I find.
I'm not using Console.Out anywhere.
d03boy - Just personal preference. It makes the text less cluttered onscreen, at least to me.
EDIT #2
Ok, some more information... I'm running VS2008 in Vista Ultimate 64 bit. I just check the project properties and it is set to "Windows Application." This utility is 32 bit.
I'm going to experiment with creating a separate project in the solution that is a true console program, as some of you have advised.
Can you define "not working"? Simply not doing anything? Throwing an exception? I would expect the problem to be in the Main(...) method - i.e. ShowUsage() isn't being called. Another common issue is not rebuilding it in the correct configuration, so bin/release (or whatever) isn't updated.
Have you built the app as a console exe? i.e. is the "Output Type" = "Console Application" in project properties? It needs to be in order to access the console...
For info, I find the easiest way to do a console help screen (once it gets beyond a handful of lines) is to embed a .txt file into the exe; then I just write out the text file (perhaps still using string.Format if I want to replace tokes).
Alternatively, there is the alternative string format:
Console.WriteLine(#"
Text File Splitter v1.4.1 released: December 14, 2008
Copyright (C) 2007-2008 Hector Sosa, Jr
http://www.systemwidgets.com
");
Are you redirecting Console.Out to somewhere else?
Try throwing a System.Diagnostics.Debugger.Launch() in the ShowUsage method so you can see if it's getting hit at runtime.
Can you reproduce the issue with a simple exe, only accepting those help parameters?