# Manage users for webform auth missing option in Visual Studio

and then there was this stacktrace and error… I have not had this issue before. It was since the 4.6 framework was installed.

Thankfully I found this stackoverflow answer which resolves it:

in notepad++ and ctrl+g (go to) line 989 and give the string appId the value of “1” instead of the stringutil.blabla

No more error on:

StringUtil.GetNonRandomizedHashCode(String.Concat(appPath, appPhysPath)).ToString("x", CultureInfo.InvariantCulture);

Good luck!

# SqlCommands in a transaction

Lazy productive I as a developer am, I did not want to write a stored procedure. So I ended up with a lot of SQL statements which needed to be combined and executed only if the previous one succeeds.

However there was a timeout during the execution. It was strange because when I copy pasted the SQL statement in SMSS it worked perfectly and fast too. My mistake was to use a new SqlCommand object which was not part of the transaction. I needed to re-use the same sqlcommand. Here is some working code:

using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["myConString"].ToString()))
{
con.Open();

SqlCommand cmd = con.CreateCommand();
SqlTransaction transaction = con.BeginTransaction();

cmd.Connection = con;
cmd.Transaction = transaction;

try{

cmd.CommandText = "SELECT productcode FROM products WHERE productid = " + productid;
string code = cmd.ExecuteScalar().ToString();

cmd.CommandText = "SELECT ProductID, ProductWeight, ProductEuroPrice, OrderID FROM ORDERPICKINGPRODUCTS WHERE orderid = " + orderid + " AND productid = " + productid;
DataTable dt = new DataTable();

cmd.CommandText = "DELETE FROM ORDERPICKINGPRODUCTS WHERE orderid = " + orderid + " AND productid = " + productid;
cmd.ExecuteNonQuery();
transaction.Commit();
}
catch(Exception e)
{
transaction.Rollback();
}
}

I know that it is better to use parameters https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.parameters%28v=vs.110%29.aspx

And the AddWithValue method… But this is just pseudo code and not in production. So don’t worry!

This is just a small sample to help people with a strange timeout which you can encounter if you use an sqlcommand outside the transaction.

Good luck!

# Remote debugging Visual Studio 2013

The first step is of course install the remote debugging tools on the debug host http://msdn.microsoft.com/en-us/library/bt727f1t.aspx#BKMK_Installing_the_Remote_Tools

When I fire up the Visual Studio Remote Debugging Monitor (latest version 12.0.30501.0), it says that it is already running on port 4018 so I have selected a different port. I selected 4019 and went to the “Tools” menu and then “Options (Ctrl + o) I have selected 'No authentication' and check 'allow any user to debug'.

All there is left to do, is press play on the Visual studio side and make sure that you have the same port and no-auth set.

The other option is not to go to options but go to permissions (Ctrl + p) and add my Live ID/ Microsoft account from my developing machine, but that takes more clicks and my debugging device also forgets these settings. So you have to set it at every launch. Since I am also the admin of this tiny LAN, there is no security risk here and I can go with option 1.

I am able to remotely debug, it's just that I have to setup the debugging every time on the client side (Lenovo Miix 2 8" tablet running win8.1) The development side does not need to be reconfigured every time.

After spending some time on google/bing/duckduckgo I have found http://msdn.microsoft.com/en-us/library/bt727f1t%28v=vs.71%29.aspx which gives me details about launching the remote debugging monitor from the command line and give it some parameters.

I ended up with a small .bat file having these command line options:

msvcmon -anyuser -noauth -port=4019