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.
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
Please, have patience if this question is long but I have never worked on this complex program which was developed by colleague of mine before I was recruited.
We have this web application running on .NET Framework v2.0 CLR. Anyway, this program is not natively written in C# but we must use a framework called Instant Developer which converts the code in a .NET application. The application runs in a Windows Server 2012 R2 under IIS 8 and with SQL Server 2014.
So, inside this application there is a very big directory called "photos" which contains a photo of each work a user completes. When the program was developed, our customer told us that very few photos were compulsory so my colleague thought that a unique directory was enough. But in this years the requirements have changed. Therefore, now a photo must be take for each work and so that directory today contains more than 5 millions of files. Consequently, it is not openable anymore by Windows Explorer, if I try the server blocks. Last month, our server was attacked by a crypto locker and my bosses decided to pay in order to get a decrypter otherwise our customer will ask us to pay a fine for each file which was lost. As soon as we have finished to recover our files, my boss asked to divide this huge directory into sub directories like /year/month/day. This can be easily done by a python script but the problem is that our customer registered in SAP a link to see that photo of this form
https://www.ourserver.it/applicationName/photo/file.jpg
and they told us they will refuse to change it.
So, I would like to change the path of the photo in the database and, somehow, give instructions to IIS 8 in order that when it receives a URL like the previous, it should query the database, discover the new path and then redirect the client to a new URL like:
https://www.ourserver.it/applicationName/photo/year/month/day/file.jpg
This event is not catchable by the framework we use, that's why I need to program IIS in this way.
How can I achieve this? I don't care if I have to write code, not a problem. But if this could be done reasonably without going mad I would really appreciate your help.
I'd like to release some updates for a WinForm program, but to date I have simply released an all-new compile. People have to un-install the old version and install the new version.
EDIT: I'm using an auto-generated InstalWizard. It preserves my file strucutre and places the [PrimaryProgramOutput] in a particular directory. I forget what this is called.
I bet there's a way to get around this, but I don't know what it's called. As you may guess, searches for "updates" "new version" "install" and the other obvious things I've tried have generated an impressive number of irrelevant results. >_<
I suspect this process has a particular name, which should point me in the right direction, but if it doesn't please link to a tutorial or something.
I see from the tags you are using C#. Visual Studio can create Setup projects for these kind of tasks. The setup projects als contain a property RemovePreviousVersion, which will remove a previous version if the versioning of your setup is correct and the GUID of the application stays the same.
See this link for more information:
http://www.simple-talk.com/dotnet/visual-studio/updates-to-setup-projects/
ClickOnce deployment is a great solution most of the time...
You can deploy to the web and when ever your users start the application it will check for updates and automatically update the application if there is a new version available.
It can also be configured not to update automatically but only to notify the user that there is a new version available and allow the user to control the update process.
This question already has an answer here:
How to make a WPF application a 30 day trial version, and make it licensed using product key?
(1 answer)
Closed 8 years ago.
C# 2008 SP1
I am writing an application that I want to give to a select number of customers.
What is the best solution to use so that after the trail period (1 month) the application will no longer work.
I was thinking that if they are interested in purchasing the software I will give them a license key or something, to unlock the application.
I am have a very limited budget as I am working on my own. So is there any free 3rd party products that does this?
If you go with a date-based approached, it can be circumvented by a user's setting their date back (although I doubt people do this very often). An alternative is to allow the application to be started a certain number of times before expiring; this approach obviously ignores any date changes.
My preferred method is to disable parts of the application that are critical to normal use of the program but aren't critical to its evaluation (like the ability to save your work, for example). I do this with my own software, and then send them an unlocking code unique to their computer when they purchase the full program. One primary advantage of this approach is that the installed demo functions as a potential sales tool forever. I'd rather have my program always working to some extent; I don't think a "Sorry, this program has expired" message generates many sales.
Your options:
At the installation write something to the registry, so that it is hard to find and remove later. This way your application will know when it was originally installed and whether it should still work right now or stop. This method will fail if the registry is cleaned well or if the OS is reinstalled.
Use some sort of online validation service. Will be free of the disadvantages of the [1]. Will also allow you to monitor application activity transcending the OS installation. For that to work you will need to somehow uniquely identify a user PC and transmit its signature to your server.
Here is the trick i did to stop users from playing with date/time settings and back dating the clock.
When the app runs for the first time, encrypt the first run date and end trial date and last run date in registry. And decrypt and check the end trial date and not system date from there on everytime the app runs. This solution works for users with no internet connectivity.
Write a registry key during your installation. The key will contain the date of the installation. The date in the registry key must be encrypted.
When your application is started, check for the existence of this registry key. If it does not exist close the application else decrypt the date, check the trial period and close the application if the trial is over.
The simplest solution (and as a result the simplest to circumvent) is to store the date the program is first installed (or run) in a file and then check that against the current date whenever the program is launched. If the difference is > 30 days then exit the program.
By storing the date in more obscure places or places that are harder for the user to tamper with (such as the registry) then it gets progressively harder for them to circumvent the system and get more time to use it, but doesn't stop them rewinding the clock on their PC.
If you store the date on your server and also get the date from your server then this is more secure, but does mean that the user has to have an open internet connection to use your software.
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?