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
Related
I have a situation where I need to debug a process that runs at a future date. This is existing legacy code that uses DateTime.Now (C#) & GETUTCDATE() (T-SQL) within its code in several places. We're having to change the date & time on Windows 10 to test how the code behaves with future dates.
We've tried preventing internet access but the application uses 3rd Party API's which require Internet access. We normally get about 1 hour of debugging time before Visual Studio 2019 checks for a stale license.
The big problem is that we're running into license issues with Visual Studio 2019 in the middle of debugging. We get booted out and have to start over. The process is lengthy and normally takes about an hour to get to a debugging position.
Does anyone know of a switch or command line parameter to temporarily allow us to modify the system date without shutting down Visual Studio 2019 due to stale license? Or any techniques that anyone has tried to debug.
Thank you in advance for your help.
This is too much for a comment.
What you could try is to install a useful debugging tool called Fiddler.
With Fiddler running, monitor your http traffic when Visual Studio is running to see which addresses it is contacting and communicating with. You should see something like this in Fidder's Inspectors tab
Once you've identified or suspect what it's doing, open your Windows host file (usually C:\Windows\System32\drivers\etc\hosts) in Notepad and add entries for each URL, eg
0.0.0.0 dc.services.visuastudio.com
to temporarily block it connecting to that particular site.
Remove, or comment out, when done.
You say it's legacy code, but hopefully you can change it.
One option would be to substitute all uses of DateTime.Now with DateTimeEx.Now, and add a class like:
public static class DateTimeEx
{
public static TimeSpan Offset { get; set; }
public static DateTime Now => DateTime.Now + Offset;
}
You can set the Offset to whatever value you like for testing purposes.
Using PCLStorage in Xamarin Forms I can create a local folder and store images downloaded from Azure.
I can then successfully test to see of the images exists using
ExistenceCheckResult fileExist = await MyFolder.CheckExistsAsync(fileName);
However, once the app has been stopped (by stopping debugging in Visual Studio) and restarted, if I run the test code above, it fails and tells me the images do not exist.
Do files then only exist for the time the app is running?
This thread looks like it could possibly cover what you are experiencing:
https://forums.xamarin.com/discussion/87498/i-am-using-pclstorage-where-are-the-files-going-to
Reading up on this, the file persistence side of things looks like debugging should not affect it, as once it writes the file - then it's in the specified location.
Also - looking at PCLStorage and the last time it was modified, if this is a new addition to your project, I can't say I would recommend it, as it looks like it is no longer being worked on, and hasn't been for some time.
I would go with an implementation from System.IO as it is now supported within .net standard 2.0 - and there appear to be lots of great examples for you to follow.
If this doesn't help, then post some more of your source code so that it can be looked into in further detail.
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've got a commandline C# program that compiles and runs fine using Visual C# 2010 and Windows 7. It also compiles and starts fine on Linux/Mono (2.10), but then sits there. (The program is using a 3rd party DLL to fetch data from a remote server.)
Running it in the debugger, I saw it seemed to be waiting for a DNS lookup. So I did the DNS lookup for it, pasted in the IP address. But it still hangs, and breaking into the debugger shows three threads all sitting there waiting:
System.Threading.Monitor.Wait (timeout set to -1)
System.Threading.Thread.Sleep
System.Threading.WaitHandle.WaitOne
I used MoMA to analyze the DLL. I'm not sure how accurate that is, because it matches against Mono 2.8, and I'm using 2.10.8.1, but it says Socket.Dispose() is a missing method. Then 32 [MonoTodo] items, 30 of which are Type.op_Equality or Type.op_Inequality. The other two are CredentialCache.get_DefaultCredentials() and MemoryMappedFile.CreateOrOpen().
But what got my attention was, at the bottom of the report, there are two entries for GetWindowsSocksProxy, which turns into SingleServerConnection.InternetQueryOption, and the P/Invoke library is wininet.dll. Could this be related?
So, is there anything I can do? E.g. can I copy that DLL from a windows machine to my linux machine? If so, where do I put it?
P.S. I wondered about connectivity issues. So I made a quick test Mono using WebClient, which worked fine. But one interesting difference is the non-working script loads "/usr/lib/mono/gac/Mono.Posix/4.0.0.0__0738eb9f132ed756/Mono.Posix.dll [External]" at the point where it first needs to connect to something. But my WebClient never did that.
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?