Showing posts with label Visual Studio. Show all posts
Showing posts with label Visual Studio. Show all posts

Tuesday, September 29, 2015

XSD in Visual Studio and the warning message "Request for the permission of type 'System.Security.Permissions.FileIOPermission"

When working in a project in Visual Studio that had a schema repository added, the warning message "Request for the permission of type 'System.Security.Permissions.FileIOPermission" showed up in various places where I had schema imports. The warning did not show up everywhere though and the project built just fine.


It turned out that the reason was that some of the xsd files where downloaded or copied from a network share and were therefore blocked in Windows, leading up to the warning message.


The warnings could be removed by simply unblocking the offending files, and restarting Visual Studio.

This also lead me to the quick way to unblock a lot of files at once. Simply use PowerShell to iterate over the files and use the Unblock-File cmdlet:
gci -r | Unblock-File

Thursday, August 5, 2010

Visual Studio hangs after debugging

I have repeatedly since I started working in Visual Studio 2008 been swearing while debugging applications since the whole IDE stops responding for a while when stopping the debug session. No updates, service packs or changes to the preferences has been able to stop this behaviour. I've also seen it on numerous other machines and have never been able to figure out why this is happening.

Yesterday I started investigating the issue again and stumbled upon a discussion I've missed before: http://social.msdn.microsoft.com/Forums/en-US/vsdebug/thread/e9c5da47-a194-4051-a3d5-28b404263b3f

In this discussion, the problem is both found and solutions offered.

The culprit can be many things, but the most common one is that the IDE is trying to contact a server in order to check certificate store validity. If the server can't be reached properly (due to proxies and whatnot), the IDE will hang before timing out.

So, if you have a problem with Visual Studio hanging when stopping a debug, try the following:

First, unplug the network cable (or if you are running wireless, kill the wireless NIC). If this solves the problem, you have an issue with the certificate store. If the IDE still hangs, remove all breakpoints in the code and try again. If there still is a problem, remove the .sou file and retry, this can be corrupt and cause a slowdown.

If you had a snappy IDE with the network cable unplugged, either leave it unplugged, or try one of the following solutions.

Before changing the settings for the certificate store, make sure that all unnecessary protocols are disabled in the network properties. Reports have been made that especially NetWare can interfere. This might solve your problem.

Change the certificate revocation setting in Internet Explorer. Open IE, go to Tools > Internet Options > Advanced > Security > Check for Publisher's Certificate Revocation and uncheck this option. This is a bit unsafe to do though so be aware.

Another solution is to edit the hosts file (\windows\system32\drivers\etc\hosts) to point the URL to your own machine. Add 127.0.0.1 crl.microsoft.com to the file. This is just as unsafe as changing the setting in IE and might end up a change that you forget which can cause grief in the future.


For me, changing the IE settings solved it and I can finally be happy when debugging in Visual Studio.

Tuesday, June 29, 2010

Build using msbuild instead of devenv

I have lately encountered a lot of build scripts that are using devenv. I have a hard time seeing why, now that msbuild is available (and has been for quite a while). Even if you don't want to use the massive amount of possibilities that msbuild brings with it, just swapping out the build part in the scripts can be worth it.

For example, the common line I tend to see is this:
DevEnv /rebuild Release %Solution%

A quick replace to this:
msbuild %Solution% /p:Configuration=Release /T:Rebuild
Will give a 30% speed increase in my cases.
 
If the machine is equipped with several CPU cores (most are), the multicore-switch can give an extra boost:
msbuild %Solution% /p:Configuration=Release /T:Rebuild /m:2

Saturday, June 12, 2010

The expression that you have entered is not valid.

A notorious error message in BizTalk is the irritating "The expression that you have entered is not valid.". This message will be shown in a random fashion when using expression shapes in orchestrations. The message will not make sense since the expression entered in fact is perfectly valid and it will seem impossible to make the message with it's red exclamation mark go away.

I have found two solutions to this problem (not permanent though). One is to simply close and reopen Visual Studio. This will not always work. The other is to comment out the line in question in the expression shape, build the project, and then uncomment the line again.

The reason the message can stick to the project is due to the fact that it is written to the orchestration file itself. This is one of few occasions I've seen error messages be saved to a source file as can be seen in the snippet below:

[Microsoft.XLANGs.BaseTypes.DesignerPosition("3616dac3-6f4f-482a-a3c4-1417e828c572")]
scope longrunning transaction Scope_Trans
{
  body
  {
    #error "The expression that you have entered is not valid."
    [Microsoft.XLANGs.BaseTypes.DesignerPosition("e6cc3fbe-3385-43a2-b535-2a066e76d63c")]
    TSFactory.Framework.Logger.Log(System.Diagnostics.TraceEventType.Information, System.String.Format("{0} Orchestration Start", tracePrefix), logCategory);

By commenting out the line and rebuilding, the error message will also be deleted from the source file and then completely disappear.

Microsoft has released a hotfix for this problem, but I cannot find that it fixed the issue for me, especially in the case of calling external assemblies from an expression shape. Neither did it do any measurable difference for my colleagues. The hotfix can however be found here: http://support.microsoft.com/kb/979153.