MSDTC with client OS (Windows 7, 8, 10)

When trying to setup distributed transactions (MSDTC) there are essentially 2 things you need to do. 

First, you need to enable connections by running Component Services MMC

image

Second you need to allow access through the firewall

image

But if you are doing this on a “client OS” like Windows 7, 8, or 10, trying to get your dev machine to talk to your SQL Server on the network for example, you might run into additional problems.

If you run the DTCPing ( https://www.microsoft.com/en-us/download/details.aspx?id=2868 ) MSDTC trouble shooting tool and you get “Access is denied”, like this:

Invoking RPC method on (compname)
Problem:fail to invoke remote RPC method
Error(0x5) at dtcping.cpp @303
–>RPC pinging exception
–>5(Access is denied.)
RPC test failed

To fix this issue follow these steps (https://blogs.msdn.microsoft.com/puneetgupta/2008/11/12/troubleshooting-msdtc-issues-with-the-dtcping-tool/)

  1. Click Start, click Run, type Regedit, and then click OK.
  2. Locate and then click the following registry key:  HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT
  3. On the Edit menu, point to New, and then click Key.
  4. Note If the RPC registry key already exists, go to step 5.
  5. Type RPC, and then press ENTER. Click RPC.
  6. On the Edit menu, point to New, and then click DWORD Value.
  7. Type RestrictRemoteClients, and then press ENTER.
  8. Click RestrictRemoteClients.
  9. On the Edit menu, click Modify.
  10. In the Value data box, type 0, and then click OK.
  11. Note To enable the RestrictRemoteClients setting, type1.
  12. Close Registry Editor and restart the computer.

Reporting blocked processes in SQL

Recently I’ve been working on an issue where a query was being blocked.  In order to get the specifics on this it’s possible to use the Blocked progress report in the SQL Profiler.

To do this you need to first enable advanced options by running:

SP_CONFIGURE’show advanced options’,1 ;
GO

Then run:

RECONFIGURE;
GO

After turning that one, you need to set the blocked process threshold.  This is the number of seconds between checks to see if there is blocking going on. 

SP_CONFIGURE’blocked process threshold’,10 ;
GO

This will set it for 10 seconds.  You could change it to something lower if you want.  When you are done testing you should change it back to 0 (disabled).

After setting the threshold you need to reconfigure again:

RECONFIGURE;
GO

Then pick the Blocked process report from SQL Profiler:

image

The possible values of the Mode value are:

0=NULL
1=Sch-S
2=Sch-M
3=S
4=U
5=X
6=IS
7=IU
8=IX
9=SIU
10=SIX
11=UIX
12=BU
13=RangeS-S
14=RangeS-U
15=RangeI-N
16=RangeI-S
17=RangeI-U
18=RangeI-X
19=RangeX-S
20=RangeX-U
21=RangeX-X

Procedure or function expects parameter which was not supplied.

If you are googling for this error:

“Procedure or function (name) expects parameter (@parameter) which was not supplied.”

and you are SURE that you are providing the parameter to your stored procedure call, remember that for this to work properly with ADO.NET you need to set the IDdCommand or SqlCommand CommandType to be CommandType.StoredProcedure.

image

Failed to load viewstate (when debugging)

I’m not sure of the reason, but I couldn’t find anyone else posting about this so I figured I’d put it out there incase another puzzled developer goes looking.  In an application I’m working on (that happens to use Telerik radAjaxManager for this postback) I would consistently get this error, which as many will know is something you can get if you start adding controls to the tree in a page event that happens after Init, but I wasn’t adding any controls.  Turns out that this error completely goes away if I disable my break points.  Even if I’m still debugging, but my break points are disabled, I never see this error.

image

I don’t know what’s going on but maybe someone else will see this same post and know that they are not alone. 

Visual Studio 2015 Nuget.Config repositoryPath

So it looks like VS 2015 has changed (again) how they deal with Nuget management.  Now they no longer create the .nuget folder and the nuget.config file.

We still want to make use of the respositoryPath so to do this for new solutions create in VS 2015 we need to:

  1. Create a .nuget folder in the root of the solution (on the file system)
  2. Inside that folder, create a file NuGet.config. 
  3. In Visual Studio 2015, right click on the solution and add a new solution directory called “.nuget”
  4. Right click on that folder and select to add a new an existing file and select the NuGet.config file created in (2).
  5. Add content like this inside the NuGet.config file:

<?xml version=”1.0″ encoding=”utf-8″?>
<configuration>
  <solution>
    <add key=”disableSourceControlIntegration” value=”true” />
  </solution>
  <config>
    <add key=”repositoryPath” value=”..\..\..\..\NugetPackages” />
  </config>
</configuration>

Then reboot Visual Studio and it should work.

Fixing Hyper V “VMName failed to change state” error 32788

If you find yourself getting this error message:

The application encountered an error while attempting to change the state of ‘VMName’.  ‘VMName’ failed to change state.  The operation failed with error code ‘32788.’

image

Go to the settings of your VM:

image

And look for something in an error state:

image

In this case I had changed Virtual Switch since using the VM so it’s no longer valid.

Remoting (RDP) to Azure service: This User Has Expired

If you are trying to RDP into an Azure service and you get the message “This User Has Expired” that’s because when Cloud Services are deployed, the user is only enabled for a short period of time.  If you don’t want to fully redeploy your application you can modify the expiration.

To do this, go to the service’s Configuration section and click the Download button to download the configuration file.

image

In that configuration file you’ll need to change the value for:

Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountExpiration

image

Go back to the configuration page and upload this file using the Upload button.  Press Save and after a few moments it will change your user accounts expiration date.

ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION

Recently when trying to server up some images that were stored in an Azure storage container, we were noticing that the files presented this error message when using Chrome (but Fiddler traces showed success and it worked fine in other browsers).

image

It turns out this was not caused by duplicate header values being added to the response but instead it was because the image file name contained a comma that was not properly escaped by putting double quotes around the filename like this:

Response.AddHeader("Content-Disposition", "attachment;filename=\"" + filename + "\"");

Red Gate SQL Source Control–Solution for users not seeing Last Changed By user names

After installing the latest version of Red Gate SQL Source Control many of our non-sys-admin users were unable to see who had made changes to a database object.

image

After reading all the documentation and applying the suggested permission changes we found that we were still lacking some of the needed permissions to get this working.  After looking through exception details in the log files we were able to get all the right permissions setup.  Use the script below to grant your user/group the necessary rights.

USE master

go

GRANT ALTER TRACE TO [UserHere]

GO

GRANT VIEW SERVER STATE TO [UserHere]

go

GRANT SELECT ON sys.sql_expression_dependencies TO [UserHere]

GO

USE tempdb

go

GRANT EXECUTE ON tempdb .dbo. RG_WhatsChanged_v4 TO [UserHere]

GO

GRANT CREATE TABLE TO [UserHere]

GO

GRANT ALTER on SCHEMA::dbo TO [UserHere]

go