Domanda

We use fluentmigrator and it wants a long for the migration number.

Normally I can just open the immedetiate window and type

System.DateTime.Now.ToString("yyyMMddhhmmss");

But sometimes it will say:

The expression cannot be evaluated while in design mode.

So I start debugging run the command again and get this error:

The expression cannot be evaluated while in run mode.

Edited to add

If I start debugging and hit pause and enter the command I get

Cannot evaluate expression because the current thread is in a sleep, wait, or join

If I start debugging hit a break point then it works but that is too many hoops to jump through and it has worked in the first scenario. It seems to build my project since if there were errors it wouldn't execute.

This is in visual studio 2010 pro.

Bonus points if one can tell me how to do this as a class template or maybe a powershell type thing?

I've tried the answer in Immediate Window, "The expression cannot be evaluated...." and selecting the project doesn't work. I don't get the > in the immediate window and if i put it before the command i get

Command "..." is not valid.

Edited To Add I created this gist to do what I wanted.

https://gist.github.com/9ad816c2b8e56b57ef79

basically a powershell command to create a c# template with some crap filled in.

È stato utile?

Soluzione

Why not just use PowerShell:

PS> [DateTime]::Now.ToString("yyyMMddhhmmss");
20120228043351

Altri suggerimenti

I'm not a visual studio user but this is how you can get the value with a PowerShell cmdlet:

Get-Date -Format yyyMMddhhmmss

You need to execute it in the third mode – Debug mode (paused in the debugger).

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top