Perfil de PaulioIT BytesBlogListasScraps Ferramentas Ajuda

Blog


27 de julho

Remote debugging - value as being optimized

Surley one of the most annoying problems with remote debugging is after finally getting a connection, the correct pdb's, the correct source and a breakpoint hit you examing the values to be faced with a big red cross saying the value has probably being optimized and you cannot view it. I'm not absolutley sure of the reason but I guessed that CLR had optimised it because the code had run before the debugger was attached. So my tip is to try and attach the debugger before the code is run. Obviously not the easiest thing to do every time but if you can do this then the CLR will not optimize the values aways. Hopefully someone out there will provide a better answer.
 
 
24 de julho

Listing the files in a Changeset

I've been trying to do this off an on for a while and finally tracked it down...
 
To list the files in a changeset;

C:\Program Files\Microsoft Visual Studio 8\Common7\IDE>tf changeset /i 27880

 

To show the dialog in a separate process so you can carry on using Visual Studio just omit the /i
15 de julho

Passing Exceptions from WCF to Silverlight

After upgrading a Silverlight project to 3 I wondered if the story about passing exceptions from WCF to SL had changed. Previously, because WCF sends fault messages as 500 response codes SL could not see them. However, although I believe this is still true I spotted, Creating and Handling Faults in Silverlight, which explains how to change the end-point behaviour to return faults as 200 codes and therefore suddenly allowing Silverlight to see them. I did have a few teething problems with, mainly to do with me misreading the config soup. One quick gotcha is to remember to refresh your service reference so you can see the new exception, I mean fault, classes.
 
 
12 de julho

Database for Silverlight

Another quick bookmark of a blog that talks about an open source database project that could be ideal for Silverlight out-of-browser applications

Embedded Database Engine for Silverlight Applications

08 de julho

Online Visual Studio like IDE

Just discovered Code Run which is basically a Visual Studio clone that runs online, even has Silverlight projects. 
07 de julho

Linq recipe #3, flatten a dictionary of byte arrays into a single byte array

Dictionary<int, byte[]> binaryParts = new Dictionary<int, byte[]>();

...

// now combine the binary from all the parts by first sorting by key

var flattenedList = binaryParts.OrderBy(p => p.Key).SelectMany(p => p.Value);

byte[] combinedBytes = flattenedList.ToArray();

Linq recipe #2, Convert a CSV string of numbers into an array of numbers

e.g. for every (n) item in the array, apply the Convert function to it and return that as the nth item in the new array

 

int[] strongValues = Array.ConvertAll(csvString.Split(','), n => Convert.ToInt32(n));

Linq recipe #1 combining two enums into a single dictionary

// Using Linq, ignore problems with jaggies

List<int> keys = new List<int> { 1, 2, 3, 4, 5 };           

List<string> data = new List<string> { "a", "b", "c", "d","e" };

 

Dictionary<int,string> combo = (from k in keys

            join d in data on keys.FindIndex(x => x==k) equals data.FindIndex(x2 => x2==d)                           

            select new {Key=k, Value=d} ).ToDictionary(de=>de.Key, de=>de.Value);

foreach (var i in combo)

{

    System.Diagnostics.Debug.WriteLine(i.Key + "," + i.Value);

}

 

// Using lamda expression, doesn't allow jaggies

Dictionary<int, string> UrisByProject = new Dictionary<int, string>();

List<int> nonZeroProjectIds = new List<int>() { 1, 2, 3, 4,5 };

List<string> urisForTheImage = new List<string>() { "a", "b", "c", "d", "e" };

nonZeroProjectIds.ForEach(p => UrisByProject.Add(p, urisForTheImage[nonZeroProjectIds.FindIndex(t => t == p)]));

foreach (var i2 in UrisByProject)

{

    System.Diagnostics.Debug.WriteLine(i2.Key + "," + i2.Value);

}

Problems with locked DLLs when compiling in Visual Studio

For some, as yet to be understood, reason after a few debug sessions some of the dependant DLLs become locked by Visual Studio and the build stage cannot overwrite the DLLs. Today I finally decided to see if anyone else was have the same problem and found this in Gary Farr's blog (copied in case the blog becomes unavailable);
 
Final solution:
VS basically locks the file and you cannot use third party resources to unlock it.  Therefore, just use VS!  In the Properties of a project in your IDE you have Buld Events.  Basically, you can write scripts during pre and post builds of a project.  I added these two lines in the pre-build event command line, which basically unlocks the dll within Visual Studio.

IF EXIST $(TargetPath).LOCKED  (del $(TargetPath).LOCKED) ELSE (IF EXIST $(TargetPath) (move $(TargetPath) $(TargetPath).LOCKED))